From 615b006e4ad84449d56ab06272ffca860fea0fa7 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Tue, 10 Oct 2023 01:08:25 -0700 Subject: [PATCH] updating nwb_schema_language to have proper single/multi fields for author/contact --- nwb_linkml/pyproject.toml | 2 +- nwb_schema_language/docs/CHANGELOG.md | 12 +++++++++++- nwb_schema_language/pyproject.toml | 2 +- .../datamodel/nwb_schema_pydantic.py | 4 ++-- .../src/nwb_schema_language/patches.py | 14 ++++++++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/nwb_linkml/pyproject.toml b/nwb_linkml/pyproject.toml index 47515c4..5451559 100644 --- a/nwb_linkml/pyproject.toml +++ b/nwb_linkml/pyproject.toml @@ -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" diff --git a/nwb_schema_language/docs/CHANGELOG.md b/nwb_schema_language/docs/CHANGELOG.md index 06796a7..90894d7 100644 --- a/nwb_schema_language/docs/CHANGELOG.md +++ b/nwb_schema_language/docs/CHANGELOG.md @@ -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 \ No newline at end of file +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` \ No newline at end of file diff --git a/nwb_schema_language/pyproject.toml b/nwb_schema_language/pyproject.toml index ae207a2..a7849ad 100644 --- a/nwb_schema_language/pyproject.toml +++ b/nwb_schema_language/pyproject.toml @@ -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 "] license = "GNU GPL v3.0" diff --git a/nwb_schema_language/src/nwb_schema_language/datamodel/nwb_schema_pydantic.py b/nwb_schema_language/src/nwb_schema_language/datamodel/nwb_schema_pydantic.py index f041572..9762fab 100644 --- a/nwb_schema_language/src/nwb_schema_language/datamodel/nwb_schema_pydantic.py +++ b/nwb_schema_language/src/nwb_schema_language/datamodel/nwb_schema_pydantic.py @@ -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.""") diff --git a/nwb_schema_language/src/nwb_schema_language/patches.py b/nwb_schema_language/src/nwb_schema_language/patches.py index 3fd58df..692bde7 100644 --- a/nwb_schema_language/src/nwb_schema_language/patches.py +++ b/nwb_schema_language/src/nwb_schema_language/patches.py @@ -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: