updating nwb_schema_language to have proper single/multi fields for author/contact

This commit is contained in:
sneakers-the-rat 2023-10-10 01:08:25 -07:00
parent 825b5914db
commit 615b006e4a
5 changed files with 29 additions and 5 deletions

View file

@ -18,7 +18,7 @@ packages = [
python = ">=3.11,<3.13"
pyyaml = "^6.0"
linkml-runtime = "^1.5.6"
nwb_schema_language = "^0.1.1"
nwb_schema_language = "^0.1.3"
rich = "^13.5.2"
linkml = "^1.5.7"
nptyping = "^2.5.0"

View file

@ -3,4 +3,14 @@
Revised models to make `name` an optional slot regardless of presence/absence
of `neurodata_type_def`, the naming of individual classes within the schema will be
handled by `nwb_linkml` - see:
https://github.com/NeurodataWithoutBorders/nwb-schema/issues/552
https://github.com/NeurodataWithoutBorders/nwb-schema/issues/552
# 0.1.2
Regenerating models to refresh... not many changes
# 0.1.3
Except that I broke the ability for the `Namespace` model to parse singleton authors.
Reinstated with a patch that runs on `gen-pydantic`

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "nwb_schema_language"
version = "0.1.2"
version = "0.1.3"
description = "Translation of the nwb-schema-language to LinkML"
authors = ["Jonny Saunders <j@nny.fyi>"]
license = "GNU GPL v3.0"

View file

@ -112,8 +112,8 @@ class Namespace(ConfiguredBaseModel):
full_name: Optional[str] = Field(None, description="""Optional string with extended full name for the namespace.""")
version: str = Field(...)
date: Optional[datetime ] = Field(None, description="""Date that a namespace was last modified or released""")
author: List[str] = Field(default_factory=list, description="""List of strings with the names of the authors of the namespace.""")
contact: List[str] = Field(default_factory=list, description="""List of strings with the contact information for the authors. Ordering of the contacts should match the ordering of the authors.""")
author: List[str] | str = Field(default_factory=list, description="""List of strings with the names of the authors of the namespace.""")
contact: List[str] | str = Field(default_factory=list, description="""List of strings with the contact information for the authors. Ordering of the contacts should match the ordering of the authors.""")
schema_: Optional[List[Schema]] = Field(alias="schema", default_factory=list, description="""List of the schema to be included in this namespace.""")

View file

@ -66,6 +66,20 @@ patch_dtype_single_multiple = Patch(
replacement=r'\1Union[List[CompoundDtype], \2',
)
patch_author_single_multiple = Patch(
phase=Phases.post_generation_pydantic,
path=Path('src/nwb_schema_language/datamodel/nwb_schema_pydantic.py'),
match=r"author: List\[str\]",
replacement="author: List[str] | str"
)
patch_contact_single_multiple = Patch(
phase=Phases.post_generation_pydantic,
path=Path('src/nwb_schema_language/datamodel/nwb_schema_pydantic.py'),
match=r"contact: List\[str\]",
replacement="contact: List[str] | str"
)
def run_patches(phase:Phases, verbose:bool=False):
patches = [p for p in Patch.instances if p.phase == phase]
for patch in patches: