diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9315d09..a8c0a08 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,17 +6,10 @@ repos: exclude: package.lock.json args: ["--exclude-lines", "\\s*\"image/png\": \".+\""] - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 # Use the latest version - hooks: - - id: isort - - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.287 # Use the latest version + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.2 # Use the latest version hooks: - id: ruff - - - repo: https://github.com/psf/black - rev: 23.3.0 # Use the latest version - hooks: - - id: black + args: ["check", "--select", "I,F,B,A,C4,ICN,LOG,G,PIE,RET,SIM,TD,PD,PLW,NPY,DOC,UP", "--ignore", "TD003,PD901,UP006,UP035", "--fix"] + - id: ruff-format + args: ["--line-length", "120"] diff --git a/poetry.lock b/poetry.lock index 7efd3f9..fe99936 100644 --- a/poetry.lock +++ b/poetry.lock @@ -56,33 +56,33 @@ test = ["astroid (>=1,<2)", "astroid (>=2,<4)", "pytest"] [[package]] name = "black" -version = "24.4.2" +version = "24.10.0" description = "The uncompromising code formatter." optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "black-24.4.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dd1b5a14e417189db4c7b64a6540f31730713d173f0b63e55fabd52d61d8fdce"}, - {file = "black-24.4.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8e537d281831ad0e71007dcdcbe50a71470b978c453fa41ce77186bbe0ed6021"}, - {file = "black-24.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eaea3008c281f1038edb473c1aa8ed8143a5535ff18f978a318f10302b254063"}, - {file = "black-24.4.2-cp310-cp310-win_amd64.whl", hash = "sha256:7768a0dbf16a39aa5e9a3ded568bb545c8c2727396d063bbaf847df05b08cd96"}, - {file = "black-24.4.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:257d724c2c9b1660f353b36c802ccece186a30accc7742c176d29c146df6e474"}, - {file = "black-24.4.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:bdde6f877a18f24844e381d45e9947a49e97933573ac9d4345399be37621e26c"}, - {file = "black-24.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e151054aa00bad1f4e1f04919542885f89f5f7d086b8a59e5000e6c616896ffb"}, - {file = "black-24.4.2-cp311-cp311-win_amd64.whl", hash = "sha256:7e122b1c4fb252fd85df3ca93578732b4749d9be076593076ef4d07a0233c3e1"}, - {file = "black-24.4.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d"}, - {file = "black-24.4.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04"}, - {file = "black-24.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc"}, - {file = "black-24.4.2-cp312-cp312-win_amd64.whl", hash = "sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0"}, - {file = "black-24.4.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:bf10f7310db693bb62692609b397e8d67257c55f949abde4c67f9cc574492cc7"}, - {file = "black-24.4.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:98e123f1d5cfd42f886624d84464f7756f60ff6eab89ae845210631714f6db94"}, - {file = "black-24.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:48a85f2cb5e6799a9ef05347b476cce6c182d6c71ee36925a6c194d074336ef8"}, - {file = "black-24.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:b1530ae42e9d6d5b670a34db49a94115a64596bc77710b1d05e9801e62ca0a7c"}, - {file = "black-24.4.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:37aae07b029fa0174d39daf02748b379399b909652a806e5708199bd93899da1"}, - {file = "black-24.4.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:da33a1a5e49c4122ccdfd56cd021ff1ebc4a1ec4e2d01594fef9b6f267a9e741"}, - {file = "black-24.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ef703f83fc32e131e9bcc0a5094cfe85599e7109f896fe8bc96cc402f3eb4b6e"}, - {file = "black-24.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:b9176b9832e84308818a99a561e90aa479e73c523b3f77afd07913380ae2eab7"}, - {file = "black-24.4.2-py3-none-any.whl", hash = "sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c"}, - {file = "black-24.4.2.tar.gz", hash = "sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d"}, + {file = "black-24.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812"}, + {file = "black-24.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea"}, + {file = "black-24.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:649fff99a20bd06c6f727d2a27f401331dc0cc861fb69cde910fe95b01b5928f"}, + {file = "black-24.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:fe4d6476887de70546212c99ac9bd803d90b42fc4767f058a0baa895013fbb3e"}, + {file = "black-24.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5a2221696a8224e335c28816a9d331a6c2ae15a2ee34ec857dcf3e45dbfa99ad"}, + {file = "black-24.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f9da3333530dbcecc1be13e69c250ed8dfa67f43c4005fb537bb426e19200d50"}, + {file = "black-24.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4007b1393d902b48b36958a216c20c4482f601569d19ed1df294a496eb366392"}, + {file = "black-24.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:394d4ddc64782e51153eadcaaca95144ac4c35e27ef9b0a42e121ae7e57a9175"}, + {file = "black-24.10.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b5e39e0fae001df40f95bd8cc36b9165c5e2ea88900167bddf258bacef9bbdc3"}, + {file = "black-24.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d37d422772111794b26757c5b55a3eade028aa3fde43121ab7b673d050949d65"}, + {file = "black-24.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14b3502784f09ce2443830e3133dacf2c0110d45191ed470ecb04d0f5f6fcb0f"}, + {file = "black-24.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:30d2c30dc5139211dda799758559d1b049f7f14c580c409d6ad925b74a4208a8"}, + {file = "black-24.10.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1cbacacb19e922a1d75ef2b6ccaefcd6e93a2c05ede32f06a21386a04cedb981"}, + {file = "black-24.10.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1f93102e0c5bb3907451063e08b9876dbeac810e7da5a8bfb7aeb5a9ef89066b"}, + {file = "black-24.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ddacb691cdcdf77b96f549cf9591701d8db36b2f19519373d60d31746068dbf2"}, + {file = "black-24.10.0-cp313-cp313-win_amd64.whl", hash = "sha256:680359d932801c76d2e9c9068d05c6b107f2584b2a5b88831c83962eb9984c1b"}, + {file = "black-24.10.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:17374989640fbca88b6a448129cd1745c5eb8d9547b464f281b251dd00155ccd"}, + {file = "black-24.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:63f626344343083322233f175aaf372d326de8436f5928c042639a4afbbf1d3f"}, + {file = "black-24.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ccfa1d0cb6200857f1923b602f978386a3a2758a65b52e0950299ea014be6800"}, + {file = "black-24.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:2cd9c95431d94adc56600710f8813ee27eea544dd118d45896bb734e9d7a0dc7"}, + {file = "black-24.10.0-py3-none-any.whl", hash = "sha256:3bb2b7a1f7b685f85b11fed1ef10f8a9148bceb49853e47a294a3dd963c1dd7d"}, + {file = "black-24.10.0.tar.gz", hash = "sha256:846ea64c97afe3bc677b761787993be4991810ecc7a4a937816dd6bddedc4875"}, ] [package.dependencies] @@ -94,7 +94,7 @@ platformdirs = ">=2" [package.extras] colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] +d = ["aiohttp (>=3.10)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] @@ -1774,4 +1774,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "398218abd7c2a6a86b136595f889e018e6a2f7630300820d9119114f48d47628" +content-hash = "3623a566d22cfb484a71c160fa733a8b08afb11b5b726c621ca809ba00152f21" diff --git a/pydantic_schemas/document_schema.py b/pydantic_schemas/document_schema.py index a1f5e55..2c2457a 100644 --- a/pydantic_schemas/document_schema.py +++ b/pydantic_schemas/document_schema.py @@ -26,14 +26,22 @@ class MetadataInformation(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) production_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version: Optional[str] = Field( - None, description="Identify and describe the current version of the document", title="Document version" + None, + description="Identify and describe the current version of the document", + title="Document version", ) @@ -54,9 +62,13 @@ class TitleStatement(SchemaBaseModel): class AuthorIdItem(SchemaBaseModel): - type: Optional[Any] = Field(None, description="Source of identifier, e.g. ORCID", title="Type") + type: Optional[Any] = Field( + None, description="Source of identifier, e.g. ORCID", title="Type" + ) id: Optional[Any] = Field( - None, description="Author's unique identifier for the corresponding source", title="Identifier" + None, + description="Author's unique identifier for the corresponding source", + title="Identifier", ) @@ -72,9 +84,7 @@ class Author(SchemaBaseModel): ) full_name: Optional[str] = Field( None, - description=( - "Full name of the author. This element to be used only when first or last name cannot be distinguished." - ), + description="Full name of the author. This element to be used only when first or last name cannot be distinguished.", title="Full name", ) @@ -88,7 +98,9 @@ class Editor(SchemaBaseModel): class Identifier(SchemaBaseModel): type: Optional[str] = Field( - None, description="Type of identifier e.g. `doi`, `handle`, `other`", title="Identifier type" + None, + description="Type of identifier e.g. `doi`, `handle`, `other`", + title="Identifier type", ) identifier: str = Field(..., title="Identifier") @@ -96,7 +108,9 @@ class Identifier(SchemaBaseModel): class TocStructuredItem(SchemaBaseModel): id: str = Field(..., title="ID or Number") parent_id: Optional[str] = Field( - None, description="For sub levels, provide the ID of the parent TOC ID", title="Parent Identifier" + None, + description="For sub levels, provide the ID of the parent TOC ID", + title="Parent Identifier", ) name: str = Field(..., title="Title") @@ -112,13 +126,19 @@ class RefCountryItem(SchemaBaseModel): class GeographicUnit(SchemaBaseModel): name: str = Field( - ..., description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", title="Location name" + ..., + description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", + title="Location name", ) code: Optional[str] = Field( - None, description="Code of the geographic unit (for countries, preferred = ISO3 code)", title="Location code" + None, + description="Code of the geographic unit (for countries, preferred = ISO3 code)", + title="Location code", ) type: Optional[str] = Field( - None, description="Type of geographic unit e.g. country, state, region, province, town, etc", title="Type" + None, + description="Type of geographic unit e.g. country, state, region, province, town, etc", + title="Type", ) @@ -169,10 +189,7 @@ class Contact(SchemaBaseModel): class Source(SchemaBaseModel): source_origin: Optional[str] = Field( None, - description=( - "For historical materials, information about the origin(s) of the sources and the rules followed in" - " establishing the sources should be specified. May not be relevant to survey data. " - ), + description="For historical materials, information about the origin(s) of the sources and the rules followed in establishing the sources should be specified. May not be relevant to survey data. ", title="Origin of Source", ) source_char: Optional[str] = Field( @@ -181,7 +198,9 @@ class Source(SchemaBaseModel): title="Characteristics of Source Noted", ) source_doc: Optional[str] = Field( - None, description="Documentation and Access to Sources", title="Source documentation" + None, + description="Documentation and Access to Sources", + title="Source documentation", ) @@ -195,7 +214,9 @@ class Theme(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Name") parent_id: Optional[str] = Field(None, title="Parent Identifier") - vocabulary: Optional[str] = Field(None, description="Name of the controlled vocabulary", title="Vocabulary") + vocabulary: Optional[str] = Field( + None, description="Name of the controlled vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field( None, description="Link to the controlled vocabulary web page, if the theme is from a taxonomy.", @@ -207,10 +228,14 @@ class Topic(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Topic") parent_id: Optional[str] = Field( - None, description="For subtopics, provide the ID of the parent topic", title="Parent topic Identifier" + None, + description="For subtopics, provide the ID of the parent topic", + title="Parent topic Identifier", ) vocabulary: Optional[str] = Field( - None, description="Name of the controlled vocabulary, if the topic is from a taxonomy.", title="Vocabulary" + None, + description="Name of the controlled vocabulary, if the topic is from a taxonomy.", + title="Vocabulary", ) uri: Optional[str] = Field( None, @@ -222,8 +247,12 @@ class Topic(SchemaBaseModel): class Discipline(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Discipline title or name") - parent_id: Optional[str] = Field(None, description="Parent discipline ID", title="Parent discipline Identifier") - vocabulary: Optional[str] = Field(None, description="Vocabulary", title="Vocabulary") + parent_id: Optional[str] = Field( + None, description="Parent discipline ID", title="Parent discipline Identifier" + ) + vocabulary: Optional[str] = Field( + None, description="Vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field(None, description="Website link", title="URI") @@ -262,21 +291,28 @@ class Tag(SchemaBaseModel): class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -285,7 +321,9 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class KeywordItem(SchemaBaseModel): @@ -303,99 +341,116 @@ class DocumentDescription(SchemaBaseModel): extra="forbid", ) title_statement: TitleStatement = Field(..., description="Study title") - authors: Optional[List[Author]] = Field(None, description="Authors", title="Authors") - editors: Optional[List[Editor]] = Field(None, description="Editors", title="Editors") - date_created: Optional[str] = Field(None, description="Date of creation", title="Date created") + authors: Optional[List[Author]] = Field( + None, description="Authors", title="Authors" + ) + editors: Optional[List[Editor]] = Field( + None, description="Editors", title="Editors" + ) + date_created: Optional[str] = Field( + None, description="Date of creation", title="Date created" + ) date_available: Optional[str] = Field( None, description="Date (often a range) that the resource will become or did become available.", title="Date available", ) date_modified: Optional[str] = Field( - None, description="Date on which the resource was changed.", title="Date last modified" + None, + description="Date on which the resource was changed.", + title="Date last modified", ) date_published: Optional[str] = Field( - None, description="Date on which document was published.", title="Date published" + None, + description="Date on which document was published.", + title="Date published", + ) + identifiers: Optional[List[Identifier]] = Field( + None, description="Other identifiers", title="Other identifiers" ) - identifiers: Optional[List[Identifier]] = Field(None, description="Other identifiers", title="Other identifiers") type: Optional[str] = Field( None, - description=( - "Valid values include - `article`, `book`, `booklet`, `collection`, `conference`, `inbook`, `incollection`," - " `inproceeding`,`manual`, `masterthesis`, `patent`, `phdthesis`, `proceedings`, `techreport`," - " `working-paper`, `website`, `other` " - ), + description="Valid values include - `article`, `book`, `booklet`, `collection`, `conference`, `inbook`, `incollection`, `inproceeding`,`manual`, `masterthesis`, `patent`, `phdthesis`, `proceedings`, `techreport`, `working-paper`, `website`, `other` ", title="Resource type", ) status: Optional[str] = Field( None, - description=( - "Status of the document - e.g. `Draft`, `Draft released for comment`, `Final draft released for comment`," - " `Final` " - ), + description="Status of the document - e.g. `Draft`, `Draft released for comment`, `Final draft released for comment`, `Final` ", title="Status", ) description: Optional[str] = Field( - None, description="An account of the content of the resource.", title="Description" + None, + description="An account of the content of the resource.", + title="Description", + ) + toc: Optional[str] = Field( + None, description="Table of contents", title="Table of contents" ) - toc: Optional[str] = Field(None, description="Table of contents", title="Table of contents") toc_structured: Optional[List[TocStructuredItem]] = Field( None, description="Table of contents", title="Table of contents" ) - abstract: Optional[str] = Field(None, description="A summary of the content", title="Abstract") + abstract: Optional[str] = Field( + None, description="A summary of the content", title="Abstract" + ) notes: Optional[List[Note]] = Field(None, title="Notes") scope: Optional[str] = Field( None, - description=( - "The extent or scope of the content of the resource. This fields maps to Dublin Core's coverage field." - ), + description="The extent or scope of the content of the resource. This fields maps to Dublin Core's coverage field.", title="Scope", ) ref_country: Optional[List[RefCountryItem]] = Field(None, title="Reference country") geographic_units: Optional[List[GeographicUnit]] = Field( None, - description=( - "List of geographic locations (regions, countries, states, provinces, etc.) describing the geographic" - " coverahe of the research project." - ), + description="List of geographic locations (regions, countries, states, provinces, etc.) describing the geographic coverahe of the research project.", title="Geographic locations", ) bbox: Optional[List[BboxItem]] = Field(None, title="Geographic bounding box") spatial_coverage: Optional[str] = Field( - None, description="The spatial extent or scope of the content of the resource.", title="Spatial coverage" + None, + description="The spatial extent or scope of the content of the resource.", + title="Spatial coverage", ) temporal_coverage: Optional[str] = Field( - None, description="The temporal extent or scope of the content of the resource.", title="Temporal coverage" + None, + description="The temporal extent or scope of the content of the resource.", + title="Temporal coverage", ) publication_frequency: Optional[str] = Field( None, - description=( - "Current stated publication frequency of either an item or an update to an item. Dates are included when" - " the beginning date of the current frequency is not the same as the beginning date of publication." - ), + description="Current stated publication frequency of either an item or an update to an item. Dates are included when the beginning date of the current frequency is not the same as the beginning date of publication.", title="Publication frequency", ) languages: Optional[List[Language]] = Field( - None, description="Documentation language e.g. English, French, etc.", title="Language" + None, + description="Documentation language e.g. English, French, etc.", + title="Language", ) license: Optional[List[LicenseItem]] = Field(None, title="License") bibliographic_citation: Optional[List[BibliographicCitationItem]] = Field( - None, description="A bibliographic reference for the resource.", title="Bibliographic citation" + None, + description="A bibliographic reference for the resource.", + title="Bibliographic citation", + ) + chapter: Optional[str] = Field( + None, description="A chapter or section number", title="Chapter number" + ) + edition: Optional[str] = Field( + None, description="The edition of a book", title="Edition" ) - chapter: Optional[str] = Field(None, description="A chapter or section number", title="Chapter number") - edition: Optional[str] = Field(None, description="The edition of a book", title="Edition") institution: Optional[str] = Field( - None, description="The sponsoring institution of a document.", title="Institution" + None, + description="The sponsoring institution of a document.", + title="Institution", + ) + journal: Optional[str] = Field( + None, description="Name of the Journal", title="Journal name" + ) + volume: Optional[str] = Field( + None, description="Volume number", title="Volume number" ) - journal: Optional[str] = Field(None, description="Name of the Journal", title="Journal name") - volume: Optional[str] = Field(None, description="Volume number", title="Volume number") number: Optional[str] = Field( None, - description=( - "The number of a journal, magazine, technical report, or of a work in a series. An issue of a journal or" - " magazine is usually identified by its volume and number; the organization that issues a technical report" - " usually gives it a number; and sometimes books are given numbers in a named series." - ), + description="The number of a journal, magazine, technical report, or of a work in a series. An issue of a journal or magazine is usually identified by its volume and number; the organization that issues a technical report usually gives it a number; and sometimes books are given numbers in a named series.", title="Number", ) pages: Optional[str] = Field( @@ -405,86 +460,85 @@ class DocumentDescription(SchemaBaseModel): ) series: Optional[str] = Field( None, - description=( - "The name given to a series or set of books. When citing an entire book, the title field gives its title" - " and the optional series field gives the name of a series in which the book was published." - ), + description="The name given to a series or set of books. When citing an entire book, the title field gives its title and the optional series field gives the name of a series in which the book was published.", title="Series name", ) publisher: Optional[str] = Field( - None, description="Entity responsible for making the resource available", title="Publisher" + None, + description="Entity responsible for making the resource available", + title="Publisher", ) publisher_address: Optional[str] = Field( None, - description=( - "For major publishing houses, just the city is given. For small publishers, you can help the reader by" - " giving the complete address." - ), + description="For major publishing houses, just the city is given. For small publishers, you can help the reader by giving the complete address.", title="Publisher's address", ) annote: Optional[str] = Field( None, - description=( - "For annotation, element will not be used by standard bibliography styles like the MLA, APA or Chicago, but" - " may be used by others that produce an annotated bibliography." - ), + description="For annotation, element will not be used by standard bibliography styles like the MLA, APA or Chicago, but may be used by others that produce an annotated bibliography.", title="Annotation", ) booktitle: Optional[str] = Field( - None, description="Title of a book, part of which is being cited", title="Book title" + None, + description="Title of a book, part of which is being cited", + title="Book title", ) crossref: Optional[str] = Field( - None, description="The database key of the entry being cross referenced", title="Cross reference" + None, + description="The database key of the entry being cross referenced", + title="Cross reference", ) howpublished: Optional[str] = Field( None, - description=( - "The element is used to store the notice for unusual publications. The first word should be capitalized." - " For example, `WebPage`, or `Distributed at the local tourist office`" - ), + description="The element is used to store the notice for unusual publications. The first word should be capitalized. For example, `WebPage`, or `Distributed at the local tourist office`", title="Store the notice for unusual publications", ) key: Optional[str] = Field( None, - description=( - "A key is a field used for alphabetizing, cross referencing, and creating a label when the `author'" - " information is missing" - ), + description="A key is a field used for alphabetizing, cross referencing, and creating a label when the `author' information is missing", title="Key", ) organization: Optional[str] = Field( - None, description="The organization that sponsors a conference or that publishes a manual", title="Organization" + None, + description="The organization that sponsors a conference or that publishes a manual", + title="Organization", + ) + url: Optional[List[str]] = Field( + None, description="URL of the document, preferably a permanent URL", title="URL" + ) + translators: Optional[List[Translator]] = Field( + None, description="Translators", title="Translators" + ) + contributors: Optional[List[Contributor]] = Field( + None, description="Contributors", title="Contributors" ) - url: Optional[List[str]] = Field(None, description="URL of the document, preferably a permanent URL", title="URL") - translators: Optional[List[Translator]] = Field(None, description="Translators", title="Translators") - contributors: Optional[List[Contributor]] = Field(None, description="Contributors", title="Contributors") acknowledgement_statement: Optional[str] = Field( None, description="Acknowledgement statement", title="Acknowledgement statement" ) - contacts: Optional[List[Contact]] = Field(None, description="Contacts", title="Contacts") + contacts: Optional[List[Contact]] = Field( + None, description="Contacts", title="Contacts" + ) rights: Optional[str] = Field( - None, description="Information about rights held in and over the resource.", title="Rights" + None, + description="Information about rights held in and over the resource.", + title="Rights", ) copyright: Optional[str] = Field( None, - description=( - "Statement and identifier indicating the legal ownership and rights regarding use and re-use of all or part" - " of the resource." - ), + description="Statement and identifier indicating the legal ownership and rights regarding use and re-use of all or part of the resource.", title="Copyright", ) usage_terms: Optional[str] = Field( - None, description="Terms Governing Use and Reproduction", title="Terms governing use and reproduction" + None, + description="Terms Governing Use and Reproduction", + title="Terms governing use and reproduction", + ) + disclaimer: Optional[str] = Field( + None, description="Disclaimer", title="Disclaimer" ) - disclaimer: Optional[str] = Field(None, description="Disclaimer", title="Disclaimer") security_classification: Optional[str] = Field( None, - description=( - "Specifics pertaining to the security classification associated with the document, title, abstract," - " contents note, and/or the author. In addition, it can contain handling instructions and external" - " dissemination information pertaining to the dissemination of the document, title, abstract, contents" - " note, and author." - ), + description="Specifics pertaining to the security classification associated with the document, title, abstract, contents note, and/or the author. In addition, it can contain handling instructions and external dissemination information pertaining to the dissemination of the document, title, abstract, contents note, and author.", title="Security classification control", ) access_restrictions: Optional[str] = Field( @@ -494,21 +548,17 @@ class DocumentDescription(SchemaBaseModel): ) sources: Optional[List[Source]] = Field( None, - description=( - "Description of sources used. The element is nestable so that the sources statement might encompass a" - " series of discrete source statements, each of which could contain the facts about an individual source. " - ), + description="Description of sources used. The element is nestable so that the sources statement might encompass a series of discrete source statements, each of which could contain the facts about an individual source. ", title="Sources", ) data_sources: Optional[List[DataSource]] = Field( None, - description=( - "Used to list the book(s), article(s), serial(s), and/or machine-readable data file(s)--if any--that served" - " as the source(s) of the data collection." - ), + description="Used to list the book(s), article(s), serial(s), and/or machine-readable data file(s)--if any--that served as the source(s) of the data collection.", title="Data Sources", ) - keywords: Optional[List[KeywordItem]] = Field(None, description="Keywords", title="Keywords") + keywords: Optional[List[KeywordItem]] = Field( + None, description="Keywords", title="Keywords" + ) themes: Optional[List[Theme]] = Field(None, description="Themes") topics: Optional[List[Topic]] = Field( None, @@ -521,17 +571,23 @@ class DocumentDescription(SchemaBaseModel): title="Disciplines", ) audience: Optional[str] = Field( - None, description="A category of user for whom the resource is intended.", title="Audience" + None, + description="A category of user for whom the resource is intended.", + title="Audience", ) mandate: Optional[str] = Field( - None, description="A category of user for whom the resource is intended.", title="Audience" + None, + description="A category of user for whom the resource is intended.", + title="Audience", ) pricing: Optional[str] = Field( None, description="Current price of an item or the special export price of an item in any currency.", title="Pricing", ) - relations: Optional[List[Relation]] = Field(None, description="Related documents", title="Document relations") + relations: Optional[List[Relation]] = Field( + None, description="Related documents", title="Document relations" + ) reproducibility: Optional[Reproducibility] = Field(None, title="Reproducibility") @@ -539,11 +595,12 @@ class ScriptSchemaDraft(SchemaBaseModel): """ Schema for Document data type """ - __metadata_type__ = "document" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" - idno: Optional[str] = Field(None, description="Project unique identifier", title="Project unique identifier") + idno: Optional[str] = Field( + None, description="Project unique identifier", title="Project unique identifier" + ) metadata_information: Optional[MetadataInformation] = Field( None, description="Document description", title="Document metadata information" ) @@ -552,4 +609,6 @@ class ScriptSchemaDraft(SchemaBaseModel): ) provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") tags: Optional[List[Tag]] = Field(None, description="Tags", title="Tags") - additional: Optional[Dict[str, Any]] = Field(None, description="Additional metadata") + additional: Optional[Dict[str, Any]] = Field( + None, description="Additional metadata" + ) diff --git a/pydantic_schemas/generators/generate_excel_files.py b/pydantic_schemas/generators/generate_excel_files.py index 59fa9a3..a0f316b 100644 --- a/pydantic_schemas/generators/generate_excel_files.py +++ b/pydantic_schemas/generators/generate_excel_files.py @@ -16,9 +16,6 @@ def compare_excel_files(file1, file2): # Check if both workbooks have the same sheets if sheets1 != sheets2: - # print("Sheet names do not match") - # print(f"File1 sheets: {sheets1}") - # print(f"File2 sheets: {sheets2}") return False # Iterate through each sheet @@ -30,8 +27,6 @@ def compare_excel_files(file1, file2): for row in ws1.iter_rows(): for cell in row: cell_address = cell.coordinate - # if sheet_name == "metadata" and cell_address == "C1": - # continue # Skip comparison for cell C1 in 'metadata' sheet which only contains the versioning number differences = [] if ws1[cell_address].value != ws2[cell_address].value: @@ -62,9 +57,6 @@ def compare_excel_files(file1, file2): differences.append(f"Alignment: {ws1[cell_address].alignment} != {ws2[cell_address].alignment}") if differences: - # print(f"Differences found at {sheet_name} {cell_address}:") - # for difference in differences: - # print(f" - {difference}") return False return True diff --git a/pydantic_schemas/generators/generate_pydantic_schemas.py b/pydantic_schemas/generators/generate_pydantic_schemas.py index 4e9fdc5..5f935e1 100644 --- a/pydantic_schemas/generators/generate_pydantic_schemas.py +++ b/pydantic_schemas/generators/generate_pydantic_schemas.py @@ -1,4 +1,3 @@ -# import importlib.metadata import os import re from subprocess import run @@ -9,13 +8,12 @@ OUTPUT_DIR = os.path.join("pydantic_schemas") PYTHON_VERSION = "3.11" BASE_CLASS = ".utils.schema_base_model.SchemaBaseModel" -# __version__ = importlib.metadata.version("metadataschemas") if not os.path.exists(OUTPUT_DIR): os.makedirs(OUTPUT_DIR) -with open("json_to_python_config.yaml", "r") as file: +with open("json_to_python_config.yaml") as file: data = yaml.safe_load(file) # for json_file, (python_file, metadata_type, schema_class_name) in INPUTS_TO_OUTPUTS.items(): @@ -40,7 +38,7 @@ "--target-python-version", PYTHON_VERSION, "--use-double-quotes", - "--wrap-string-literal", + # "--wrap-string-literal", "--collapse-root-models", "--disable-timestamp", "--base-class", @@ -49,15 +47,19 @@ "pydantic_v2.BaseModel", "--output", output_path, - ] + ], + check=False, ) - with open(output_path, "r") as file: + with open(output_path) as file: content = file.read() updated_content = re.sub( f'class {model_name}\(SchemaBaseModel\):\n( """\n.*\n """)', # - lambda match: f"""class {model_name}(SchemaBaseModel):\n{match.group(1)}\n __metadata_type__ = "{section}"\n __metadata_type_version__ = "{version}" """, + lambda match, + model_name=model_name, + section=section, + version=version: f"""class {model_name}(SchemaBaseModel):\n{match.group(1)}\n __metadata_type__ = "{section}"\n __metadata_type_version__ = "{version}" """, content, ) diff --git a/pydantic_schemas/geospatial_schema.py b/pydantic_schemas/geospatial_schema.py index a9da30c..a41d260 100644 --- a/pydantic_schemas/geospatial_schema.py +++ b/pydantic_schemas/geospatial_schema.py @@ -26,14 +26,22 @@ class MetadataInformation(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) production_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version: Optional[str] = Field( - None, description="Identify and describe the current version of the document", title="Document version" + None, + description="Identify and describe the current version of the document", + title="Document version", ) @@ -44,17 +52,13 @@ class GeometricObject(SchemaBaseModel): geometricObjectType: Optional[str] = Field( None, - description=( - "Identification of the objects used to represent features in the vector spatial dataset. Codelist value" - " according to the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_GeometricObjectTypeCode)" - " GeometricObjectType codelist. Possible values: {`complex`, `composite`, `curve`, `point`, `solid`," - " `surface`}" - ), + description="Identification of the objects used to represent features in the vector spatial dataset. Codelist value according to the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_GeometricObjectTypeCode) GeometricObjectType codelist. Possible values: {`complex`, `composite`, `curve`, `point`, `solid`, `surface`}", title="Geometric Object Type", ) geometricObjectCount: Optional[int] = Field( - None, description="Number of geometric objects available for the resource", title="Geometric Object count" + None, + description="Number of geometric objects available for the resource", + title="Geometric Object count", ) @@ -65,12 +69,7 @@ class VectorSpatialRepresentation(SchemaBaseModel): topologyLevel: Optional[str] = Field( None, - description=( - "Topology level associated to the vector resource. Codelist value according to the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_TopologyLevelCode) TopologyLevel" - " codelist. Possible values: {`geometryOnly`, `topology1D`, `planarGraph`, `fullPlanarGraph`," - " `surfaceGraph`, `fullSurfaceGraph`, `topology3D`, `fullTopology3D`, `abstract`}" - ), + description="Topology level associated to the vector resource. Codelist value according to the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_TopologyLevelCode) TopologyLevel codelist. Possible values: {`geometryOnly`, `topology1D`, `planarGraph`, `fullPlanarGraph`, `surfaceGraph`, `fullSurfaceGraph`, `topology3D`, `fullTopology3D`, `abstract`}", title="Topology Level", ) geometricObjects: Optional[List[GeometricObject]] = Field( @@ -85,27 +84,25 @@ class Resolution(SchemaBaseModel): Resolution associated to the dimension. The resolution is handled as 'measure' which could be either a length, distance [special measure of length), angle or scale. """ - uom: Optional[str] = Field(None, description="Unit considered for the resolution measure", title="Unit Of Measure") + uom: Optional[str] = Field( + None, + description="Unit considered for the resolution measure", + title="Unit Of Measure", + ) class AxisDimensionProperty(SchemaBaseModel): dimensionName: Optional[str] = Field( None, - description=( - "name type of the dimension. Codelist value according to the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_DimensionNameTypeCode)" - " DimensionNameType codelist. Possible values: {`row`, `column`, `vertical`, `track`, `crossTrack`, `line`," - " `sample`, `time`}" - ), + description="name type of the dimension. Codelist value according to the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_DimensionNameTypeCode) DimensionNameType codelist. Possible values: {`row`, `column`, `vertical`, `track`, `crossTrack`, `line`, `sample`, `time`}", title="Dimension name type", ) - dimensionSize: Optional[int] = Field(None, description="Size of the dimension", title="Dimension size") + dimensionSize: Optional[int] = Field( + None, description="Size of the dimension", title="Dimension size" + ) resolution: Optional[Resolution] = Field( None, - description=( - "Resolution associated to the dimension. The resolution is handled as 'measure' which could be either a" - " length, distance [special measure of length), angle or scale." - ), + description="Resolution associated to the dimension. The resolution is handled as 'measure' which could be either a length, distance [special measure of length), angle or scale.", title="Dimension resolution", ) @@ -116,18 +113,18 @@ class GridSpatialRepresentation(SchemaBaseModel): """ numberOfDimensions: Optional[int] = Field( - None, description="Number of dimensions in the grid", title="Number of dimensions" + None, + description="Number of dimensions in the grid", + title="Number of dimensions", ) axisDimensionProperties: Optional[List[AxisDimensionProperty]] = Field( - None, description="Properties of the axis dimensions", title="Axis dimension properties" + None, + description="Properties of the axis dimensions", + title="Axis dimension properties", ) cellGeometry: Optional[str] = Field( None, - description=( - "Type of geometry used for the grid cells. Codelist value according to the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CellGeometryCode)" - " CellGeometryCode codelist. Possible values: {`point`, `area`, `voxel`, `stratum`}" - ), + description="Type of geometry used for the grid cells. Codelist value according to the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CellGeometryCode) CellGeometryCode codelist. Possible values: {`point`, `area`, `voxel`, `stratum`}", title="Cell geometry", ) transformationParameterAvailability: Optional[bool] = Field( @@ -140,19 +137,11 @@ class GridSpatialRepresentation(SchemaBaseModel): class SpatialRepresentationInfoItem(SchemaBaseModel): vectorSpatialRepresentation: Optional[VectorSpatialRepresentation] = Field( None, - description=( - "Vector Resource spatial representation - Spatial representation information for the dataset (resource)." - " Best practice is to include metadata for spatial representation if the described resource is a" - " georeferenced vector dataset." - ), + description="Vector Resource spatial representation - Spatial representation information for the dataset (resource). Best practice is to include metadata for spatial representation if the described resource is a georeferenced vector dataset.", ) gridSpatialRepresentation: Optional[GridSpatialRepresentation] = Field( None, - description=( - "Grid Resource spatial representation - Spatial representation information for the dataset (resource)." - " Best practice is to include metadata for spatial representation if the described resource is a" - " georeferenced gridded / raster dataset." - ), + description="Grid Resource spatial representation - Spatial representation information for the dataset (resource). Best practice is to include metadata for spatial representation if the described resource is a georeferenced gridded / raster dataset.", ) @@ -163,22 +152,15 @@ class AssociationType(SchemaBaseModel): codeListValue: Optional[str] = Field( None, - title=( - "Association type, eg. 'isComposedOf'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_AssociationTypeCode)" - " AssociationType codelist. Suggested values: {crossReference, largerWorkCitation, partOfSeamlessDatabase," - " source, stereoMate, isComposedOf, collectiveTitle, series, dependency, revisionOf}" - ), + title="Association type, eg. 'isComposedOf'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_AssociationTypeCode) AssociationType codelist. Suggested values: {crossReference, largerWorkCitation, partOfSeamlessDatabase, source, stereoMate, isComposedOf, collectiveTitle, series, dependency, revisionOf}", ) codeList: Optional[str] = Field( None, - title=( - "Codelist used for association types. Recommended URI:" - " http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_AssociationTypeCode" - ), + title="Codelist used for association types. Recommended URI: http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_AssociationTypeCode", ) codeSpace: Optional[str] = Field( - None, title="Codespace of the association types codelist. Recommended value: ISOTC211/19115" + None, + title="Codespace of the association types codelist. Recommended value: ISOTC211/19115", ) @@ -189,23 +171,15 @@ class InitiativeType(SchemaBaseModel): codeListValue: Optional[str] = Field( None, - title=( - "Initiative type, eg. 'collection'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_InitiativeTypeCode)" - " InitiativeType codelist. Suggested values: {campaign, collection, dataDictionary, exercise, experiment," - " investigation, mission, sensor, operation, platform, process, program, project, sciencePaper, study," - " task, trial, userGuide}" - ), + title="Initiative type, eg. 'collection'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_InitiativeTypeCode) InitiativeType codelist. Suggested values: {campaign, collection, dataDictionary, exercise, experiment, investigation, mission, sensor, operation, platform, process, program, project, sciencePaper, study, task, trial, userGuide}", ) codeList: Optional[str] = Field( None, - title=( - "Codelist used for initiative types. Recommended URI:" - " http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_InitiativeTypeCode" - ), + title="Codelist used for initiative types. Recommended URI: http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DS_InitiativeTypeCode", ) codeSpace: Optional[str] = Field( - None, title="Codespace of the initiative types codelist. Recommended value: ISOTC211/19115" + None, + title="Codespace of the initiative types codelist. Recommended value: ISOTC211/19115", ) @@ -214,23 +188,37 @@ class AggregationInfo(SchemaBaseModel): Identification of aggregate that encompasses the described resource, eg. data collection """ - aggregateDataSetName: Optional[str] = Field(None, title="Name of the Aggregate dataset") - aggregateDataSetIdentifier: Optional[str] = Field(None, title="Identifier of the Aggregate dataset") + aggregateDataSetName: Optional[str] = Field( + None, title="Name of the Aggregate dataset" + ) + aggregateDataSetIdentifier: Optional[str] = Field( + None, title="Identifier of the Aggregate dataset" + ) associationType: Optional[AssociationType] = Field( None, description="Type of association between the dataset resource and the aggregate Resource", title="Association type", ) initiativeType: Optional[InitiativeType] = Field( - None, description="Type of initative behind the aggregate Resource", title="Initiative type" + None, + description="Type of initative behind the aggregate Resource", + title="Initiative type", ) class GeographicBoundingBox(SchemaBaseModel): - westBoundLongitude: Optional[confloat(ge=-180.0, le=180.0)] = Field(None, title="West") - eastBoundLongitude: Optional[confloat(ge=-180.0, le=180.0)] = Field(None, title="East") - southBoundLatitude: Optional[confloat(ge=-180.0, le=180.0)] = Field(None, title="South") - northBoundLatitude: Optional[confloat(ge=-180.0, le=180.0)] = Field(None, title="North") + westBoundLongitude: Optional[confloat(ge=-180.0, le=180.0)] = Field( + None, title="West" + ) + eastBoundLongitude: Optional[confloat(ge=-180.0, le=180.0)] = Field( + None, title="East" + ) + southBoundLatitude: Optional[confloat(ge=-180.0, le=180.0)] = Field( + None, title="South" + ) + northBoundLatitude: Optional[confloat(ge=-180.0, le=180.0)] = Field( + None, title="North" + ) class Geohash(SchemaBaseModel): @@ -265,29 +253,29 @@ class GeographicBoundingPolygon(SchemaBaseModel): class GeographicElementItem(SchemaBaseModel): - geographicBoundingBox: Optional[GeographicBoundingBox] = Field(None, title="Geographic Bounding Box") + geographicBoundingBox: Optional[GeographicBoundingBox] = Field( + None, title="Geographic Bounding Box" + ) geohash: Optional[Geohash] = Field(None, title="Geohash") - geographicDescription: Optional[str] = Field(None, title="Geographic description identifier") + geographicDescription: Optional[str] = Field( + None, title="Geographic description identifier" + ) geographicBoundingPolygon: Optional[GeographicBoundingPolygon] = Field( - None, description="Geographic Bounding Polygon", title="Geographic Bounding Polygon" + None, + description="Geographic Bounding Polygon", + title="Geographic Bounding Polygon", ) class TemporalElementExtentItem(SchemaBaseModel): beginPosition: Optional[str] = Field( None, - description=( - "Begin time position. Requires an extended ISO 8601 formatted combined UTC date and time string" - " (2009-11-17T10:00:00)" - ), + description="Begin time position. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Begin time position", ) endPosition: Optional[str] = Field( None, - description=( - "End time position. Requires an extended ISO 8601 formatted combined UTC date and time string" - " (2009-11-17T10:00:00)" - ), + description="End time position. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="End time position", ) @@ -310,29 +298,40 @@ class Extent(SchemaBaseModel): geographicElement: Optional[List[GeographicElementItem]] = Field( None, description="Geographic extent(s)", title="Geographic extent(s)" ) - temporalElementExtent: Optional[List[TemporalElementExtentItem]] = Field(None, title="Temporal extent(s)") - verticalElement: Optional[List[VerticalElementItem]] = Field(None, title="Vertical extent(s)") + temporalElementExtent: Optional[List[TemporalElementExtentItem]] = Field( + None, title="Temporal extent(s)" + ) + verticalElement: Optional[List[VerticalElementItem]] = Field( + None, title="Vertical extent(s)" + ) class SpatialResolutionItem(SchemaBaseModel): - uom: Optional[str] = Field(None, description="Unit considered for the resolution measure", title="Unit Of Measure") + uom: Optional[str] = Field( + None, + description="Unit considered for the resolution measure", + title="Unit Of Measure", + ) value: Optional[float] = Field(None, description="Value", title="Value") class AccessProperties(SchemaBaseModel): - fees: Optional[str] = Field(None, description="Eventual fees associated with the service", title="Fees") + fees: Optional[str] = Field( + None, description="Eventual fees associated with the service", title="Fees" + ) plannedAvailableDateTime: Optional[str] = Field( None, - description=( - "Date and time when the metadata record was created or updated. Requires an extended ISO 8601 formatted" - " combined UTC date and time string (2009-11-17T10:00:00)" - ), + description="Date and time when the metadata record was created or updated. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Service availability Date Stamp", ) orderingInstructions: Optional[str] = Field( - None, description="Eventual instructions for the ordering", title="Ordering instructions" + None, + description="Eventual instructions for the ordering", + title="Ordering instructions", + ) + turnaround: Optional[str] = Field( + None, description="Turnaround", title="Turnaround" ) - turnaround: Optional[str] = Field(None, description="Turnaround", title="Turnaround") class CoupledResourceItem(SchemaBaseModel): @@ -347,21 +346,15 @@ class CouplingType(SchemaBaseModel): codeListValue: Optional[str] = Field( None, - title=( - "Coupling type, eg. 'loose'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#SV_CouplingTypeCode) CouplingType" - " codelist. Suggested values: {loose, mixed, tight}" - ), + title="Coupling type, eg. 'loose'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#SV_CouplingTypeCode) CouplingType codelist. Suggested values: {loose, mixed, tight}", ) codeList: Optional[str] = Field( None, - title=( - "Codelist used for coupling types. Recommended URI:" - " http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#SV_CouplingTypeCode" - ), + title="Codelist used for coupling types. Recommended URI: http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#SV_CouplingTypeCode", ) codeSpace: Optional[str] = Field( - None, title="Codespace of the coupling types codelist. Recommended value: ISOTC211/19119" + None, + title="Codespace of the coupling types codelist. Recommended value: ISOTC211/19119", ) @@ -370,7 +363,9 @@ class OperatesOnItem(SchemaBaseModel): Operates On relationship """ - uuidref: Optional[str] = Field(None, title="Unique dataset identifier within the same catalogue") + uuidref: Optional[str] = Field( + None, title="Unique dataset identifier within the same catalogue" + ) class ContentType(SchemaBaseModel): @@ -380,22 +375,15 @@ class ContentType(SchemaBaseModel): codeListValue: Optional[str] = Field( None, - title=( - "Type of coverage content, eg. 'image'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CoverageContentTypeCode) Coverage" - " content type codelist. Suggested values: {image, thematicClassification, physicalMeasurement," - " auxillaryInformation, qualityInformation, referenceInformation, modelResult, coordinate, auxilliaryData}" - ), + title="Type of coverage content, eg. 'image'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CoverageContentTypeCode) Coverage content type codelist. Suggested values: {image, thematicClassification, physicalMeasurement, auxillaryInformation, qualityInformation, referenceInformation, modelResult, coordinate, auxilliaryData}", ) codeList: Optional[str] = Field( None, - title=( - "Codelist used for coverage content types. Recommended URI:" - " http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CoverageContentTypeCode" - ), + title="Codelist used for coverage content types. Recommended URI: http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CoverageContentTypeCode", ) codeSpace: Optional[str] = Field( - None, title="Codespace of the coverage content types codelist. Recommended value: ISOTC211/19115" + None, + title="Codespace of the coverage content types codelist. Recommended value: ISOTC211/19115", ) @@ -420,67 +408,88 @@ class Cardinality(SchemaBaseModel): Definition of the member type cardinality """ - lower: Optional[int] = Field(None, description="Lower cardinality range value", title="Lower cardinality") - upper: Optional[int] = Field(None, description="Upper cardinality range value", title="Upper cardinality") + lower: Optional[int] = Field( + None, description="Lower cardinality range value", title="Lower cardinality" + ) + upper: Optional[int] = Field( + None, description="Upper cardinality range value", title="Upper cardinality" + ) class ListedValueItem(SchemaBaseModel): - label: Optional[str] = Field(None, description="a label for the value", title="Value label") - code: Optional[str] = Field(None, description="a code for the value", title="Value code") - definition: Optional[str] = Field(None, description="a definition for the value", title="Value definition") + label: Optional[str] = Field( + None, description="a label for the value", title="Value label" + ) + code: Optional[str] = Field( + None, description="a code for the value", title="Value code" + ) + definition: Optional[str] = Field( + None, description="a definition for the value", title="Value definition" + ) class CarrierOfCharacteristic(SchemaBaseModel): memberName: Optional[str] = Field( - None, description="Name of the property member of the feature type", title="Member name" + None, + description="Name of the property member of the feature type", + title="Member name", ) definition: Optional[str] = Field( - None, description="Definition of the property member of the feature type", title="Definition" + None, + description="Definition of the property member of the feature type", + title="Definition", ) cardinality: Optional[Cardinality] = Field( - None, description="Definition of the member type cardinality", title="Cardinality" + None, + description="Definition of the member type cardinality", + title="Cardinality", + ) + code: Optional[str] = Field( + None, + description="Code for the attribute member of the feature type", + title="Code", ) - code: Optional[str] = Field(None, description="Code for the attribute member of the feature type", title="Code") valueMeasurementUnit: Optional[str] = Field( - None, description="Measurement unit of the values (in case of variable)", title="Value measurement unit" + None, + description="Measurement unit of the values (in case of variable)", + title="Value measurement unit", ) valueType: Optional[str] = Field( None, - description=( - "Type of value. A good practice is to rely on primitive data types defined in the XML Schema" - " https://www.w3.org/2009/XMLSchema/XMLSchema.xsd" - ), + description="Type of value. A good practice is to rely on primitive data types defined in the XML Schema https://www.w3.org/2009/XMLSchema/XMLSchema.xsd", title="Value type", ) listedValue: Optional[List[ListedValueItem]] = Field( - None, description="List of controlled value(s) used in te attribute member", title="Listed value(s)" + None, + description="List of controlled value(s) used in te attribute member", + title="Listed value(s)", ) class FeatureTypeItem(SchemaBaseModel): typeName: Optional[str] = Field( None, - description=( - "text string that uniquely identifies this feature type within the feature catalogue that contains this" - " feature type" - ), + description="text string that uniquely identifies this feature type within the feature catalogue that contains this feature type", title="Type name", ) definition: Optional[str] = Field( - None, description="definition of the feature type in a natural language", title="Definition" + None, + description="definition of the feature type in a natural language", + title="Definition", ) code: Optional[str] = Field( None, - description=( - "code that uniquely identifies this feature type within the feature catalogue that contains this feature" - " type" - ), + description="code that uniquely identifies this feature type within the feature catalogue that contains this feature type", title="Code", ) isAbstract: Optional[bool] = Field( - None, description="indicates if the feature type is abstract or not", title="Is abstract" + None, + description="indicates if the feature type is abstract or not", + title="Is abstract", + ) + aliases: Optional[List[str]] = Field( + None, description="equivalent name(s) of this feature type", title="Alias(es)" ) - aliases: Optional[List[str]] = Field(None, description="equivalent name(s) of this feature type", title="Alias(es)") carrierOfCharacteristics: Optional[List[CarrierOfCharacteristic]] = Field( None, description="links this feature type to the property types that it contains", @@ -500,30 +509,12 @@ class ResourceSchema(SchemaBaseModel): dctype: Optional[str] = Field( "doc/oth", - description=( - "Document types for external resource e.g. `doc/adm` \n* `doc/adm` - Document, Administrative [doc/adm] \n*" - " `doc/anl` - Document, Analytical [doc/anl] \n* `doc/oth` - Document, Other [doc/oth] \n* `doc/qst` -" - " Document, Questionnaire [doc/qst] \n* `doc/ref` - Document, Reference [doc/ref] \n* `doc/rep` - Document," - " Report [doc/rep] \n* `doc/tec` - Document, Technical [doc/tec] \n* `aud` - Audio [aud]\n* `dat` -" - " Database [dat]\n* `map` - Map [map]\n* `dat/micro` - Microdata File [dat/micro]\n* `pic` - Photo [pic]\n*" - " `prg` - Program [prg]\n* `tbl` - Table [tbl]\n* `vid` - Video [vid] \n* `web` - Web Site [web]" - ), + description="Document types for external resource e.g. `doc/adm` \n* `doc/adm` - Document, Administrative [doc/adm] \n* `doc/anl` - Document, Analytical [doc/anl] \n* `doc/oth` - Document, Other [doc/oth] \n* `doc/qst` - Document, Questionnaire [doc/qst] \n* `doc/ref` - Document, Reference [doc/ref] \n* `doc/rep` - Document, Report [doc/rep] \n* `doc/tec` - Document, Technical [doc/tec] \n* `aud` - Audio [aud]\n* `dat` - Database [dat]\n* `map` - Map [map]\n* `dat/micro` - Microdata File [dat/micro]\n* `pic` - Photo [pic]\n* `prg` - Program [prg]\n* `tbl` - Table [tbl]\n* `vid` - Video [vid] \n* `web` - Web Site [web]", title="Resource type", ) dcformat: Optional[str] = Field( None, - description=( - "Document file format e.g. `application/zip` \n* `application/x-compressed` - Compressed, Generic \n*" - " `application/zip` - Compressed, ZIP \n* `application/x-cspro` - Data, CSPro \n* `application/dbase` -" - " Data, dBase \n* `application/msaccess` - Data, Microsoft Access \n* `application/x-sas` - Data, SAS " - " \n* `application/x-spss` - Data, SPSS \n* `application/x-stata` - Data, Stata \n* `text` - Document," - " Generic \n* `text/html` - Document, HTML \n* `application/msexcel` - Document, Microsoft Excel \n*" - " `application/mspowerpoint` - Document, Microsoft PowerPoint \n* `application/msword` - Document," - " Microsoft Word \n* `application/pdf` - Document, PDF \n* `application/postscript` - Document," - " Postscript \n* `text/plain` - Document, Plain \n* `text/wordperfect` - Document, WordPerfect \n*" - " `image/gif` - Image, GIF \n* `image/jpeg` - Image, JPEG \n* `image/png` - Image, PNG \n*" - " `image/tiff` - Image, TIFF" - ), + description="Document file format e.g. `application/zip` \n* `application/x-compressed` - Compressed, Generic \n* `application/zip` - Compressed, ZIP \n* `application/x-cspro` - Data, CSPro \n* `application/dbase` - Data, dBase \n* `application/msaccess` - Data, Microsoft Access \n* `application/x-sas` - Data, SAS \n* `application/x-spss` - Data, SPSS \n* `application/x-stata` - Data, Stata \n* `text` - Document, Generic \n* `text/html` - Document, HTML \n* `application/msexcel` - Document, Microsoft Excel \n* `application/mspowerpoint` - Document, Microsoft PowerPoint \n* `application/msword` - Document, Microsoft Word \n* `application/pdf` - Document, PDF \n* `application/postscript` - Document, Postscript \n* `text/plain` - Document, Plain \n* `text/wordperfect` - Document, WordPerfect \n* `image/gif` - Image, GIF \n* `image/jpeg` - Image, JPEG \n* `image/png` - Image, PNG \n* `image/tiff` - Image, TIFF", title="Resource Format", ) title: str = Field(..., description="Title") @@ -539,29 +530,33 @@ class ResourceSchema(SchemaBaseModel): toc: Optional[str] = Field(None, description="TOC") filename: Optional[str] = Field( None, - description=( - "Resource file name or URL. For uploading a file, use the field `file` in formData or use the `Upload file`" - " endpoint." - ), + description="Resource file name or URL. For uploading a file, use the field `file` in formData or use the `Upload file` endpoint.", ) class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -570,7 +565,9 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class CharacterSet(SchemaBaseModel): @@ -580,18 +577,11 @@ class CharacterSet(SchemaBaseModel): codeListValue: Optional[str] = Field( None, - title=( - "Character set code, e.g 'utf8'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CharacterSetCode) CharacterSet" - " codelist" - ), + title="Character set code, e.g 'utf8'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CharacterSetCode) CharacterSet codelist", ) codeList: Optional[str] = Field( None, - title=( - "Codelist used for character sets. Recommended URI:" - " http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CharacterSetCode" - ), + title="Codelist used for character sets. Recommended URI: http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_CharacterSetCode", ) @@ -600,14 +590,12 @@ class Date(SchemaBaseModel): Date """ - date: str = Field(..., description="Date in ISO 8601 format - YYYY-MM-DD", title="Date") + date: str = Field( + ..., description="Date in ISO 8601 format - YYYY-MM-DD", title="Date" + ) type: Optional[str] = Field( None, - description=( - "Date type e.g. `publication`, `revision`, `creation`, `expiry`, `lastUpdate`, `lastRevision`," - " `deprecated`. See full list at" - " [data.noaa.gov](https://data.noaa.gov/resources/iso19139/schema/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode)" - ), + description="Date type e.g. `publication`, `revision`, `creation`, `expiry`, `lastUpdate`, `lastRevision`, `deprecated`. See full list at [data.noaa.gov](https://data.noaa.gov/resources/iso19139/schema/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode)", title="Date type", ) @@ -621,9 +609,13 @@ class OnlineResource(SchemaBaseModel): name: Optional[str] = Field(None, title="Resource title") description: Optional[str] = Field(None, title="Resource description") protocol: Optional[str] = Field( - None, description="Protocol used to access the resource, eg HTTP, FTP", title="Protocol" + None, + description="Protocol used to access the resource, eg HTTP, FTP", + title="Protocol", + ) + function: Optional[str] = Field( + None, description="Function of the online resource", title="Function" ) - function: Optional[str] = Field(None, description="Function of the online resource", title="Function") class Phone(SchemaBaseModel): @@ -652,8 +644,12 @@ class ContactInfo(SchemaBaseModel): Information to contact the responsible party """ - phone: Optional[Phone] = Field(None, description="Phone contact information", title="Phone") - address: Optional[Address] = Field(None, description="Address contact information", title="Address") + phone: Optional[Phone] = Field( + None, description="Phone contact information", title="Phone" + ) + address: Optional[Address] = Field( + None, description="Address contact information", title="Address" + ) onlineResource: Optional[OnlineResource] = None @@ -662,30 +658,38 @@ class ResponsibleParty(SchemaBaseModel): Definition of a responsible party (individual or organization) """ - individualName: Optional[str] = Field(None, description="Name of the individual", title="Individual name") - organisationName: Optional[str] = Field(None, description="Name of the organization", title="Organization name") - positionName: Optional[str] = Field(None, description="Name of the individual position", title="Position name") + individualName: Optional[str] = Field( + None, description="Name of the individual", title="Individual name" + ) + organisationName: Optional[str] = Field( + None, description="Name of the organization", title="Organization name" + ) + positionName: Optional[str] = Field( + None, description="Name of the individual position", title="Position name" + ) contactInfo: Optional[ContactInfo] = Field( - None, description="Information to contact the responsible party", title="Contact info" + None, + description="Information to contact the responsible party", + title="Contact info", ) role: Optional[str] = Field( None, - description=( - "Role of the responsible party. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_RoleCode) Role codelist." - " Suggested values: {`resourceProvider`, `custodian`, `owner`, `sponsor`, `user`, `distributor`," - " `originator`, `pointOfContact`, `principalInvestigator`, `processor`, `publisher`, `author`, `coAuthor`," - " `collaborator`, `editor`, `mediator`, `rightsHolder`, `contributor`, `funder`, `stakeholder`}" - ), + description="Role of the responsible party. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_RoleCode) Role codelist. Suggested values: {`resourceProvider`, `custodian`, `owner`, `sponsor`, `user`, `distributor`, `originator`, `pointOfContact`, `principalInvestigator`, `processor`, `publisher`, `author`, `coAuthor`, `collaborator`, `editor`, `mediator`, `rightsHolder`, `contributor`, `funder`, `stakeholder`}", title="Role", ) class IdentifierItem(SchemaBaseModel): authority: Optional[str] = Field( - None, description="The authority that identifies uniquely the resource metadata", title="Authority" + None, + description="The authority that identifies uniquely the resource metadata", + title="Authority", + ) + code: Optional[Any] = Field( + None, + description="A code uniquely identifying the resource metadata", + title="Code", ) - code: Optional[Any] = Field(None, description="A code uniquely identifying the resource metadata", title="Code") class Series(SchemaBaseModel): @@ -693,10 +697,18 @@ class Series(SchemaBaseModel): Series citation """ - name: Optional[str] = Field(None, description="Name of the series in which the resource is cited", title="Name") - issueIdentification: Optional[str] = Field(None, description="Identification of the series issue", title="Issue") + name: Optional[str] = Field( + None, + description="Name of the series in which the resource is cited", + title="Name", + ) + issueIdentification: Optional[str] = Field( + None, description="Identification of the series issue", title="Issue" + ) page: Optional[str] = Field( - None, description="Identification of the series page in which the resource is cited", title="Page" + None, + description="Identification of the series page in which the resource is cited", + title="Page", ) @@ -706,39 +718,36 @@ class Citation(SchemaBaseModel): """ title: Optional[str] = Field(None, description="Resource title", title="Title") - alternateTitle: Optional[List[str]] = Field(None, description="Resource alternate title", title="Alternate Title") + alternateTitle: Optional[List[str]] = Field( + None, description="Resource alternate title", title="Alternate Title" + ) date: Optional[List[Date]] = Field( - None, description="Date(s) associated to the resource citation", title="Citation date(s)" + None, + description="Date(s) associated to the resource citation", + title="Citation date(s)", ) edition: Optional[str] = Field(None, description="Edition", title="Edition") editionDate: Optional[str] = Field( None, - description=( - "Date and time when the metadata record was created or updated. Requires an extended ISO 8601 formatted" - " combined UTC date and time string (2009-11-17T10:00:00)" - ), + description="Date and time when the metadata record was created or updated. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Edition Date", ) identifier: Optional[List[IdentifierItem]] = Field( None, description="Identifiers for the resource metadata", title="Identifier" ) citedResponsibleParty: Optional[List[ResponsibleParty]] = Field( - None, description="Responsible party(ies) to cite in the resource citation", title="Responsible party(ies)" + None, + description="Responsible party(ies) to cite in the resource citation", + title="Responsible party(ies)", ) presentationForm: Optional[List[Any]] = Field( None, - description=( - "The resource presentation form. e.g. 'mapDigital'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_PresentationFormCode)" - " PresentationForm codelist. Suggested values: {`documentDigital`, `imageDigital`, `documentHardcopy`," - " `imageHardcopy`, `mapDigital`, `mapHardcopy`, `modelDigital`, `modelHardcopy`, `profileDigital`," - " `profileHardcopy`, `tableDigital`, `tableHardcopy`, `videoDigital`, `videoHardcopy`, `audioDigital`," - " `audioHardcopy`, `multimediaDigital`, `multimediaHardcopy`, `physicalSample`, `diagramDigital`," - " `diagramHardcopy`}" - ), + description="The resource presentation form. e.g. 'mapDigital'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_PresentationFormCode) PresentationForm codelist. Suggested values: {`documentDigital`, `imageDigital`, `documentHardcopy`, `imageHardcopy`, `mapDigital`, `mapHardcopy`, `modelDigital`, `modelHardcopy`, `profileDigital`, `profileHardcopy`, `tableDigital`, `tableHardcopy`, `videoDigital`, `videoHardcopy`, `audioDigital`, `audioHardcopy`, `multimediaDigital`, `multimediaHardcopy`, `physicalSample`, `diagramDigital`, `diagramHardcopy`}", title="Presentation form", ) - series: Optional[Series] = Field(None, description="Series citation", title="Series") + series: Optional[Series] = Field( + None, description="Series citation", title="Series" + ) otherCitationDetails: Optional[str] = Field(None, title="Other Citation Details") collectiveTitle: Optional[str] = Field(None, title="Collective Title") ISBN: Optional[str] = Field(None, title="ISBN") @@ -750,13 +759,19 @@ class ReferenceSystem(SchemaBaseModel): Reference System """ - code: Optional[str] = Field(None, description="example - 5701", title="Reference System Identifier Code") - codeSpace: Optional[str] = Field(None, description="example - 'EPSG'", title="Code Space") + code: Optional[str] = Field( + None, description="example - 5701", title="Reference System Identifier Code" + ) + codeSpace: Optional[str] = Field( + None, description="example - 'EPSG'", title="Code Space" + ) class UpdateScopeItem(SchemaBaseModel): scope: Optional[str] = Field( - None, description="Scope of data to which maintenance is applied", title="Update Scope" + None, + description="Scope of data to which maintenance is applied", + title="Update Scope", ) description: Optional[str] = Field( None, @@ -772,27 +787,23 @@ class MaintenanceInfo(SchemaBaseModel): maintenanceAndUpdateFrequency: Optional[str] = Field( None, - description=( - "Frequency of maintenance/update of a resource. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_MaintenanceFrequencyCode)" - " MaintenanceFrequency codelist. Suggested values: {`continual`, `daily`, `weekly`, `fortnightly`," - " `monthly`, `quarterly`, `biannually`, `annually`, `asNeeded`, `irregular`, `notPlanned`, `unknown`}" - ), + description="Frequency of maintenance/update of a resource. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_MaintenanceFrequencyCode) MaintenanceFrequency codelist. Suggested values: {`continual`, `daily`, `weekly`, `fortnightly`, `monthly`, `quarterly`, `biannually`, `annually`, `asNeeded`, `irregular`, `notPlanned`, `unknown`}", title="Maintenance and Update Frequency", ) dateOfNextUpdate: Optional[str] = Field( None, - description=( - "Date of the next update of the resource. Requires an extended ISO 8601 formatted combined UTC date and" - " time string (2009-11-17T10:00:00)" - ), + description="Date of the next update of the resource. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Date of Next Update", ) userDefinedMaintenanceFrequency: Optional[str] = Field( - None, description="User defined maintenance frequency", title="User Defined Maintenance Frequency" + None, + description="User defined maintenance frequency", + title="User Defined Maintenance Frequency", ) updateScope: Optional[List[UpdateScopeItem]] = Field( - None, description="Scope of data to which maintenance is applied", title="Update Scope" + None, + description="Scope of data to which maintenance is applied", + title="Update Scope", ) maintenanceNote: Optional[List[str]] = Field( None, description="Note about the maintenance", title="Maintenance Note" @@ -819,11 +830,17 @@ class Format(SchemaBaseModel): name: Optional[str] = Field(None, title="Format name") version: Optional[str] = Field(None, title="Format version") - amendmentNumber: Optional[str] = Field(None, title="Format version amendment number") + amendmentNumber: Optional[str] = Field( + None, title="Format version amendment number" + ) specification: Optional[str] = Field(None, title="Format specification") - fileDecompressionTechnique: Optional[str] = Field(None, title="File decompression technique") + fileDecompressionTechnique: Optional[str] = Field( + None, title="File decompression technique" + ) FormatDistributor: Optional[ResponsibleParty] = Field( - None, description="Responsible party in charge of the format distribution", title="Distributor" + None, + description="Responsible party in charge of the format distribution", + title="Distributor", ) @@ -834,16 +851,14 @@ class Keywords(SchemaBaseModel): type: Optional[str] = Field( None, - description=( - "Type of keyword based on pre-defined code values. based on (but not limited to) code values listed in the" - " ISO 19115 \n {`dataCenter`, `discipline`, `place`, `dataResolution`," - " \n`stratum`,`temporal`,`theme`,`dataCentre`,`featureType`,`instrument`,`platform`,`process`,`project`,`service`,`product`,`subTopicCategory`}" - ), + description="Type of keyword based on pre-defined code values. based on (but not limited to) code values listed in the ISO 19115 \n {`dataCenter`, `discipline`, `place`, `dataResolution`, \n`stratum`,`temporal`,`theme`,`dataCentre`,`featureType`,`instrument`,`platform`,`process`,`project`,`service`,`product`,`subTopicCategory`}", title="Keyword type", ) keyword: str = Field(..., description="Keywords") thesaurusName: Optional[str] = Field( - None, description="Thesaurus to which keywords are associated", title="Thesaurus" + None, + description="Thesaurus to which keywords are associated", + title="Thesaurus", ) @@ -855,33 +870,17 @@ class LegalConstraints(SchemaBaseModel): useLimitation: Optional[List[str]] = None accessConstraints: Optional[List[str]] = Field( None, - description=( - "A restriction to access/use a resource. e.g. 'dataset'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_RestrictionCode) Restriction" - " codelist. Suggested values: {`copyright`, `patent`, `patentPending`, `trademark`, `license`," - " `intellectualPropertyRights`, `restricted`, `otherRestrictions`, `unrestricted`, `licenceUnrestricted`," - " `licenceEndUser`, `licenceDistributor`, `private`, `statutory`, `confidential`, `SBU`, `in-confidence`}" - ), + description="A restriction to access/use a resource. e.g. 'dataset'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_RestrictionCode) Restriction codelist. Suggested values: {`copyright`, `patent`, `patentPending`, `trademark`, `license`, `intellectualPropertyRights`, `restricted`, `otherRestrictions`, `unrestricted`, `licenceUnrestricted`, `licenceEndUser`, `licenceDistributor`, `private`, `statutory`, `confidential`, `SBU`, `in-confidence`}", title="Access constraints", ) useConstraints: Optional[List[str]] = Field( None, - description=( - "Legal constraints concerning the use of the resource, e.g. Terms of use statement, License. Recommended" - " code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_RestrictionCode) Restriction" - " codelist. Suggested values: {`copyright`, `patent`, `patentPending`, `trademark`, `license`," - " `intellectualPropertyRights`, `restricted`, `otherRestrictions`, `unrestricted`, `licenceUnrestricted`," - " `licenceEndUser`, `licenceDistributor`, `private`, `statutory`, `confidential`, `SBU`, `in-confidence`}" - ), + description="Legal constraints concerning the use of the resource, e.g. Terms of use statement, License. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_RestrictionCode) Restriction codelist. Suggested values: {`copyright`, `patent`, `patentPending`, `trademark`, `license`, `intellectualPropertyRights`, `restricted`, `otherRestrictions`, `unrestricted`, `licenceUnrestricted`, `licenceEndUser`, `licenceDistributor`, `private`, `statutory`, `confidential`, `SBU`, `in-confidence`}", title="Use constraints", ) otherConstraints: Optional[List[str]] = Field( None, - description=( - "Other legal constraints concerning the resource, e.g. additional information to complement the access/use" - " constraints, Disclaimer" - ), + description="Other legal constraints concerning the resource, e.g. additional information to complement the access/use constraints, Disclaimer", title="Other constraints", ) @@ -894,20 +893,13 @@ class SecurityConstraints(SchemaBaseModel): useLimitation: Optional[List[str]] = None classification: Optional[str] = Field( None, - description=( - "Security constraint classification , e.g. 'secret'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_ClassificationCode)" - " Classification codelist. Suggested values: {`unclassified`, `restricted`, `confidential`, `secret`," - " `topSecret`, `SBU`, `forOfficialUseOnly`, `protected`, `limitedDistribution`}" - ), + description="Security constraint classification , e.g. 'secret'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_ClassificationCode) Classification codelist. Suggested values: {`unclassified`, `restricted`, `confidential`, `secret`, `topSecret`, `SBU`, `forOfficialUseOnly`, `protected`, `limitedDistribution`}", title="Classification", ) userNote: Optional[str] = Field(None, title="User note") classificationSystem: Optional[str] = Field( None, - description=( - "A specific classification system, eg. Organization-specific system to classify resource confidentiality" - ), + description="A specific classification system, eg. Organization-specific system to classify resource confidentiality", title="Classification system", ) handlingDescription: Optional[str] = Field( @@ -923,10 +915,14 @@ class Constraints(SchemaBaseModel): """ legalConstraints: Optional[LegalConstraints] = Field( - None, description="Legal constraints associated to the resource", title="Legal constraints" + None, + description="Legal constraints associated to the resource", + title="Legal constraints", ) securityConstraints: Optional[SecurityConstraints] = Field( - None, description="Security constraints associated to the resource", title="Security constraints" + None, + description="Security constraints associated to the resource", + title="Security constraints", ) @@ -935,15 +931,25 @@ class Parameter(SchemaBaseModel): Service parameter """ - name: Optional[str] = Field(None, description="Service parameter name", title="Name") + name: Optional[str] = Field( + None, description="Service parameter name", title="Name" + ) direction: Optional[str] = Field( - None, description="Direction of the parameter. Suggested values: {in, out, inout}", title="Direction" + None, + description="Direction of the parameter. Suggested values: {in, out, inout}", + title="Direction", + ) + description: Optional[str] = Field( + None, description="Service parameter description", title="Description" ) - description: Optional[str] = Field(None, description="Service parameter description", title="Description") optionality: Optional[str] = Field( - None, description="Optionality, either 'Optional' or 'Mandatory' value", title="Optionality" + None, + description="Optionality, either 'Optional' or 'Mandatory' value", + title="Optionality", + ) + repeatability: Optional[bool] = Field( + None, description="Service parameter repeatability", title="Repeatability" ) - repeatability: Optional[bool] = Field(None, description="Service parameter repeatability", title="Repeatability") valueType: Optional[str] = Field(None, description="Value type", title="Value type") @@ -954,20 +960,15 @@ class DCPItem(SchemaBaseModel): codeListValue: Optional[str] = Field( None, - title=( - "DCP, eg. 'WebServices'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DCPList) DCP codelist. Suggested" - " values: {COM, CORBA, JAVA, SQL, WebServices, XML}" - ), + title="DCP, eg. 'WebServices'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DCPList) DCP codelist. Suggested values: {COM, CORBA, JAVA, SQL, WebServices, XML}", ) codeList: Optional[str] = Field( None, - title=( - "Codelist used for DCPs. Recommended URI:" - " http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DCPList" - ), + title="Codelist used for DCPs. Recommended URI: http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DCPList", + ) + codeSpace: Optional[str] = Field( + None, title="Codespace of the DCPs. Recommended value: ISOTC211/19119" ) - codeSpace: Optional[str] = Field(None, title="Codespace of the DCPs. Recommended value: ISOTC211/19119") class OperationMetadata(SchemaBaseModel): @@ -977,11 +978,15 @@ class OperationMetadata(SchemaBaseModel): operationName: Optional[str] = Field(None, title="Operation name") DCP: Optional[List[DCPItem]] = Field( - None, description="Distributed Computing Plateform(s). Recommended value: 'WebServices'", title="DCP(s)" + None, + description="Distributed Computing Plateform(s). Recommended value: 'WebServices'", + title="DCP(s)", ) operationDescription: Optional[str] = Field(None, title="Operation description") invocationName: Optional[str] = Field(None, title="Invocation name") - parameters: Optional[List[Parameter]] = Field(None, description="Operation parameters", title="Parameters") + parameters: Optional[List[Parameter]] = Field( + None, description="Operation parameters", title="Parameters" + ) connectPoint: Optional[OnlineResource] = Field(None, title="Connect Point(s)") dependsOn: Optional[List[OperationMetadata]] = Field( None, description="Depends on (other operation metadata)", title="Depends on" @@ -991,22 +996,20 @@ class OperationMetadata(SchemaBaseModel): class ResourceSpecificUsageItem(SchemaBaseModel): specificUsage: Optional[str] = Field( None, - description=( - "A description of a specific usage of this resource relevant to highlight, eg. use case of interest," - " success story, data paper" - ), + description="A description of a specific usage of this resource relevant to highlight, eg. use case of interest, success story, data paper", title="Specific usage description", ) usageDateTime: Optional[str] = Field( None, - description=( - "Date and time of the usage. Requires an extended ISO 8601 formatted combined UTC date and time string" - " (2009-11-17T10:00:00)" - ), + description="Date and time of the usage. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Metadata Date Stamp", ) - userDeterminedLimitations: Optional[str] = Field(None, title="User determined limitations") - userContactInfo: Optional[List[ResponsibleParty]] = Field(None, title="User contact(s)") + userDeterminedLimitations: Optional[str] = Field( + None, title="User determined limitations" + ) + userContactInfo: Optional[List[ResponsibleParty]] = Field( + None, title="User contact(s)" + ) class ServiceIdentification(SchemaBaseModel): @@ -1014,21 +1017,35 @@ class ServiceIdentification(SchemaBaseModel): Service identification """ - serviceType: Optional[str] = Field(None, description="Service type name", title="Service type") - serviceTypeVersion: Optional[str] = Field(None, description="Service type version", title="Service type version") - accessProperties: Optional[AccessProperties] = Field(None, title="Access properties") + serviceType: Optional[str] = Field( + None, description="Service type name", title="Service type" + ) + serviceTypeVersion: Optional[str] = Field( + None, description="Service type version", title="Service type version" + ) + accessProperties: Optional[AccessProperties] = Field( + None, title="Access properties" + ) restrictions: Optional[List[Constraints]] = Field( - None, description="Constraints associated to the service", title="Service constraints" + None, + description="Constraints associated to the service", + title="Service constraints", ) keywords: Optional[List[Keywords]] = Field( - None, description="Service keywords, organized by keyword type", title="Service keywords" + None, + description="Service keywords, organized by keyword type", + title="Service keywords", ) coupledResource: Optional[List[CoupledResourceItem]] = Field( None, description="Coupled resource(s)", title="Coupled resource(s)" ) - couplingType: Optional[CouplingType] = Field(None, description="Coupling type", title="Coupling type") + couplingType: Optional[CouplingType] = Field( + None, description="Coupling type", title="Coupling type" + ) containsOperations: Optional[List[OperationMetadata]] = Field( - None, description="Operation(s) contained in the service", title="Contained operation(s)" + None, + description="Operation(s) contained in the service", + title="Contained operation(s)", ) operatesOn: Optional[List[OperatesOnItem]] = Field( None, @@ -1042,39 +1059,55 @@ class IdentificationInfo(SchemaBaseModel): Identification(s) of the resource """ - citation: Optional[Citation] = Field(None, description="Dataset citation", title="Citation") - abstract: Optional[str] = Field(None, description="Abstract describing the dataset resource", title="Abstract") - purpose: Optional[str] = Field(None, description="Purpose of the dataset resource", title="Purpose") - credit: Optional[str] = Field(None, description="Credit associated to the dataset resource", title="Credit") + citation: Optional[Citation] = Field( + None, description="Dataset citation", title="Citation" + ) + abstract: Optional[str] = Field( + None, description="Abstract describing the dataset resource", title="Abstract" + ) + purpose: Optional[str] = Field( + None, description="Purpose of the dataset resource", title="Purpose" + ) + credit: Optional[str] = Field( + None, description="Credit associated to the dataset resource", title="Credit" + ) status: Optional[List[str]] = Field( None, - description=( - "Status of the dataset resource. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_ProgressCode) Progress codelist." - " Suggested values: {`completed`, `historicalArchive`, `obsolete`, `onGoing`, `planned`, `required`," - " `underDevelopment`, `final`, `pending`, `retired`, `superseded`, `tentative`, `valid`, `accepted`," - " `notAccepted`, `withdrawn`, `proposed`, `deprecated`}" - ), + description="Status of the dataset resource. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_ProgressCode) Progress codelist. Suggested values: {`completed`, `historicalArchive`, `obsolete`, `onGoing`, `planned`, `required`, `underDevelopment`, `final`, `pending`, `retired`, `superseded`, `tentative`, `valid`, `accepted`, `notAccepted`, `withdrawn`, `proposed`, `deprecated`}", title="Status", ) pointOfContact: Optional[List[ResponsibleParty]] = Field( - None, description="One or more points of contacts for the resource", title="Points of contact" + None, + description="One or more points of contacts for the resource", + title="Points of contact", ) resourceMaintenance: Optional[List[MaintenanceInfo]] = Field( - None, description="Information about the dataset resource maintenance", title="Resource maintenance" + None, + description="Information about the dataset resource maintenance", + title="Resource maintenance", ) graphicOverview: Optional[List[GraphicOverview]] = Field( - None, description="Graphic Overview(s) for the dataset resource", title="Graphic Overview(s)" + None, + description="Graphic Overview(s) for the dataset resource", + title="Graphic Overview(s)", + ) + resourceFormat: Optional[List[Format]] = Field( + None, description="Resource format(s)", title="Resource format(s)" ) - resourceFormat: Optional[List[Format]] = Field(None, description="Resource format(s)", title="Resource format(s)") descriptiveKeywords: Optional[List[Keywords]] = Field( - None, description="Descriptive keywords, organized by keyword type", title="Descriptive keywords" + None, + description="Descriptive keywords, organized by keyword type", + title="Descriptive keywords", ) resourceConstraints: Optional[List[Constraints]] = Field( - None, description="Constraints associated to the resource", title="Resource constraints" + None, + description="Constraints associated to the resource", + title="Resource constraints", ) resourceSpecificUsage: Optional[List[ResourceSpecificUsageItem]] = Field( - None, description="Resource specific usage(s) - if applicable", title="Resource specific usage(s)" + None, + description="Resource specific usage(s) - if applicable", + title="Resource specific usage(s)", ) aggregationInfo: Optional[AggregationInfo] = Field( None, @@ -1083,31 +1116,22 @@ class IdentificationInfo(SchemaBaseModel): ) extent: Optional[Extent] = Field( None, - description=( - "Defines the spatial (horizontal and vertical) and temporal region to which the content of the resource" - " applies." - ), + description="Defines the spatial (horizontal and vertical) and temporal region to which the content of the resource applies.", title="Extent of the resource", ) spatialRepresentationType: Optional[List[str]] = Field( None, - description=( - "Spatial representation type of the resource. e.g. 'vector'. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_SpatialRepresentationTypeCode)" - " SpatialRepresentationType codelist. Suggested values: {`vector`, `grid`, `textTable`, `tin`," - " `stereoModel`, `video`}" - ), + description="Spatial representation type of the resource. e.g. 'vector'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_SpatialRepresentationTypeCode) SpatialRepresentationType codelist. Suggested values: {`vector`, `grid`, `textTable`, `tin`, `stereoModel`, `video`}", title="Spatial Representation type", ) spatialResolution: Optional[List[SpatialResolutionItem]] = Field( - None, description="Spatial resolution of the resource", title="Spatial Resolution" + None, + description="Spatial resolution of the resource", + title="Spatial Resolution", ) language: Optional[List[str]] = Field( None, - description=( - "Resource language(s). Preferred code following the [ISO 639-2](http://www.loc.gov/standards/iso639-2/)" - " (alpha-3 code)" - ), + description="Resource language(s). Preferred code following the [ISO 639-2](http://www.loc.gov/standards/iso639-2/) (alpha-3 code)", title="Resource language(s)", ) characterSet: Optional[List[CharacterSet]] = Field( @@ -1115,18 +1139,13 @@ class IdentificationInfo(SchemaBaseModel): ) topicCategory: Optional[List[str]] = Field( None, - description=( - "Topic category of the resource. e.g. `owner`. Recommended code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_TopicCategoryCode) TopicCategory" - " codelist. Suggested values: {`farming`, `biota`, `boundaries`, `climatologyMeteorologyAtmosphere`," - " `economy`, `elevation`, `environment`, `geoscientificInformation`, `health`, `imageryBaseMapsEarthCover`," - " `intelligenceMilitary`, `inlandWaters`, `location`, `oceans`, `planningCadastre`, `society`, `structure`," - " `transportation`, `utilitiesCommunication`, `extraTerrestrial`, `disaster`}" - ), + description="Topic category of the resource. e.g. `owner`. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_TopicCategoryCode) TopicCategory codelist. Suggested values: {`farming`, `biota`, `boundaries`, `climatologyMeteorologyAtmosphere`, `economy`, `elevation`, `environment`, `geoscientificInformation`, `health`, `imageryBaseMapsEarthCover`, `intelligenceMilitary`, `inlandWaters`, `location`, `oceans`, `planningCadastre`, `society`, `structure`, `transportation`, `utilitiesCommunication`, `extraTerrestrial`, `disaster`}", title="Topic categories", ) supplementalInformation: Optional[str] = Field( - None, description="Additional information about the resource", title="Supplemental Information" + None, + description="Additional information about the resource", + title="Supplemental Information", ) serviceIdentification: Optional[ServiceIdentification] = Field( None, description="Service identification", title="Service identification" @@ -1149,16 +1168,15 @@ class FeatureCatalogueDescription(SchemaBaseModel): description="Indicates if the feature catalogue (ISO 19110) is included with the dataset?", title="Included with dataset", ) - featureCatalogueCitation: Optional[Citation] = Field(None, title="Feature Catalogue citation") + featureCatalogueCitation: Optional[Citation] = Field( + None, title="Feature Catalogue citation" + ) class ContentInfoItem(SchemaBaseModel): featureCatalogueDescription: Optional[FeatureCatalogueDescription] = Field( None, - description=( - "description of the feature catalogue (ISO 19110) associated to a vector resource, ie. the definition of" - " the vector data structure" - ), + description="description of the feature catalogue (ISO 19110) associated to a vector resource, ie. the definition of the vector data structure", title="Feature Catalogue Description", ) coverageDescription: Optional[CoverageDescription] = Field( @@ -1181,18 +1199,26 @@ class DistributionInfo(SchemaBaseModel): Distribution information """ - distributionFormat: Optional[List[Format]] = Field(None, title="Distribution format(s)") + distributionFormat: Optional[List[Format]] = Field( + None, title="Distribution format(s)" + ) distributor: Optional[List[ResponsibleParty]] = Field( - None, description="Responsible party(ies) in charge of the resource distribution", title="Distributor(s)" + None, + description="Responsible party(ies) in charge of the resource distribution", + title="Distributor(s)", ) transferOptions: Optional[TransferOptions] = Field( - None, description="Options of digital transfer available for the resource", title="Digital transfer options" + None, + description="Options of digital transfer available for the resource", + title="Digital transfer options", ) class ResultItem(SchemaBaseModel): specification: Optional[Citation] = Field( - None, description="The specification(s) of the data quality conformance result", title="Result specification" + None, + description="The specification(s) of the data quality conformance result", + title="Result specification", ) explanation: Optional[str] = Field( None, @@ -1212,38 +1238,43 @@ class Result(SchemaBaseModel): Result of conformance of the resource """ - nameOfMeasure: Optional[List[str]] = Field(None, description="Data quality measure names", title="Measures") + nameOfMeasure: Optional[List[str]] = Field( + None, description="Data quality measure names", title="Measures" + ) measureIdentification: Optional[str] = Field( - None, description="Unique identifier for the data quality measure", title="Measure identification" + None, + description="Unique identifier for the data quality measure", + title="Measure identification", ) measureDescription: Optional[str] = Field( - None, description="Description for the data quality measure", title="Measure description" + None, + description="Description for the data quality measure", + title="Measure description", ) evaluationMethodType: Optional[List[str]] = Field( None, - description=( - "The type of method to evaluate the data quality measure. e.g. 'indirect'. Recommended code following the" - " [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DQ_EvaluationMethodTypeCode)" - " TopicCategory codelist. Suggested values: {`directInternal`, `directExternal`, `indirect`}" - ), + description="The type of method to evaluate the data quality measure. e.g. 'indirect'. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#DQ_EvaluationMethodTypeCode) TopicCategory codelist. Suggested values: {`directInternal`, `directExternal`, `indirect`}", title="Evaluation method type", ) evaluationMethodDescription: Optional[str] = Field( - None, description="a description of the data quality evaluation method", title="Evaluation method description" + None, + description="a description of the data quality evaluation method", + title="Evaluation method description", ) evaluationProcedure: Optional[Citation] = Field( - None, description="Evaluation procedure description (as 'citation')", title="Evaluation procedure" + None, + description="Evaluation procedure description (as 'citation')", + title="Evaluation procedure", ) dateTime: Optional[str] = Field( None, - description=( - "Date and time when the data quality report has been established. Requires an extended ISO 8601 formatted" - " combined UTC date and time string (2009-11-17T10:00:00)" - ), + description="Date and time when the data quality report has been established. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Report Date Stamp", ) result: Optional[List[ResultItem]] = Field( - None, description="Result(s) of consistency associated to the data quality report", title="Result(s)" + None, + description="Result(s) of consistency associated to the data quality report", + title="Result(s)", ) @@ -1253,13 +1284,17 @@ class DQDomainConsistency(SchemaBaseModel): """ result: Optional[Result] = Field( - None, description="Result of conformance of the resource", title="Conformance Result" + None, + description="Result of conformance of the resource", + title="Conformance Result", ) class ReportItem(SchemaBaseModel): DQ_DomainConsistency: Optional[DQDomainConsistency] = Field( - None, description="Domain consistency report information", title="Data quality domain consistency" + None, + description="Domain consistency report information", + title="Data quality domain consistency", ) @@ -1270,22 +1305,29 @@ class SourceItem(SchemaBaseModel): class ProcessStepItem(SchemaBaseModel): description: Optional[str] = Field( - None, description="description of the process step", title="process step description" + None, + description="description of the process step", + title="process step description", + ) + rationale: Optional[str] = Field( + None, + description="rationale of the process step", + title="process step rationale", ) - rationale: Optional[str] = Field(None, description="rationale of the process step", title="process step rationale") dateTime: Optional[str] = Field( None, - description=( - "Date and time when the data quality report has been established. Requires an extended ISO 8601 formatted" - " combined UTC date and time string (2009-11-17T10:00:00)" - ), + description="Date and time when the data quality report has been established. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Date stamp", ) processor: Optional[List[ResponsibleParty]] = Field( - None, description="Responsible party(ies) in charge of the processing for the step", title="Processor(s)" + None, + description="Responsible party(ies) in charge of the processing for the step", + title="Processor(s)", ) source: Optional[List[SourceItem]] = Field( - None, description="Source(s) processed during the process step", title="Source(s)" + None, + description="Source(s) processed during the process step", + title="Source(s)", ) @@ -1300,26 +1342,22 @@ class Lineage(SchemaBaseModel): title="Lineage statement", ) processStep: Optional[List[ProcessStepItem]] = Field( - None, description="Description of the process steps required to obtain the resource", title="Process step(s)" + None, + description="Description of the process steps required to obtain the resource", + title="Process step(s)", ) class DataQualityInfoItem(SchemaBaseModel): scope: Optional[str] = Field( None, - description=( - "Scope(s), or 'hierarchy level(s)' applicable to the dataset description e.g. dataset, series. Recommended" - " code following the [ISO/TS" - " 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MX_ScopeCode) Scope codelist." - " Suggested values: `attribute`, `attributeType`, `collectionHardware`, `collectionSession`, `dataset`," - " `series`, `nonGeographicDataset`, `dimensionGroup`, `feature`, `featureType`, `propertyType`," - " `fieldSession`, `software`, `service`, `model`, `tile`, `initiative`, `stereomate`, `sensor`," - " `platformSeries`, `sensorSeries`, `productionSeries`, `transferAggregate`, `otherAggregate`" - ), + description="Scope(s), or 'hierarchy level(s)' applicable to the dataset description e.g. dataset, series. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MX_ScopeCode) Scope codelist. Suggested values: `attribute`, `attributeType`, `collectionHardware`, `collectionSession`, `dataset`, `series`, `nonGeographicDataset`, `dimensionGroup`, `feature`, `featureType`, `propertyType`, `fieldSession`, `software`, `service`, `model`, `tile`, `initiative`, `stereomate`, `sensor`, `platformSeries`, `sensorSeries`, `productionSeries`, `transferAggregate`, `otherAggregate`", title="Scope of the data quality information", ) report: Optional[List[ReportItem]] = Field( - None, description="Data quality report(s) associated to the resource", title="Data quality report(s)" + None, + description="Data quality report(s) associated to the resource", + title="Data quality report(s)", ) lineage: Optional[Lineage] = Field( None, @@ -1333,13 +1371,19 @@ class PortrayalCatalogueInfo(SchemaBaseModel): Information identifying the portrayal catalogue used by the resource """ - portrayalCatalogueCitation: Optional[List[Citation]] = Field(None, title="Citation for the portrayal catalogue") + portrayalCatalogueCitation: Optional[List[Citation]] = Field( + None, title="Citation for the portrayal catalogue" + ) class FeatureCatalogue(SchemaBaseModel): - name: Optional[str] = Field(None, description="Name of the feature catalogue", title="Name") + name: Optional[str] = Field( + None, description="Name of the feature catalogue", title="Name" + ) scope: Optional[List[str]] = Field( - None, description="Subject domain(s) of feature types defined in this feature catalogue", title="Scope(s)" + None, + description="Subject domain(s) of feature types defined in this feature catalogue", + title="Scope(s)", ) fieldOfApplication: Optional[List[str]] = Field( None, @@ -1348,56 +1392,49 @@ class FeatureCatalogue(SchemaBaseModel): ) versionNumber: Optional[str] = Field( None, - description=( - "version number of this feature catalogue, which may include both a major version number or letter and a" - " sequence of minor release numbers or letters, such as '3.2.4a.' The format of this attribute may differ" - " between cataloguing authorities." - ), + description="version number of this feature catalogue, which may include both a major version number or letter and a sequence of minor release numbers or letters, such as '3.2.4a.' The format of this attribute may differ between cataloguing authorities.", title="Version number", ) versionDate: Optional[Date] = None producer: Optional[ResponsibleParty] = Field( None, - description=( - "Name, address, country, and telecommunications address of person or organization having primary" - " responsibility for the intellectual content of this feature catalogue" - ), + description="Name, address, country, and telecommunications address of person or organization having primary responsibility for the intellectual content of this feature catalogue", title="Producer", ) functionalLanguage: Optional[str] = Field( None, - description=( - "Formal functional language in which the feature operation formal definition occurs in this feature" - " catalogue" - ), + description="Formal functional language in which the feature operation formal definition occurs in this feature catalogue", title="Functional language", ) featureType: Optional[List[FeatureTypeItem]] = Field( - None, description="Feature type(s) contained in the catalogue", title="Feature type(s)" + None, + description="Feature type(s) contained in the catalogue", + title="Feature type(s)", ) class Description(SchemaBaseModel): - idno: str = Field(..., description="Global unique persistent identifier", title="Unique Identifier") - language: Optional[str] = Field(None, description="Main metadata language", title="Language") + idno: str = Field( + ..., + description="Global unique persistent identifier", + title="Unique Identifier", + ) + language: Optional[str] = Field( + None, description="Main metadata language", title="Language" + ) characterSet: Optional[CharacterSet] = Field( - None, description="Metadata Character encoding used e.g. UTF-8", title="Character set" + None, + description="Metadata Character encoding used e.g. UTF-8", + title="Character set", ) parentIdentifier: Optional[str] = Field( None, - description=( - "Global unique persistent identifier of the parent record, eg. a data collection that includes several" - " datasets" - ), + description="Global unique persistent identifier of the parent record, eg. a data collection that includes several datasets", title="Unique parent identifier", ) hierarchyLevel: Optional[str] = Field( None, - description=( - "List of Scope(s), or 'hierarchy level(s)'. e.g. `dataset`, `service`. Recommended code following the" - " [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MX_ScopeCode) Scope" - " codelist. (string)" - ), + description="List of Scope(s), or 'hierarchy level(s)'. e.g. `dataset`, `service`. Recommended code following the [ISO/TS 19139](http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MX_ScopeCode) Scope codelist. (string)", title="Scope(s) / Hierarchy Level(s)", ) hierarchyLevelName: Optional[str] = Field( @@ -1410,10 +1447,7 @@ class Description(SchemaBaseModel): ) dateStamp: Optional[str] = Field( None, - description=( - "Date and time when the metadata record was created or updated. Requires an extended ISO 8601 formatted" - " combined UTC date and time string (2009-11-17T10:00:00)" - ), + description="Date and time when the metadata record was created or updated. Requires an extended ISO 8601 formatted combined UTC date and time string (2009-11-17T10:00:00)", title="Metadata Date Stamp", ) metadataStandardName: Optional[str] = Field( @@ -1423,28 +1457,26 @@ class Description(SchemaBaseModel): ) metadataStandardVersion: Optional[str] = Field( None, - description=( - "Version of the metadata standard used. Optional for ISO/TC211 standard if the metadata standard name" - " includes the inception year" - ), + description="Version of the metadata standard used. Optional for ISO/TC211 standard if the metadata standard name includes the inception year", title="Metadata standard version", ) dataSetURI: Optional[str] = Field( - None, description="A URI that uniquely identifies the dataset", title="Dataset URI" + None, + description="A URI that uniquely identifies the dataset", + title="Dataset URI", ) spatialRepresentationInfo: Optional[List[SpatialRepresentationInfoItem]] = Field( None, title="Resource Spatial Representation(s)" ) referenceSystemInfo: Optional[List[ReferenceSystem]] = Field( None, - description=( - "Resource's spatial reference systems - Description of the spatial and/or temporal reference systems used" - " in the dataset." - ), + description="Resource's spatial reference systems - Description of the spatial and/or temporal reference systems used in the dataset.", title="Resource Reference Systems", ) identificationInfo: Optional[IdentificationInfo] = Field( - None, description="Identification(s) of the resource", title="Identification Info(s)" + None, + description="Identification(s) of the resource", + title="Identification Info(s)", ) contentInfo: Optional[List[ContentInfoItem]] = Field( None, @@ -1458,7 +1490,9 @@ class Description(SchemaBaseModel): None, description="Data quality information", title="Data quality information" ) metadataMaintenance: Optional[MaintenanceInfo] = Field( - None, description="Metadata maintenance information", title="Metadata Maintenance information" + None, + description="Metadata maintenance information", + title="Metadata Maintenance information", ) portrayalCatalogueInfo: Optional[PortrayalCatalogueInfo] = Field( None, @@ -1470,18 +1504,21 @@ class Description(SchemaBaseModel): thesaurusInfo: Optional[List[Citation]] = Field( None, description="Thesaurus referenced by keywords", title="Thesaurus" ) - feature_catalogue: Optional[FeatureCatalogue] = Field(None, title="Feature catalogue") + feature_catalogue: Optional[FeatureCatalogue] = Field( + None, title="Feature catalogue" + ) class GeospatialSchema(SchemaBaseModel): """ Geospatial draft schema """ - __metadata_type__ = "geospatial" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" - idno: Optional[str] = Field(None, description="Project unique identifier", title="Project unique identifier") + idno: Optional[str] = Field( + None, description="Project unique identifier", title="Project unique identifier" + ) metadata_information: Optional[MetadataInformation] = Field( None, description="Document description", title="Document metadata information" ) @@ -1508,7 +1545,9 @@ class Locale(SchemaBaseModel): Locale definition for multi-lingual description """ - id: Optional[str] = Field(None, description="Locale code, eg. FR, EN", title="Locale code") + id: Optional[str] = Field( + None, description="Locale code, eg. FR, EN", title="Locale code" + ) languageCode: Optional[str] = Field(None, description="Language", title="Language") characterEncoding: Optional[CharacterEncoding] = Field( None, description="Character encoding used e.g. UTF-8", title="Character set" diff --git a/pydantic_schemas/image_schema.py b/pydantic_schemas/image_schema.py index c7ddb01..7f3e963 100644 --- a/pydantic_schemas/image_schema.py +++ b/pydantic_schemas/image_schema.py @@ -35,20 +35,30 @@ class MetadataInformation(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) production_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version: Optional[str] = Field( - None, description="Identify and describe the current version of the document", title="Document version" + None, + description="Identify and describe the current version of the document", + title="Document version", ) class Identifier(SchemaBaseModel): type: Optional[str] = Field( - None, description="Type of identifier e.g. `doi`, `handle`, `other`", title="Identifier type" + None, + description="Type of identifier e.g. `doi`, `handle`, `other`", + title="Identifier type", ) identifier: str = Field(..., title="Identifier") @@ -71,15 +81,23 @@ class Tag(SchemaBaseModel): class SceneCodesLabelledItem(SchemaBaseModel): - code: Optional[str] = Field(None, description="Scene code as a string of 6 digits", title="Scene Code") + code: Optional[str] = Field( + None, description="Scene code as a string of 6 digits", title="Scene Code" + ) label: Optional[str] = Field(None, description="Label", title="Scene Label") - description: Optional[str] = Field(None, description="Description of the scene", title="Scene Description") + description: Optional[str] = Field( + None, description="Description of the scene", title="Scene Description" + ) class SubjectCodesLabelledItem(SchemaBaseModel): - code: Optional[str] = Field(None, description="Subject code as a string of 8 digits", title="Subject Code") + code: Optional[str] = Field( + None, description="Subject code as a string of 8 digits", title="Subject Code" + ) label: Optional[str] = Field(None, description="Label", title="Subject Label") - description: Optional[str] = Field(None, description="Description of the scene", title="Subject Description") + description: Optional[str] = Field( + None, description="Description of the scene", title="Subject Description" + ) class Delimitertype(Enum): @@ -116,18 +134,12 @@ class ArtworkOrObject(SchemaBaseModel): ) physicalDescription: Optional[str] = Field( None, - description=( - "A textual description of the physical characteristics of the artwork or object, without reference to the" - " content depicted." - ), + description="A textual description of the physical characteristics of the artwork or object, without reference to the content depicted.", title="Physical Description {Artwork or Object detail}", ) creatorNames: Optional[List[str]] = Field( None, - description=( - "Contains the name of the artist who has created artwork or an object in the image. In cases where the" - " artist could or should not be identified the name of a company or organisation may be appropriate." - ), + description="Contains the name of the artist who has created artwork or an object in the image. In cases where the artist could or should not be identified the name of a company or organisation may be appropriate.", title="Creator {Artwork or Object detail}", ) creatorIdentifiers: Optional[List[str]] = Field( @@ -142,42 +154,27 @@ class ArtworkOrObject(SchemaBaseModel): ) stylePeriod: Optional[List[str]] = Field( None, - description=( - "The style, historical or artistic period, movement, group, or school whose characteristics are represented" - " in the artwork or object." - ), + description="The style, historical or artistic period, movement, group, or school whose characteristics are represented in the artwork or object.", title="Style Period {Artwork or Object detail}", ) dateCreated: Optional[AwareDatetime] = Field( None, - description=( - "Designates the date and optionally the time the artwork or object in the image was created. This relates" - " to artwork or objects with associated intellectual property rights." - ), + description="Designates the date and optionally the time the artwork or object in the image was created. This relates to artwork or objects with associated intellectual property rights.", title="Date Created {Artwork or Object detail}", ) circaDateCreated: Optional[str] = Field( None, - description=( - "Approximate date or range of dates associated with the creation and production of an artwork or object or" - " its components." - ), + description="Approximate date or range of dates associated with the creation and production of an artwork or object or its components.", title="Circa Date Created {Artwork or Object detail}", ) source: Optional[str] = Field( None, - description=( - "The organisation or body holding and registering the artwork or object in the image for inventory" - " purposes." - ), + description="The organisation or body holding and registering the artwork or object in the image for inventory purposes.", title="Source {Artwork or Object detail}", ) sourceInventoryNr: Optional[str] = Field( None, - description=( - "The inventory number issued by the organisation or body holding and registering the artwork or object in" - " the image." - ), + description="The inventory number issued by the organisation or body holding and registering the artwork or object in the image.", title="Source Inventory Number {Artwork or Object detail}", ) sourceInventoryUrl: Optional[AnyUrl] = Field( @@ -197,11 +194,7 @@ class ArtworkOrObject(SchemaBaseModel): ) copyrightNotice: Optional[str] = Field( None, - description=( - "Contains any necessary copyright notice for claiming the intellectual property for artwork or an object in" - " the image and should identify the current owner of the copyright of this work with associated" - " intellectual property rights." - ), + description="Contains any necessary copyright notice for claiming the intellectual property for artwork or an object in the image and should identify the current owner of the copyright of this work with associated intellectual property rights.", title="Copyright Notice {Artwork or Object detail}", ) currentLicensorName: Optional[str] = Field( @@ -221,10 +214,14 @@ class CreatorContactInfo(SchemaBaseModel): extra="forbid", ) country: Optional[str] = Field( - None, description="The contact information country part.", title="Country {contact info detail}" + None, + description="The contact information country part.", + title="Country {contact info detail}", ) emailwork: Optional[str] = Field( - None, description="The contact information email address part.", title="Email address(es) {contact info detail}" + None, + description="The contact information email address part.", + title="Email address(es) {contact info detail}", ) region: Optional[str] = Field( None, @@ -232,27 +229,24 @@ class CreatorContactInfo(SchemaBaseModel): title="State/Province {contact info detail}", ) phonework: Optional[str] = Field( - None, description="The contact information phone number part.", title="Phone number(s) {contact info detail}" + None, + description="The contact information phone number part.", + title="Phone number(s) {contact info detail}", ) weburlwork: Optional[str] = Field( None, - description=( - "The contact information web address part. Multiple addresses can be given. May have to be separated by a" - " comma in the user interface." - ), + description="The contact information web address part. Multiple addresses can be given. May have to be separated by a comma in the user interface.", title="Web URL(s) {contact info detail}", ) address: Optional[str] = Field( None, - description=( - "The contact information address part. Comprises an optional company name and all required information to" - " locate the building or postbox to which mail should be sent. To that end, the address is a multiline" - " field." - ), + description="The contact information address part. Comprises an optional company name and all required information to locate the building or postbox to which mail should be sent. To that end, the address is a multiline field.", title="Address {contact info detail}", ) city: Optional[str] = Field( - None, description="The contact information city part.", title="City {contact info detail}" + None, + description="The contact information city part.", + title="City {contact info detail}", ) postalCode: Optional[str] = Field( None, @@ -291,13 +285,20 @@ class Device(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - manufacturer: Optional[str] = Field(None, description="Name of the manufacturer of the device") + manufacturer: Optional[str] = Field( + None, description="Name of the manufacturer of the device" + ) modelName: Optional[str] = Field(None, description="Name of the device model") - serialNumber: Optional[str] = Field(None, description="Serial number, assigned by manufacturer") + serialNumber: Optional[str] = Field( + None, description="Serial number, assigned by manufacturer" + ) attLensDescription: Optional[str] = Field( - None, description="Short description of the lens used with the device at the time of the recording" + None, + description="Short description of the lens used with the device at the time of the recording", + ) + ownerDeviceId: Optional[str] = Field( + None, description="Identifier assigned by the owner of the device" ) - ownerDeviceId: Optional[str] = Field(None, description="Identifier assigned by the owner of the device") class EmbdEncRightsExpr(SchemaBaseModel): @@ -306,9 +307,7 @@ class EmbdEncRightsExpr(SchemaBaseModel): ) encRightsExpr: str = Field( ..., - description=( - "Embedded serialized rights expression using a rights expression language which is encoded as a string." - ), + description="Embedded serialized rights expression using a rights expression language which is encoded as a string.", title="Encoded Rights Expression", ) rightsExprEncType: str = Field( @@ -327,9 +326,13 @@ class Entity(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - name: Optional[str] = Field(None, description="Full name of the entity/concept", title="Name") + name: Optional[str] = Field( + None, description="Full name of the entity/concept", title="Name" + ) identifiers: Optional[List[AnyUrl]] = Field( - None, description="Globally unique identifier of the entity/concept", title="Identifier" + None, + description="Globally unique identifier of the entity/concept", + title="Identifier", ) @@ -337,12 +340,18 @@ class EntityWRole(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - name: Optional[str] = Field(None, description="Full name of the entity/concept", title="Name") + name: Optional[str] = Field( + None, description="Full name of the entity/concept", title="Name" + ) role: Optional[List[AnyUrl]] = Field( - None, description="Identifier of the role the entity has in the context of the metadata property", title="Role" + None, + description="Identifier of the role the entity has in the context of the metadata property", + title="Role", ) identifiers: Optional[List[AnyUrl]] = Field( - None, description="Globally unique identifier of the entity/concept", title="Identifier" + None, + description="Globally unique identifier of the entity/concept", + title="Identifier", ) @@ -350,19 +359,29 @@ class EpisodeSeason(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - name: Optional[str] = Field(None, description="Name of the episode or season of a series", title="Name") + name: Optional[str] = Field( + None, description="Name of the episode or season of a series", title="Name" + ) identifier: Optional[AnyUrl] = Field( - None, description="Identifier of the episode or season of a series", title="Identifier" + None, + description="Identifier of the episode or season of a series", + title="Identifier", + ) + number: Optional[float] = Field( + None, description="Number of the episode or season of a series", title="Number" ) - number: Optional[float] = Field(None, description="Number of the episode or season of a series", title="Number") class FrameSize(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - heightPixels: Optional[int] = Field(None, description="Height of the video frame in pixels", title="Height") - widthPixels: Optional[int] = Field(None, description="Width of the video frame in pixels", title="Width") + heightPixels: Optional[int] = Field( + None, description="Height of the video frame in pixels", title="Height" + ) + widthPixels: Optional[int] = Field( + None, description="Width of the video frame in pixels", title="Width" + ) class LinkedEncRightsExpr(SchemaBaseModel): @@ -390,34 +409,58 @@ class Location(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - name: Optional[str] = Field(None, description="Full name of the location", title="Name") + name: Optional[str] = Field( + None, description="Full name of the location", title="Name" + ) identifiers: Optional[List[AnyUrl]] = Field( - None, description="Globally unique identifier of the location", title="Identifier" + None, + description="Globally unique identifier of the location", + title="Identifier", ) worldRegion: Optional[str] = Field( - None, description="Name of the world region the Location is located in", title="World region name" + None, + description="Name of the world region the Location is located in", + title="World region name", ) countryName: Optional[str] = Field( - None, description="Name of the country the Location is located in", title="Country name" + None, + description="Name of the country the Location is located in", + title="Country name", ) countryCode: Optional[str] = Field( - None, description="ISO code of the country the Location is located in", title="Country ISO code" + None, + description="ISO code of the country the Location is located in", + title="Country ISO code", ) provinceState: Optional[str] = Field( - None, description="Name of the state or province the Location is located in", title="State/Province name" + None, + description="Name of the state or province the Location is located in", + title="State/Province name", + ) + city: Optional[str] = Field( + None, + description="Name of the city the Location is located in", + title="City name", ) - city: Optional[str] = Field(None, description="Name of the city the Location is located in", title="City name") sublocation: Optional[str] = Field( - None, description="Name of a sub location the Location is located in", title="Sublocation name" + None, + description="Name of a sub location the Location is located in", + title="Sublocation name", ) gpsAltitude: Optional[float] = Field( - None, description="Altitude in meters of a WGS84 based position of this Location", title="GPS-Altitude" + None, + description="Altitude in meters of a WGS84 based position of this Location", + title="GPS-Altitude", ) gpsLatitude: Optional[float] = Field( - None, description="Lattitude of a WGS84 based position of this Location", title="GPS-Lattitude" + None, + description="Lattitude of a WGS84 based position of this Location", + title="GPS-Lattitude", ) gpsLongitude: Optional[float] = Field( - None, description="Longitude of a WGS84 based position of this Location", title="GPS-Longitude" + None, + description="Longitude of a WGS84 based position of this Location", + title="GPS-Longitude", ) @@ -426,7 +469,9 @@ class PersonWDetails(SchemaBaseModel): extra="forbid", ) name: Optional[str] = Field(None, description="Name of the person", title="Name") - description: Optional[str] = Field(None, description="A textual description of the person", title="Description") + description: Optional[str] = Field( + None, description="A textual description of the person", title="Description" + ) identifiers: Optional[List[AnyUrl]] = Field( None, description="Globally unique identifier of the person", title="Identifier" ) @@ -440,14 +485,18 @@ class Product(SchemaBaseModel): extra="forbid", ) description: Optional[str] = Field( - None, description="A textual description of the product.", title="Description {Product detail}" + None, + description="A textual description of the product.", + title="Description {Product detail}", ) gtin: str = Field( ..., description="A 14 digit GTIN (Global Trade Item Number) of the product (GTIN-8 to GTIN-14 codes are used).", title="GTIN {Product detail}", ) - name: Optional[str] = Field(None, description="Name of the product.", title="Name {Product detail}") + name: Optional[str] = Field( + None, description="Name of the product.", title="Name {Product detail}" + ) class ProductWGtin(SchemaBaseModel): @@ -460,7 +509,9 @@ class ProductWGtin(SchemaBaseModel): description="A 14 digit GTIN (Global Trade Item Number) of the product (GTIN-8 to GTIN-14 codes are used).", title="GTIN", ) - description: Optional[str] = Field(None, description="A textual description of the product.", title="Description") + description: Optional[str] = Field( + None, description="A textual description of the product.", title="Description" + ) class PublicationEvent(SchemaBaseModel): @@ -468,13 +519,19 @@ class PublicationEvent(SchemaBaseModel): extra="forbid", ) date: AwareDatetime = Field( - ..., description="Date and optionally the time of publishing the video", title="Publication Date" + ..., + description="Date and optionally the time of publishing the video", + title="Publication Date", ) name: Optional[str] = Field( - None, description="Name of the event for publishing this video.", title="Publication Event Name" + None, + description="Name of the event for publishing this video.", + title="Publication Event Name", ) identifier: Optional[AnyUrl] = Field( - None, description="Identifier of the event for publishing this video", title="Publication Event Identifier" + None, + description="Identifier of the event for publishing this video", + title="Publication Event Identifier", ) @@ -483,7 +540,9 @@ class QualifiedLink(SchemaBaseModel): extra="forbid", ) link: Optional[AnyUrl] = Field(None, description="URL of the link", title="Link") - linkQualifier: Optional[AnyUrl] = Field(None, description="Term qualifying the use of the link", title="Qualifier") + linkQualifier: Optional[AnyUrl] = Field( + None, description="Term qualifying the use of the link", title="Qualifier" + ) class Rating(SchemaBaseModel): @@ -492,23 +551,28 @@ class Rating(SchemaBaseModel): ) ratingSourceLink: AnyUrl = Field( ..., - description=( - "Link to the site and optionally the page of the party which has issued the rating value, linked resource" - " should explain the rating rules." - ), + description="Link to the site and optionally the page of the party which has issued the rating value, linked resource should explain the rating rules.", title="Rating Source Link", ) - ratingValue: str = Field(..., description="Rating value as issued by the rating source", title="Rating Value") + ratingValue: str = Field( + ..., + description="Rating value as issued by the rating source", + title="Rating Value", + ) ratingScaleMinValue: Optional[str] = Field( None, description="The value of the rating scale used for the lowest/worst rating", title="Rating Scale Min Value", ) ratingRegions: Optional[List[Location]] = Field( - None, description="Geopolitical region to which this rating applies.", title="Rating Region" + None, + description="Geopolitical region to which this rating applies.", + title="Rating Region", ) ratingValueLogoLink: Optional[AnyUrl] = Field( - None, description="Visualisation of the rating value referenced by a link", title="Rating Value Logo" + None, + description="Visualisation of the rating value referenced by a link", + title="Rating Value Logo", ) ratingScaleMaxValue: Optional[str] = Field( None, @@ -540,14 +604,20 @@ class RegionWDelimiter(SchemaBaseModel): title="Rectangle, upper left Y", ) measureType: Optional[MeasureType] = Field( - None, description="How the measures of the rectangle are expressed", title="Measure Type" + None, + description="How the measures of the rectangle are expressed", + title="Measure Type", ) regionAreaHeight: Optional[float] = Field( - None, description="Vertical height of the rectangle", title="Rectangle, vertical size" + None, + description="Vertical height of the rectangle", + title="Rectangle, vertical size", ) regionText: str = Field(..., description="Text or textual data", title="Text") regionAreaWidth: Optional[float] = Field( - None, description="Horizontal width of the rectangle", title="Rectangle, horizontal size" + None, + description="Horizontal width of the rectangle", + title="Rectangle, horizontal size", ) @@ -556,10 +626,14 @@ class RegistryEntry(SchemaBaseModel): extra="forbid", ) role: Optional[AnyUrl] = Field( - None, description="An identifier of the reason and/or purpose for this Registry Entry.", title="Role" + None, + description="An identifier of the reason and/or purpose for this Registry Entry.", + title="Role", ) assetIdentifier: str = Field( - ..., description="Unique identifier of the video as issued by a registry", title="Asset Identifier" + ..., + description="Unique identifier of the video as issued by a registry", + title="Asset Identifier", ) registryIdentifier: AnyUrl = Field( ..., @@ -572,8 +646,12 @@ class Series(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - name: Optional[str] = Field(None, description="Name of the series", title="Series name") - identifier: Optional[AnyUrl] = Field(None, description="Identifier for the series", title="Series identifier") + name: Optional[str] = Field( + None, description="Name of the series", title="Series name" + ) + identifier: Optional[AnyUrl] = Field( + None, description="Identifier for the series", title="Series identifier" + ) class TemporalCoverage(SchemaBaseModel): @@ -581,10 +659,14 @@ class TemporalCoverage(SchemaBaseModel): extra="forbid", ) tempCoverageFrom: Optional[AwareDatetime] = Field( - None, description="Optionally truncated date when the temporal coverage starts", title="From Date" + None, + description="Optionally truncated date when the temporal coverage starts", + title="From Date", ) tempCoverageTo: Optional[AwareDatetime] = Field( - None, description="Optionally truncated date when the temporal coverage ends", title="To Date" + None, + description="Optionally truncated date when the temporal coverage ends", + title="To Date", ) @@ -606,10 +688,7 @@ class VideoTime(SchemaBaseModel): ) timeValue: str = Field( ..., - description=( - "Formated string including hours, minutes, seconds, fractions of seconds or frames, depending on the Time" - " Format" - ), + description="Formated string including hours, minutes, seconds, fractions of seconds or frames, depending on the Time Format", title="Time Value", ) timeFormat: TimeFormat = Field( @@ -634,10 +713,14 @@ class Topic(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Topic") parent_id: Optional[str] = Field( - None, description="For subtopics, provide the ID of the parent topic", title="Parent topic Identifier" + None, + description="For subtopics, provide the ID of the parent topic", + title="Parent topic Identifier", ) vocabulary: Optional[str] = Field( - None, description="Name of the controlled vocabulary, if the topic is from a taxonomy.", title="Vocabulary" + None, + description="Name of the controlled vocabulary, if the topic is from a taxonomy.", + title="Vocabulary", ) uri: Optional[str] = Field( None, @@ -689,7 +772,9 @@ class Type(Enum): class Relation(SchemaBaseModel): name: Optional[str] = Field(None, title="Name") type: Optional[Type] = Field(None, title="Type") - uri: Optional[str] = Field(None, description="Link to related resource", title="URI") + uri: Optional[str] = Field( + None, description="Link to related resource", title="URI" + ) class DcmiSchema(SchemaBaseModel): @@ -697,58 +782,82 @@ class DcmiSchema(SchemaBaseModel): Schema based on DCMI elements """ - type: Optional[str] = Field("image", description="Type of resource e.g. image", title="Type of resource") + type: Optional[str] = Field( + "image", description="Type of resource e.g. image", title="Type of resource" + ) title: str = Field(..., title="Photo title") caption: Optional[str] = Field(None, title="Photo caption") description: Optional[str] = Field(None, description="Description") topics: Optional[List[Topic]] = Field(None, title="Topics") keywords: Optional[List[Keyword]] = None - creator: Optional[str] = Field(None, description="Name of the person or organization", title="Creator") + creator: Optional[str] = Field( + None, description="Name of the person or organization", title="Creator" + ) contributor: Optional[str] = Field( - None, description="Name of the contributing person or organization", title="Contributor" + None, + description="Name of the contributing person or organization", + title="Contributor", ) publisher: Optional[str] = Field(None, title="Publisher") - date: Optional[str] = Field(None, description="Date when the photo was taken. use format YYYY-MM-DD", title="Date") + date: Optional[str] = Field( + None, + description="Date when the photo was taken. use format YYYY-MM-DD", + title="Date", + ) country: Optional[List[CountryItem]] = Field(None, title="Country") coverage: Optional[str] = Field(None, title="Geographic coverage") gps: Optional[Gps] = Field( - None, description="Geographic location of where the photo was taken", title="Geographic location" + None, + description="Geographic location of where the photo was taken", + title="Geographic location", ) format: Optional[str] = Field( None, - description=( - "Image file format e.g. `image/gif` - Image, GIF \n* `image/jpeg` - Image, JPEG \n* `image/png` - Image," - " PNG \n* `image/tiff` - Image, TIFF" - ), + description="Image file format e.g. `image/gif` - Image, GIF \n* `image/jpeg` - Image, JPEG \n* `image/png` - Image, PNG \n* `image/tiff` - Image, TIFF", title="Image format", ) languages: Optional[List[Language]] = Field( - None, description="Metadata language e.g. English, French, etc.", title="Language" + None, + description="Metadata language e.g. English, French, etc.", + title="Language", ) relations: Optional[List[Relation]] = Field(None, title="Related resources") rights: Optional[str] = Field(None, description="Copyrights", title="Rights") - source: Optional[str] = Field(None, description="Related resource from which resource is derived", title="Source") + source: Optional[str] = Field( + None, + description="Related resource from which resource is derived", + title="Source", + ) note: Optional[str] = Field( - None, description="Any additional information not covered by other fields", title="Notes" + None, + description="Any additional information not covered by other fields", + title="Notes", ) class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -757,7 +866,9 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class PhotoVideoMetadataIPTC(SchemaBaseModel): @@ -770,10 +881,7 @@ class PhotoVideoMetadataIPTC(SchemaBaseModel): ) title: Optional[str] = Field( None, - description=( - "A shorthand reference for the digital image. Title provides a short human readable name which can be a" - " text and/or numeric reference. It is not the same as Headline." - ), + description="A shorthand reference for the digital image. Title provides a short human readable name which can be a text and/or numeric reference. It is not the same as Headline.", title="Title", ) imageSupplierImageId: Optional[str] = Field( @@ -783,142 +891,105 @@ class PhotoVideoMetadataIPTC(SchemaBaseModel): ) registryEntries: Optional[List[RegistryEntry]] = Field( None, - description=( - "Both a Registry Item Id and a Registry Organisation Id to record any registration of this digital image" - " with a registry." - ), + description="Both a Registry Item Id and a Registry Organisation Id to record any registration of this digital image with a registry.", title="Image Registry Entry", ) digitalImageGuid: Optional[str] = Field( None, - description=( - "Globally unique identifier for this digital image. It is created and applied by the creator of the digital" - " image at the time of its creation . This value shall not be changed after that time." - ), + description="Globally unique identifier for this digital image. It is created and applied by the creator of the digital image at the time of its creation . This value shall not be changed after that time.", title="Digital Image GUID", ) dateCreated: Optional[AwareDatetime] = Field( None, - description=( - "Designates the date and optionally the time the content of the image was created rather than the date of" - " the creation of the digital representation." - ), + description="Designates the date and optionally the time the content of the image was created rather than the date of the creation of the digital representation.", title="Date Created", ) headline: Optional[str] = Field( - None, description="A brief synopsis of the caption. Headline is not the same as Title.", title="Headline" + None, + description="A brief synopsis of the caption. Headline is not the same as Title.", + title="Headline", ) eventName: Optional[str] = Field( - None, description="Names or describes the specific event at which the photo was taken.", title="Event" + None, + description="Names or describes the specific event at which the photo was taken.", + title="Event", ) description: Optional[str] = Field( - None, description="A textual description, including captions, of the image.", title="Description" + None, + description="A textual description, including captions, of the image.", + title="Description", ) captionWriter: Optional[str] = Field( None, - description=( - "Identifier or the name of the person involved in writing, editing or correcting the description of the" - " image." - ), + description="Identifier or the name of the person involved in writing, editing or correcting the description of the image.", title="Description Writer", ) keywords: Optional[List[str]] = Field( None, - description=( - "Keywords to express the subject of the image. Keywords may be free text and don't have to be taken from a" - " controlled vocabulary. Codes from the controlled vocabulary IPTC Subject NewsCodes must go to the" - ' "Subject Code" field.' - ), + description='Keywords to express the subject of the image. Keywords may be free text and don\'t have to be taken from a controlled vocabulary. Codes from the controlled vocabulary IPTC Subject NewsCodes must go to the "Subject Code" field.', title="Keywords", ) sceneCodes: Optional[List[str]] = Field( None, - description=( - 'Describes the scene of a photo content. Specifies one ore more terms from the IPTC "Scene-NewsCodes". Each' - " Scene is represented as a string of 6 digits in an unordered list." - ), + description='Describes the scene of a photo content. Specifies one ore more terms from the IPTC "Scene-NewsCodes". Each Scene is represented as a string of 6 digits in an unordered list.', title="Scene Code", ) sceneCodesLabelled: Optional[List[SceneCodesLabelledItem]] = Field( None, - description=( - 'Describes the scene of a photo content. Specifies one ore more terms from the IPTC "Scene-NewsCodes". Each' - " Scene is represented as a string of 6 digits in an unordered list." - ), + description='Describes the scene of a photo content. Specifies one ore more terms from the IPTC "Scene-NewsCodes". Each Scene is represented as a string of 6 digits in an unordered list.', title="Scene Codes", ) subjectCodes: Optional[List[str]] = Field( None, - description=( - "Specifies one or more Subjects from the IPTC Subject-NewsCodes taxonomy to categorise the image. Each" - " Subject is represented as a string of 8 digits in an unordered list." - ), + description="Specifies one or more Subjects from the IPTC Subject-NewsCodes taxonomy to categorise the image. Each Subject is represented as a string of 8 digits in an unordered list.", title="Subject Code", ) subjectCodesLabelled: Optional[List[SubjectCodesLabelledItem]] = Field( None, - description=( - "Specifies one or more Subjects from the IPTC Subject-NewsCodes taxonomy to categorise the image. Each" - " Subject is represented as a string of 8 digits in an unordered list." - ), + description="Specifies one or more Subjects from the IPTC Subject-NewsCodes taxonomy to categorise the image. Each Subject is represented as a string of 8 digits in an unordered list.", title="Subject Codes", ) creatorNames: Optional[List[str]] = Field( None, - description=( - "Contains the name of the photographer, but in cases where the photographer should not be identified the" - " name of a company or organisation may be appropriate." - ), + description="Contains the name of the photographer, but in cases where the photographer should not be identified the name of a company or organisation may be appropriate.", title="Creator", ) creatorContactInfo: Optional[CreatorContactInfo] = Field( None, - description=( - "The creator's contact information provides all necessary information to get in contact with the creator of" - " this image and comprises a set of sub-properties for proper addressing." - ), + description="The creator's contact information provides all necessary information to get in contact with the creator of this image and comprises a set of sub-properties for proper addressing.", title="Creator's Contact Info", ) creditLine: Optional[str] = Field( None, - description=( - "The credit to person(s) and/or organisation(s) required by the supplier of the image to be used when" - " published. This is a free-text field." - ), + description="The credit to person(s) and/or organisation(s) required by the supplier of the image to be used when published. This is a free-text field.", title="Credit Line", ) digitalSourceType: Optional[AnyUrl] = Field( - None, description="The type of the source of this digital image", title="Digital Source Type" + None, + description="The type of the source of this digital image", + title="Digital Source Type", ) jobid: Optional[str] = Field( None, - description=( - "Number or identifier for the purpose of improved workflow handling. This is a user created identifier" - " related to the job for which the image is supplied." - ), + description="Number or identifier for the purpose of improved workflow handling. This is a user created identifier related to the job for which the image is supplied.", title="Job Id", ) jobtitle: Optional[str] = Field( None, - description=( - "Contains the job title of the photographer. As this is sort of a qualifier the Creator element has to be" - " filled in as mandatory prerequisite for using Creator's Jobtitle." - ), + description="Contains the job title of the photographer. As this is sort of a qualifier the Creator element has to be filled in as mandatory prerequisite for using Creator's Jobtitle.", title="Creator's jobtitle", ) source: Optional[str] = Field( None, - description=( - "The name of a person or party who has a role in the content supply chain. This could be an agency, a" - " member of an agency, an individual or a combination. Source could be different from Creator and from the" - " entities in the Copyright Notice." - ), + description="The name of a person or party who has a role in the content supply chain. This could be an agency, a member of an agency, an individual or a combination. Source could be different from Creator and from the entities in the Copyright Notice.", title="Source", ) locationsShown: Optional[List[Location]] = Field( None, description="The location the photo was taken.", title="Location created" ) - imageRating: Optional[int] = Field(None, description="Rating of the image by its user or supplier") + imageRating: Optional[int] = Field( + None, description="Rating of the image by its user or supplier" + ) supplier: Optional[List[Entity]] = Field( None, description="Identifies the most recent supplier of the image, who is not necessarily its owner or creator.", @@ -926,19 +997,18 @@ class PhotoVideoMetadataIPTC(SchemaBaseModel): ) copyrightNotice: Optional[str] = Field( None, - description=( - "Contains any necessary copyright notice for claiming the intellectual property for this photograph and" - " should identify the current owner of the copyright for the photograph. Other entities like the creator of" - " the photograph may be added in the corresponding field. Notes on usage rights should be provided in" - ' "Rights usage terms".' - ), + description='Contains any necessary copyright notice for claiming the intellectual property for this photograph and should identify the current owner of the copyright for the photograph. Other entities like the creator of the photograph may be added in the corresponding field. Notes on usage rights should be provided in "Rights usage terms".', title="Copyright Notice", ) copyrightOwners: Optional[List[EntityWRole]] = Field( - None, description="Owner or owners of the copyright in the licensed image.", title="Copyright Owner" + None, + description="Owner or owners of the copyright in the licensed image.", + title="Copyright Owner", ) usageTerms: Optional[str] = Field( - None, description="The licensing parameters of the image expressed in free-text.", title="Rights Usage Terms" + None, + description="The licensing parameters of the image expressed in free-text.", + title="Rights Usage Terms", ) embdEncRightsExpr: Optional[List[EmbdEncRightsExpr]] = Field( None, @@ -952,29 +1022,16 @@ class PhotoVideoMetadataIPTC(SchemaBaseModel): ) webstatementRights: Optional[AnyUrl] = Field( None, - description=( - "URL referencing a web resouce providing a statement of the copyright ownership and usage rights of the" - " image." - ), + description="URL referencing a web resouce providing a statement of the copyright ownership and usage rights of the image.", ) instructions: Optional[str] = Field( None, - description=( - "Any of a number of instructions from the provider or creator to the receiver of the image which might" - " include any of the following: embargoes (NewsMagazines OUT) and other restrictions not covered by the" - ' "Rights Usage Terms" field; information regarding the original means of capture (scanning notes,' - " colourspace info) or other specific text information that the user may need for accurate reproduction;" - " additional permissions required when publishing; credits for publishing if they exceed the IIM length of" - " the credit field" - ), + description='Any of a number of instructions from the provider or creator to the receiver of the image which might include any of the following: embargoes (NewsMagazines OUT) and other restrictions not covered by the "Rights Usage Terms" field; information regarding the original means of capture (scanning notes, colourspace info) or other specific text information that the user may need for accurate reproduction; additional permissions required when publishing; credits for publishing if they exceed the IIM length of the credit field', title="Instructions", ) genres: Optional[List[CvTerm]] = Field( None, - description=( - "Artistic, style, journalistic, product or other genre(s) of the image (expressed by a term from any" - " Controlled Vocabulary)" - ), + description="Artistic, style, journalistic, product or other genre(s) of the image (expressed by a term from any Controlled Vocabulary)", title="Genre", ) intellectualGenre: Optional[str] = Field( @@ -988,10 +1045,14 @@ class PhotoVideoMetadataIPTC(SchemaBaseModel): title="Artwork or Object in the Image", ) personInImageNames: Optional[List[str]] = Field( - None, description="Name of a person shown in the image.", title="Person Shown in the Image" + None, + description="Name of a person shown in the image.", + title="Person Shown in the Image", ) personsShown: Optional[List[PersonWDetails]] = Field( - None, description="Details about a person the content is about.", title="Person Shown in the Image with Details" + None, + description="Details about a person the content is about.", + title="Person Shown in the Image with Details", ) modelAges: Optional[List[int]] = Field( None, @@ -1009,22 +1070,18 @@ class PhotoVideoMetadataIPTC(SchemaBaseModel): title="Minor Model Age Disclosure", ) modelReleaseDocuments: Optional[List[str]] = Field( - None, description="Optional identifier associated with each Model Release.", title="Model Release Id" + None, + description="Optional identifier associated with each Model Release.", + title="Model Release Id", ) modelReleaseStatus: Optional[CvTerm] = Field( None, - description=( - "Summarises the availability and scope of model releases authorising usage of the likenesses of persons" - " appearing in the photograph." - ), + description="Summarises the availability and scope of model releases authorising usage of the likenesses of persons appearing in the photograph.", title="Model Release Status", ) organisationInImageCodes: Optional[List[str]] = Field( None, - description=( - "Code from a controlled vocabulary for identifying the organisation or company which is featured in the" - " image." - ), + description="Code from a controlled vocabulary for identifying the organisation or company which is featured in the image.", title="Code of Organisation Featured in the Image", ) organisationInImageNames: Optional[List[str]] = Field( @@ -1033,41 +1090,33 @@ class PhotoVideoMetadataIPTC(SchemaBaseModel): title="Name of Organisation Featured in the Image", ) productsShown: Optional[List[Product]] = Field( - None, description="A product the content is about.", title="Product Shown in the Image" + None, + description="A product the content is about.", + title="Product Shown in the Image", ) maxAvailHeight: Optional[int] = Field( None, - description=( - "The maximum available height in pixels of the original photo from which this photo has been derived by" - " downsizing." - ), + description="The maximum available height in pixels of the original photo from which this photo has been derived by downsizing.", title="Max Avail Height", ) maxAvailWidth: Optional[int] = Field( None, - description=( - "The maximum available width in pixels of the original photo from which this photo has been derived by" - " downsizing." - ), + description="The maximum available width in pixels of the original photo from which this photo has been derived by downsizing.", title="Max Avail Width", ) propertyReleaseStatus: Optional[CvTerm] = Field( None, - description=( - "Summarises the availability and scope of property releases authorising usage of the properties appearing" - " in the photograph." - ), + description="Summarises the availability and scope of property releases authorising usage of the properties appearing in the photograph.", title="Property Release Status", ) propertyReleaseDocuments: Optional[List[str]] = Field( - None, description="Optional identifier associated with each Property Release.", title="Property Release Id" + None, + description="Optional identifier associated with each Property Release.", + title="Property Release Id", ) aboutCvTerms: Optional[List[CvTerm]] = Field( None, - description=( - "One or more topics, themes or entities the content is about, each one expressed by a term from a" - " Controlled Vocabulary." - ), + description="One or more topics, themes or entities the content is about, each one expressed by a term from a Controlled Vocabulary.", title="CV-Term About Image", ) @@ -1080,7 +1129,9 @@ class IptcPmdSchema(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - photoVideoMetadataIPTC: PhotoVideoMetadataIPTC = Field(..., description="Container for IPTC photo/video metadata") + photoVideoMetadataIPTC: PhotoVideoMetadataIPTC = Field( + ..., description="Container for IPTC photo/video metadata" + ) class LinkedImage(SchemaBaseModel): @@ -1090,8 +1141,12 @@ class LinkedImage(SchemaBaseModel): link: AnyUrl = Field(..., description="Link URL locating the image resource") mediaType: Optional[str] = Field(None, description="IANA Media (MIME) Type") widthPixels: Optional[int] = Field(None, description="Width of the image in pixels") - heightPixels: Optional[int] = Field(None, description="Height of the image in pixels") - role: Optional[str] = Field(None, description="Role of this image in the context of the video") + heightPixels: Optional[int] = Field( + None, description="Height of the image in pixels" + ) + role: Optional[str] = Field( + None, description="Role of this image in the context of the video" + ) linkQualifiers: Optional[List[AnyUrl]] = Field( None, description="Qualifier of the relationship of the image with the video" ) @@ -1099,8 +1154,12 @@ class LinkedImage(SchemaBaseModel): class ImageDescription(SchemaBaseModel): - idno: Optional[str] = Field(None, description="Image unique identifier", title="Image unique identifier") - identifiers: Optional[List[Identifier]] = Field(None, description="Other identifiers", title="Other identifiers") + idno: Optional[str] = Field( + None, description="Image unique identifier", title="Image unique identifier" + ) + identifiers: Optional[List[Identifier]] = Field( + None, description="Other identifiers", title="Other identifiers" + ) iptc: Optional[IptcPmdSchema] = None dcmi: Optional[DcmiSchema] = None license: Optional[List[LicenseItem]] = Field(None, title="License") @@ -1111,21 +1170,26 @@ class ImageDataTypeSchema(SchemaBaseModel): """ Uses IPTC JSON schema. See for more details - http://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata. """ - __metadata_type__ = "image" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" repositoryid: Optional[str] = Field( "central", description="Abbreviation for the collection that owns the document", title="Collection ID that owns the document", ) - published: Optional[int] = Field("0", description="Status `0=draft`, `1=published`", title="Status") - overwrite: Optional[Overwrite] = Field("no", description="Overwrite document if already exists?") + published: Optional[int] = Field( + "0", description="Status `0=draft`, `1=published`", title="Status" + ) + overwrite: Optional[Overwrite] = Field( + "no", description="Overwrite document if already exists?" + ) metadata_information: Optional[MetadataInformation] = Field( None, description="Document description", title="Document metadata information" ) image_description: Optional[ImageDescription] = None provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") tags: Optional[List[Tag]] = Field(None, description="Tags", title="Tags") - additional: Optional[Dict[str, Any]] = Field(None, description="Additional metadata") + additional: Optional[Dict[str, Any]] = Field( + None, description="Additional metadata" + ) diff --git a/pydantic_schemas/indicator_schema.py b/pydantic_schemas/indicator_schema.py index 7529e62..74b231f 100644 --- a/pydantic_schemas/indicator_schema.py +++ b/pydantic_schemas/indicator_schema.py @@ -41,11 +41,17 @@ class MetadataInformation(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) prod_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version_statement: Optional[VersionStatement] = Field( None, description="Version Statement", title="Version Statement" @@ -55,14 +61,13 @@ class MetadataInformation(SchemaBaseModel): class AuthoringEntityItem(SchemaBaseModel): name: str = Field( ..., - description=( - "Name of the person, corporate body, or agency responsible for the work's substantive and intellectual" - " content. If a person, invert first and last name and use commas." - ), + description="Name of the person, corporate body, or agency responsible for the work's substantive and intellectual content. If a person, invert first and last name and use commas.", title="Agency Name", ) affiliation: Optional[str] = Field(None, title="Affiliation") - abbreviation: Optional[Any] = Field(None, description="Abbreviation", title="Abbreviation") + abbreviation: Optional[Any] = Field( + None, description="Abbreviation", title="Abbreviation" + ) email: Optional[Any] = Field(None, description="Email", title="Email") uri: Optional[str] = Field(None, title="URI") @@ -109,7 +114,9 @@ class StatisticalConceptReference(DefinitionReference): class Concept(SchemaBaseModel): name: str = Field(..., title="Name") - definition: Optional[str] = Field(None, description="Definition", title="Definition") + definition: Optional[str] = Field( + None, description="Definition", title="Definition" + ) uri: Optional[str] = Field(None, description="Website link", title="URI") @@ -141,7 +148,9 @@ class Theme(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Name") parent_id: Optional[str] = Field(None, title="Parent Identifier") - vocabulary: Optional[str] = Field(None, description="Name of the controlled vocabulary", title="Vocabulary") + vocabulary: Optional[str] = Field( + None, description="Name of the controlled vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field( None, description="Link to the controlled vocabulary web page, if the theme is from a taxonomy.", @@ -153,10 +162,14 @@ class Topic(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Topic") parent_id: Optional[str] = Field( - None, description="For subtopics, provide the ID of the parent topic", title="Parent topic Identifier" + None, + description="For subtopics, provide the ID of the parent topic", + title="Parent topic Identifier", ) vocabulary: Optional[str] = Field( - None, description="Name of the controlled vocabulary, if the topic is from a taxonomy.", title="Vocabulary" + None, + description="Name of the controlled vocabulary, if the topic is from a taxonomy.", + title="Vocabulary", ) uri: Optional[str] = Field( None, @@ -169,7 +182,9 @@ class Discipline(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Discipline title or name") parent_id: Optional[str] = Field(None, title="Parent Identifier") - vocabulary: Optional[str] = Field(None, description="Vocabulary", title="Vocabulary") + vocabulary: Optional[str] = Field( + None, description="Vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field(None, description="Website link", title="URI") @@ -195,13 +210,19 @@ class RefCountryItem(SchemaBaseModel): class GeographicUnit(SchemaBaseModel): name: str = Field( - ..., description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", title="Location name" + ..., + description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", + title="Location name", ) code: Optional[str] = Field( - None, description="Code of the geographic unit (for countries, preferred = ISO3 code)", title="Location code" + None, + description="Code of the geographic unit (for countries, preferred = ISO3 code)", + title="Location code", ) type: Optional[str] = Field( - None, description="Type of geographic unit e.g. country, state, region, province etc", title="Type" + None, + description="Type of geographic unit e.g. country, state, region, province etc", + title="Type", ) @@ -223,7 +244,9 @@ class LicenseItem(SchemaBaseModel): class Link(SchemaBaseModel): - type: Optional[str] = Field(None, description="Link types - API, website, etc.", title="Link type") + type: Optional[str] = Field( + None, description="Link types - API, website, etc.", title="Link type" + ) description: Optional[str] = Field(None, title="Description") uri: Optional[str] = Field(None, title="URI") @@ -255,14 +278,18 @@ class Author(SchemaBaseModel): class Dataset(SchemaBaseModel): idno: Optional[str] = Field(None, title="Identifier (IDNO)") title: Optional[str] = Field( - None, description="Title of the dataset inluding the country and year if relevant", title="Title" + None, + description="Title of the dataset inluding the country and year if relevant", + title="Title", ) uri: Optional[str] = Field(None, title="URI") class Source(SchemaBaseModel): idno: Optional[str] = Field(None, title="Source ID") - other_identifiers: Optional[List[OtherIdentifier]] = Field(None, title="Identifiers") + other_identifiers: Optional[List[OtherIdentifier]] = Field( + None, title="Identifiers" + ) type: Optional[str] = Field(None, title="Source type") name: str = Field(..., description="Source name", title="Name") organization: Optional[str] = Field(None, title="Organization") @@ -291,12 +318,16 @@ class Keyword(SchemaBaseModel): class Acronym(SchemaBaseModel): acronym: str = Field(..., title="Acronym or abbreviation") expansion: str = Field(..., title="Expansion of the acronym or abbreviation") - occurrence: Optional[float] = Field(None, title="Occurrence of the acronym in the document") + occurrence: Optional[float] = Field( + None, title="Occurrence of the acronym in the document" + ) class Erratum(SchemaBaseModel): date: Optional[str] = Field( - None, description="Date when the erratum was reported or published", title="Date of erratum" + None, + description="Date when the erratum was reported or published", + title="Date of erratum", ) description: Optional[str] = Field( None, @@ -319,7 +350,9 @@ class Note(SchemaBaseModel): class RelatedIndicator(SchemaBaseModel): - id: Optional[str] = Field(None, description="Indicator unique identifier", title="Identifier") + id: Optional[str] = Field( + None, description="Indicator unique identifier", title="Identifier" + ) code: Optional[str] = Field(None, title="Indicator code") label: Optional[str] = Field(None, title="Indicator name") uri: Optional[str] = Field(None, title="URI") @@ -355,7 +388,9 @@ class FrameworkItem(SchemaBaseModel): class SeriesGroup(SchemaBaseModel): name: Optional[str] = Field(None, title="Name") description: Optional[str] = Field( - None, description="A brief description of the series group.", title="Description" + None, + description="A brief description of the series group.", + title="Description", ) version: Optional[str] = Field(None, title="Version") uri: Optional[str] = Field(None, title="URI") @@ -382,33 +417,35 @@ class SeriesDescription(SchemaBaseModel): display_name: Optional[str] = Field(None, title="Display Name") authoring_entity: Optional[List[AuthoringEntityItem]] = Field( None, - description=( - "The person, corporate body, or agency responsible for the work's substantive and intellectual content." - " Repeat the element for each author, and use 'affiliation' attribute if available. Invert first and last" - " name and use commas." - ), + description="The person, corporate body, or agency responsible for the work's substantive and intellectual content. Repeat the element for each author, and use 'affiliation' attribute if available. Invert first and last name and use commas.", title="Authoring entity", ) - database_id: Optional[str] = Field(None, description="Series database ID", title="Database ID") - database_name: Optional[str] = Field(None, description="Series database name", title="Database name") + database_id: Optional[str] = Field( + None, description="Series database ID", title="Database ID" + ) + database_name: Optional[str] = Field( + None, description="Series database name", title="Database name" + ) date_last_update: Optional[str] = Field(None, title="Last updated date") date_released: Optional[str] = Field(None, title="Date released") version_statement: Optional[VersionStatement] = Field( None, description="Version Statement", title="Version Statement" ) aliases: Optional[List[Alias]] = Field(None, title="Series other names") - alternate_identifiers: Optional[List[AlternateIdentifier]] = Field(None, title="Alternate identifiers") + alternate_identifiers: Optional[List[AlternateIdentifier]] = Field( + None, title="Alternate identifiers" + ) languages: Optional[List[Language]] = Field(None, description="Supported languages") measurement_unit: Optional[str] = Field(None, title="Series unit of measure") power_code: Optional[str] = Field( None, - description=( - "Power of 10 by which the reported statistics should be multiplied. e.g. '6' indicating millions of units" - ), + description="Power of 10 by which the reported statistics should be multiplied. e.g. '6' indicating millions of units", title="Power code", ) dimensions: Optional[List[Dimension]] = Field(None, title="Dimensions") - release_calendar: Optional[str] = Field(None, description="Release calendar", title="Release calendar") + release_calendar: Optional[str] = Field( + None, description="Release calendar", title="Release calendar" + ) periodicity: Optional[str] = Field(None, title="Periodicity of data") base_period: Optional[str] = Field(None, title="Base period") definition_short: Optional[str] = Field(None, title="Definition short") @@ -420,9 +457,13 @@ class SeriesDescription(SchemaBaseModel): ) statistical_concept: Optional[str] = Field(None, title="Statistical concept") statistical_concept_references: Optional[List[StatisticalConceptReference]] = Field( - None, description="URLs for statistical concept references", title="Statistical concept references" + None, + description="URLs for statistical concept references", + title="Statistical concept references", + ) + concepts: Optional[List[Concept]] = Field( + None, description="Related concepts", title="Related concepts" ) - concepts: Optional[List[Concept]] = Field(None, description="Related concepts", title="Related concepts") universe: Optional[str] = Field( None, description="Target population (the statistical universe about which information is sought)", @@ -430,46 +471,42 @@ class SeriesDescription(SchemaBaseModel): ) data_collection: Optional[DataCollection] = Field( None, - description=( - " This description should include, when applicable, the sample frame used, the questions used to collect" - " the data, the type of interview, the dates/duration of fieldwork, the sample size and the response rate." - " Some additional information on questionnaire design and testing, interviewer training, methods used to" - " monitor non-response etc." - ), + description=" This description should include, when applicable, the sample frame used, the questions used to collect the data, the type of interview, the dates/duration of fieldwork, the sample size and the response rate. Some additional information on questionnaire design and testing, interviewer training, methods used to monitor non-response etc.", title="Data collection", ) methodology: Optional[str] = Field(None, title="Methodology") methodology_references: Optional[List[MethodologyReference]] = Field( - None, description="URLs for methodology references", title="Methodology references" + None, + description="URLs for methodology references", + title="Methodology references", ) derivation: Optional[str] = Field(None, title="Derivation") derivation_references: Optional[List[DerivationReference]] = Field( - None, description="URLs for derivation references", title="Derivation references" + None, + description="URLs for derivation references", + title="Derivation references", ) imputation: Optional[str] = Field(None, title="Imputations") imputation_references: Optional[List[ImputationReference]] = Field( - None, description="URLs for imputation references", title="Imputation references" + None, + description="URLs for imputation references", + title="Imputation references", ) seasonal_adjustment: Optional[str] = Field( None, - description=( - "Application of statistical techniques to time series data in order to remove seasonal fluctuations and to" - " better understand underlying trends." - ), + description="Application of statistical techniques to time series data in order to remove seasonal fluctuations and to better understand underlying trends.", title="Seasonal adjustment", ) adjustments: Optional[List[str]] = Field( None, - description=( - "Description of any adjustments with respect to use of standard classifications and harmonization of" - " breakdowns for age group and other dimensions, or adjustments made for compliance with specific" - " international or national definitions." - ), + description="Description of any adjustments with respect to use of standard classifications and harmonization of breakdowns for age group and other dimensions, or adjustments made for compliance with specific international or national definitions.", title="Other adjustments", ) missing: Optional[str] = Field(None, title="Treatment of missing values") validation_rules: Optional[List[str]] = Field( - None, description="Set of rules to validate values for indicators, e.g. range checks", title="Validation rules" + None, + description="Set of rules to validate values for indicators, e.g. range checks", + title="Validation rules", ) quality_checks: Optional[str] = Field(None, title="Quality control methods") quality_note: Optional[str] = Field(None, title="Note on data quality") @@ -491,37 +528,49 @@ class SeriesDescription(SchemaBaseModel): mandate: Optional[Mandate] = Field(None, description="Mandate", title="Mandate") time_periods: Optional[List[TimePeriod]] = Field(None, title="Series dates") ref_country: Optional[List[RefCountryItem]] = Field( - None, description="List of countries for which data are available", title="Reference country" + None, + description="List of countries for which data are available", + title="Reference country", ) geographic_units: Optional[List[GeographicUnit]] = Field( None, - description=( - "List of geographic units (regions, countries, states, provinces, etc.) for which data are available in the" - " database." - ), + description="List of geographic units (regions, countries, states, provinces, etc.) for which data are available in the database.", title="Geographic locations", ) bbox: Optional[List[BboxItem]] = Field(None, title="Geographic bounding box") aggregation_method: Optional[str] = Field(None, title="Aggregation method") aggregation_method_references: Optional[List[AggregationMethodReference]] = Field( - None, description="URLs for aggregation method references", title="Aggregation method references" + None, + description="URLs for aggregation method references", + title="Aggregation method references", ) disaggregation: Optional[str] = Field(None, title="Dissaggregation") - license: Optional[List[LicenseItem]] = Field(None, description="License information", title="License") + license: Optional[List[LicenseItem]] = Field( + None, description="License information", title="License" + ) confidentiality: Optional[str] = Field( None, description="Confidentiality statement", title="Confidentiality statement" ) confidentiality_status: Optional[str] = Field(None, title="Confidentiality status") confidentiality_note: Optional[str] = Field(None, title="Confidentiality note") citation_requirement: Optional[str] = Field( - None, description="Citation requirement (can include a specific recommended citation)" + None, + description="Citation requirement (can include a specific recommended citation)", + ) + links: Optional[List[Link]] = Field( + None, description="Links to API calls, websites, etc.", title="Series links" + ) + api_documentation: Optional[List[ApiDocumentationItem]] = Field( + None, description="API Documentation" + ) + sources: Optional[List[Source]] = Field( + None, description="Sources", title="Sources" ) - links: Optional[List[Link]] = Field(None, description="Links to API calls, websites, etc.", title="Series links") - api_documentation: Optional[List[ApiDocumentationItem]] = Field(None, description="API Documentation") - sources: Optional[List[Source]] = Field(None, description="Sources", title="Sources") sources_note: Optional[str] = Field(None, title="Notes form original sources") direct_sources: Optional[List[DirectSource]] = Field( - None, description="Refers to the sources from where the data was directly collected", title="Direct sources" + None, + description="Refers to the sources from where the data was directly collected", + title="Direct sources", ) keywords: Optional[List[Keyword]] = Field(None, description="Keywords") acronyms: Optional[List[Acronym]] = Field(None, description="Acronyms") @@ -529,22 +578,30 @@ class SeriesDescription(SchemaBaseModel): None, description="List of corrected errors in data or metadata", title="Errata" ) acknowledgements: Optional[List[Acknowledgement]] = Field( - None, description="Acknowledgments of persons or organizations", title="Other acknowledgments" + None, + description="Acknowledgments of persons or organizations", + title="Other acknowledgments", ) acknowledgement_statement: Optional[str] = Field( None, description="Acknowledgement statement", title="Acknowledgement statement" ) disclaimer: Optional[str] = Field(None, title="Disclaimer") notes: Optional[List[Note]] = Field(None, description="Notes", title="Notes") - related_indicators: Optional[List[RelatedIndicator]] = Field(None, description="Related indicators") + related_indicators: Optional[List[RelatedIndicator]] = Field( + None, description="Related indicators" + ) compliance: Optional[List[ComplianceItem]] = Field( - None, description="Compliance with international resolution", title="Compliance with international resolution" + None, + description="Compliance with international resolution", + title="Compliance with international resolution", ) framework: Optional[List[FrameworkItem]] = Field(None, title="Framework") series_groups: Optional[List[SeriesGroup]] = Field( None, description="Series included in groups", title="Series groups" ) - contacts: Optional[List[Contact]] = Field(None, description="Contacts", title="Contacts") + contacts: Optional[List[Contact]] = Field( + None, description="Contacts", title="Contacts" + ) class DataType(Enum): @@ -589,9 +646,13 @@ class DataStructureItem(SchemaBaseModel): description: Optional[str] = Field(None, title="Description") data_type: Optional[DataType] = Field(None, title="Data type") column_type: Optional[ColumnType] = Field(None, title="Column type") - time_period_format: Optional[TimePeriodFormat] = Field(None, title="Time period format") + time_period_format: Optional[TimePeriodFormat] = Field( + None, title="Time period format" + ) code_list: Optional[List[CodeListItem]] = Field(None, title="Code list") - code_list_reference: Optional[CodeListReference] = Field(None, title="Code list reference") + code_list_reference: Optional[CodeListReference] = Field( + None, title="Code list reference" + ) class Operator(Enum): @@ -612,7 +673,9 @@ class Filter(SchemaBaseModel): class DataNote(SchemaBaseModel): - filters: Optional[List[Filter]] = Field(None, description="Filters", title="Filters") + filters: Optional[List[Filter]] = Field( + None, description="Filters", title="Filters" + ) note: Optional[str] = Field(None, title="Note") @@ -666,7 +729,9 @@ class ResourceTypeGeneral(Enum): class Types(SchemaBaseModel): resourceType: str = Field(..., title="Resource type") - resourceTypeGeneral: Optional[ResourceTypeGeneral] = Field(None, title="Resource type general") + resourceTypeGeneral: Optional[ResourceTypeGeneral] = Field( + None, title="Resource type general" + ) class DataciteSchema(SchemaBaseModel): @@ -687,21 +752,28 @@ class DataciteSchema(SchemaBaseModel): class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -710,27 +782,42 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class TimeseriesSchema(SchemaBaseModel): """ Schema for timeseries data type """ - __metadata_type__ = "indicator" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" - idno: Optional[str] = Field(None, description="Project unique identifier", title="Project unique identifier") + idno: Optional[str] = Field( + None, description="Project unique identifier", title="Project unique identifier" + ) metadata_information: Optional[MetadataInformation] = Field( - None, description="Information on the production of the metadata", title="Metadata creation" + None, + description="Information on the production of the metadata", + title="Metadata creation", ) series_description: SeriesDescription = Field(..., description="Series information") - data_structure: Optional[List[DataStructureItem]] = Field(None, description="Data structure definition") - data_notes: Optional[List[DataNote]] = Field(None, description="Data notes", title="Data notes") - datacite: Optional[DataciteSchema] = Field(None, description="DataCite metadata for generating DOI") + data_structure: Optional[List[DataStructureItem]] = Field( + None, description="Data structure definition" + ) + data_notes: Optional[List[DataNote]] = Field( + None, description="Data notes", title="Data notes" + ) + datacite: Optional[DataciteSchema] = Field( + None, description="DataCite metadata for generating DOI" + ) provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") - tags: Optional[List[Tag]] = Field(None, description="Tags", title="Tags (user-defined)") + tags: Optional[List[Tag]] = Field( + None, description="Tags", title="Tags (user-defined)" + ) additional: Optional[Dict[str, Any]] = Field( - None, description="Any other custom metadata not covered by the schema", title="Additional custom metadata" + None, + description="Any other custom metadata not covered by the schema", + title="Additional custom metadata", ) diff --git a/pydantic_schemas/indicators_db_schema.py b/pydantic_schemas/indicators_db_schema.py index 83afcd6..e0755aa 100644 --- a/pydantic_schemas/indicators_db_schema.py +++ b/pydantic_schemas/indicators_db_schema.py @@ -35,20 +35,30 @@ class MetadataInformation(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) prod_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version: Optional[str] = Field( - None, description="Identify and describe the current version of the document", title="Document version" + None, + description="Identify and describe the current version of the document", + title="Document version", ) class Identifier(SchemaBaseModel): type: Optional[str] = Field( - None, description="Type of identifier e.g. `doi`, `handle`, `other`", title="Identifier type" + None, + description="Type of identifier e.g. `doi`, `handle`, `other`", + title="Identifier type", ) identifier: str = Field(..., title="Identifier") @@ -63,25 +73,20 @@ class TitleStatement(SchemaBaseModel): description="The ID number of a database is a unique number that is used to identify a particular database.", title="Unique user defined ID", ) - identifiers: Optional[List[Identifier]] = Field(None, description="Other identifiers", title="Other identifiers") + identifiers: Optional[List[Identifier]] = Field( + None, description="Other identifiers", title="Other identifiers" + ) title: str = Field( ..., - description=( - "The title is the official name of the survey as it is stated on the questionnaire or as it appears in the" - " design documents. The following items should be noted:\n - Include the reference year(s) of the survey in" - " the title. \n - Do not include the abbreviation of the survey name in the title. \n - As the survey title" - " is a proper noun, the first letter of each word should be capitalized (except for prepositions or other" - " conjunctions).\n - Including the country name in the title is optional." - ), + description="The title is the official name of the survey as it is stated on the questionnaire or as it appears in the design documents. The following items should be noted:\n - Include the reference year(s) of the survey in the title. \n - Do not include the abbreviation of the survey name in the title. \n - As the survey title is a proper noun, the first letter of each word should be capitalized (except for prepositions or other conjunctions).\n - Including the country name in the title is optional.", title="Survey title", ) - sub_title: Optional[str] = Field(None, description="A short subtitle for the survey", title="Survey subtitle") + sub_title: Optional[str] = Field( + None, description="A short subtitle for the survey", title="Survey subtitle" + ) alternate_title: Optional[str] = Field( None, - description=( - "The abbreviation of a survey is usually the first letter of each word of the titled survey. The survey" - " reference year(s) may be included." - ), + description="The abbreviation of a survey is usually the first letter of each word of the titled survey. The survey reference year(s) may be included.", title="Abbreviation or Acronym", ) translated_title: Optional[str] = Field( @@ -94,14 +99,13 @@ class TitleStatement(SchemaBaseModel): class AuthoringEntityItem(SchemaBaseModel): name: str = Field( ..., - description=( - "Name of the person, corporate body, or agency responsible for the work's substantive and intellectual" - " content. If a person, invert first and last name and use commas." - ), + description="Name of the person, corporate body, or agency responsible for the work's substantive and intellectual content. If a person, invert first and last name and use commas.", title="Agency Name", ) affiliation: Optional[str] = Field(None, title="Affiliation") - abbreviation: Optional[str] = Field(None, description="Abbreviation", title="Abbreviation") + abbreviation: Optional[str] = Field( + None, description="Abbreviation", title="Abbreviation" + ) email: Optional[str] = Field(None, description="Email", title="Email") uri: Optional[str] = Field(None, title="URI") @@ -110,7 +114,9 @@ class VersionItem(SchemaBaseModel): version: str = Field(..., description="Version number e.g. v1.0", title="Version") date: str = Field(..., title="Version Date") responsibility: Optional[str] = Field( - None, description="Version Responsibility Statement", title="Version Responsibility Statement" + None, + description="Version Responsibility Statement", + title="Version Responsibility Statement", ) notes: Optional[str] = Field(None, title="Version Notes") @@ -121,10 +127,14 @@ class UpdateScheduleItem(SchemaBaseModel): class TimeCoverageItem(SchemaBaseModel): start: Optional[str] = Field( - None, description="Time coverage, start date (oldest date for which data are available)", title="Start date" + None, + description="Time coverage, start date (oldest date for which data are available)", + title="Start date", ) end: Optional[str] = Field( - None, description="Time coverage, end date (most recent date for which data are available)", title="End date" + None, + description="Time coverage, end date (most recent date for which data are available)", + title="End date", ) @@ -136,7 +146,9 @@ class Theme(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Name") parent_id: Optional[str] = Field(None, title="Parent Identifier") - vocabulary: Optional[str] = Field(None, description="Name of the controlled vocabulary", title="Vocabulary") + vocabulary: Optional[str] = Field( + None, description="Name of the controlled vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field( None, description="Link to the controlled vocabulary web page, if the theme is from a taxonomy.", @@ -148,10 +160,14 @@ class Topic(SchemaBaseModel): id: str = Field(..., title="Unique Identifier") name: str = Field(..., title="Topic") parent_id: Optional[str] = Field( - None, description="For subtopics, provide the ID of the parent topic", title="Parent topic Identifier" + None, + description="For subtopics, provide the ID of the parent topic", + title="Parent topic Identifier", ) vocabulary: Optional[str] = Field( - None, description="Name of the controlled vocabulary, if the topic is from a taxonomy.", title="Vocabulary" + None, + description="Name of the controlled vocabulary, if the topic is from a taxonomy.", + title="Vocabulary", ) uri: Optional[str] = Field( None, @@ -173,13 +189,19 @@ class RefCountryItem(SchemaBaseModel): class GeographicUnit(SchemaBaseModel): name: str = Field( - ..., description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", title="Location name" + ..., + description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", + title="Location name", ) code: Optional[str] = Field( - None, description="Code of the geographic unit (for countries, preferred = ISO3 code)", title="Location code" + None, + description="Code of the geographic unit (for countries, preferred = ISO3 code)", + title="Location code", ) type: Optional[str] = Field( - None, description="Type of geographic unit e.g. country, state, region, province etc", title="Type" + None, + description="Type of geographic unit e.g. country, state, region, province etc", + title="Type", ) @@ -191,11 +213,19 @@ class BboxItem(SchemaBaseModel): class Sponsor(SchemaBaseModel): - name: Optional[str] = Field(None, description="Name of the sponsoring agency", title="Funding Agency/Sponsor") + name: Optional[str] = Field( + None, + description="Name of the sponsoring agency", + title="Funding Agency/Sponsor", + ) abbreviation: Optional[str] = Field( - None, description="Abbreviation (acronym) of the sponsoring agency", title="Abbreviation" + None, + description="Abbreviation (acronym) of the sponsoring agency", + title="Abbreviation", + ) + role: Optional[str] = Field( + None, description="Specific role of the sponsoring agency", title="Role" ) - role: Optional[str] = Field(None, description="Specific role of the sponsoring agency", title="Role") grant: Optional[str] = Field(None, description="Grant number", title="Grant") uri: Optional[str] = Field(None, title="URI") @@ -227,7 +257,9 @@ class Language(SchemaBaseModel): class AccessOption(SchemaBaseModel): - type: str = Field(..., description="Access type e.g. API, Bulk, Query, etc", title="Access type") + type: str = Field( + ..., description="Access type e.g. API, Bulk, Query, etc", title="Access type" + ) uri: Optional[str] = Field(None, title="URI") note: Optional[str] = Field(None, description="Note", title="Note") @@ -253,22 +285,26 @@ class DatabaseDescription(SchemaBaseModel): title_statement: TitleStatement = Field(..., description="Study title") authoring_entity: Optional[List[AuthoringEntityItem]] = Field( None, - description=( - "The person, corporate body, or agency responsible for the work's substantive and intellectual content." - " Repeat the element for each author, and use 'affiliation' attribute if available. Invert first and last" - " name and use commas." - ), + description="The person, corporate body, or agency responsible for the work's substantive and intellectual content. Repeat the element for each author, and use 'affiliation' attribute if available. Invert first and last name and use commas.", title="Authoring entity", ) - abstract: Optional[str] = Field(None, description="A brief description of the database", title="Abstract") - url: Optional[str] = Field(None, description="Link to the dataset web page", title="Dataset URL") + abstract: Optional[str] = Field( + None, description="A brief description of the database", title="Abstract" + ) + url: Optional[str] = Field( + None, description="Link to the dataset web page", title="Dataset URL" + ) type: Optional[str] = Field(None, description="Dataset type", title="Dataset type") doi: Optional[str] = Field(None, description="DOI handle", title="DOI") date_created: Optional[str] = Field( - None, description="Date this version of the dataset was created", title="Date of creation" + None, + description="Date this version of the dataset was created", + title="Date of creation", ) date_published: Optional[str] = Field( - None, description="Date this version of the dataset was published", title="Dataset published date" + None, + description="Date this version of the dataset was published", + title="Dataset published date", ) version: Optional[List[VersionItem]] = Field(None, title="Version Statement") update_frequency: Optional[str] = Field( @@ -281,20 +317,15 @@ class DatabaseDescription(SchemaBaseModel): ) time_coverage: Optional[List[TimeCoverageItem]] = Field( None, - description=( - "Time coverage for the whole database. This will typically be the min and max dates for which data are" - " available in any series contained in the database." - ), + description="Time coverage for the whole database. This will typically be the min and max dates for which data are available in any series contained in the database.", title="Range of dates covered by the dataset", ) - time_coverage_note: Optional[str] = Field(None, description="Time coverage note", title="Time coverage note") + time_coverage_note: Optional[str] = Field( + None, description="Time coverage note", title="Time coverage note" + ) periodicity: Optional[List[PeriodicityItem]] = Field( None, - description=( - "Periodicity of the data contained in the database (NOT the periodicity of update of the database). This" - " describes the various reference periods for the series. Example: `annual`, `quarterly`, `monthly`," - " `daily`." - ), + description="Periodicity of the data contained in the database (NOT the periodicity of update of the database). This describes the various reference periods for the series. Example: `annual`, `quarterly`, `monthly`, `daily`.", title="Periodicity of series", ) themes: Optional[List[Theme]] = Field(None, description="Themes") @@ -305,32 +336,34 @@ class DatabaseDescription(SchemaBaseModel): ) keywords: Optional[List[Keyword]] = Field(None, description="Keywords") ref_country: Optional[List[RefCountryItem]] = Field( - None, description="List of countries for which data are available", title="Reference country" + None, + description="List of countries for which data are available", + title="Reference country", ) geographic_units: Optional[List[GeographicUnit]] = Field( None, - description=( - "List of geographic units (regions, countries, states, provinces, etc.) for which data are available in the" - " database." - ), + description="List of geographic units (regions, countries, states, provinces, etc.) for which data are available in the database.", title="Geographic locations", ) geographic_coverage_note: Optional[str] = Field( - None, description="Notes on geographic coverage", title="Geographic coverage notes" + None, + description="Notes on geographic coverage", + title="Geographic coverage notes", + ) + bbox: Optional[List[BboxItem]] = Field( + None, description="Geographic bounding box", title="Geographic bounding box" ) - bbox: Optional[List[BboxItem]] = Field(None, description="Geographic bounding box", title="Geographic bounding box") geographic_granularity: Optional[str] = Field( None, description="Granularity of geographic coverage e.g. `national`, `regional`, `provincial`", title="Geographic granularity", ) - geographic_area_count: Optional[str] = Field(None, description="Number of geographic areas") + geographic_area_count: Optional[str] = Field( + None, description="Number of geographic areas" + ) sponsors: Optional[List[Sponsor]] = Field( None, - description=( - "The source(s) of funds for production of the work. If different funding agencies sponsored different" - " stages of the production process, use the 'role' attribute to distinguish them." - ), + description="The source(s) of funds for production of the work. If different funding agencies sponsored different stages of the production process, use the 'role' attribute to distinguish them.", title="Sponsor/Funding Agency", ) acknowledgments: Optional[List[Acknowledgment]] = Field( @@ -338,18 +371,21 @@ class DatabaseDescription(SchemaBaseModel): ) acknowledgment_statement: Optional[str] = Field( None, - title=( - "An overall statement of acknowledgment, which can be used as an alternative (or supplement) to the" - " itemized list provided in `acknowledgments`." - ), + title="An overall statement of acknowledgment, which can be used as an alternative (or supplement) to the itemized list provided in `acknowledgments`.", + ) + contacts: Optional[List[Contact]] = Field( + None, description="Contacts", title="Contacts" + ) + links: Optional[List[Link]] = Field( + None, description="Related links", title="Related links" ) - contacts: Optional[List[Contact]] = Field(None, description="Contacts", title="Contacts") - links: Optional[List[Link]] = Field(None, description="Related links", title="Related links") languages: Optional[List[Language]] = Field(None, description="Supported languages") access_options: Optional[List[AccessOption]] = Field( None, description="Access options e.g. API, Bulk, Query", title="Access options" ) - license: Optional[List[LicenseItem]] = Field(None, description="License information", title="License") + license: Optional[List[LicenseItem]] = Field( + None, description="License information", title="License" + ) citation: Optional[str] = Field(None, title="Citation") notes: Optional[List[Note]] = Field(None, description="Notes", title="Notes") disclaimer: Optional[str] = Field(None, title="Disclaimer") @@ -357,21 +393,28 @@ class DatabaseDescription(SchemaBaseModel): class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -380,19 +423,24 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class TimeseriesDatabaseSchema(SchemaBaseModel): """ Schema for timeseries database """ - __metadata_type__ = "indicators_db" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" - published: Optional[int] = Field(0, description="0=draft, 1=published", title="Status") - overwrite: Optional[Overwrite] = Field("no", description="Overwrite database if already exists?") + published: Optional[int] = Field( + 0, description="0=draft, 1=published", title="Status" + ) + overwrite: Optional[Overwrite] = Field( + "no", description="Overwrite database if already exists?" + ) metadata_information: Optional[MetadataInformation] = Field( None, description="Document description", title="Document metadata information" ) @@ -401,5 +449,7 @@ class TimeseriesDatabaseSchema(SchemaBaseModel): ) provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") additional: Optional[Dict[str, Any]] = Field( - None, description="Any other custom metadata not covered by the schema", title="Additional custom metadata" + None, + description="Any other custom metadata not covered by the schema", + title="Additional custom metadata", ) diff --git a/pydantic_schemas/metadata_manager.py b/pydantic_schemas/metadata_manager.py index 591508d..f41fea7 100644 --- a/pydantic_schemas/metadata_manager.py +++ b/pydantic_schemas/metadata_manager.py @@ -1,7 +1,7 @@ import importlib.metadata import warnings from copy import copy -from typing import Dict, List, Optional, Type, Union +from typing import List, Optional, Type, Union from openpyxl import load_workbook from pydantic import BaseModel @@ -18,8 +18,15 @@ table_schema, video_schema, ) -from .utils.excel_to_pydantic import excel_doc_to_pydantic, excel_single_sheet_to_pydantic -from .utils.pydantic_to_excel import parse_version, write_across_many_sheets, write_to_single_sheet +from .utils.excel_to_pydantic import ( + excel_doc_to_pydantic, + excel_single_sheet_to_pydantic, +) +from .utils.pydantic_to_excel import ( + parse_version, + write_across_many_sheets, + write_to_single_sheet, +) from .utils.quick_start import make_skeleton from .utils.schema_base_model import SchemaBaseModel from .utils.utils import merge_dicts, standardize_keys_in_dict @@ -139,14 +146,14 @@ def create_metadata_outline( self, metadata_name_or_class: Union[str, Type[BaseModel]], debug: bool = False ) -> BaseModel: """ - Create a skeleton pydantic object for the given metadata type. + Create a skeleton pydantic model for the given metadata type. Args: metadata_name_or_class (str or type[BaseModel]): The name of the metadata type or the metadata class. debug (bool): If True, print debug information on the skeleton creation. Returns: - BaseModel: A pydantic object with the metadata schema and default values. + BaseModel: A pydantic model with the metadata schema and default values. Example: >>> from pydantic_schemas.metadata_manager import MetadataManager @@ -157,8 +164,7 @@ def create_metadata_outline( schema = self.metadata_class_from_name(metadata_name_or_class) else: schema = metadata_name_or_class - skeleton_object = make_skeleton(schema, debug=debug) - return skeleton_object + return make_skeleton(schema, debug=debug) def _get_name_schema_writer(self, metadata_name_or_class): """ @@ -188,9 +194,11 @@ def _get_name_schema_writer(self, metadata_name_or_class): metadata_name = self.standardize_metadata_name(metadata_name_or_class) schema = self._TYPE_TO_SCHEMA[metadata_name] else: - for metadata_name, schema in self._TYPE_TO_SCHEMA.items(): - if schema is metadata_name_or_class or schema is type(metadata_name_or_class): - break + # for metadata_name, schema in self._TYPE_TO_SCHEMA.items(): + # if schema is metadata_name_or_class or schema is type(metadata_name_or_class): + # break + metadata_name = self.standardize_metadata_name(metadata_name_or_class.__metadata_type__) + schema = metadata_name_or_class writer = self._TYPE_TO_WRITER[metadata_name] else: writer = write_to_single_sheet @@ -238,7 +246,7 @@ def write_metadata_outline_to_excel( metadata_name, schema, _ = self._get_name_schema_writer(metadata_name_or_class) else: metadata_name, schema, writer = self._get_name_schema_writer(metadata_name_or_class) - skeleton_object = self.create_metadata_outline(schema, debug=False) + skeleton_model = self.create_metadata_outline(schema, debug=False) if filename is None: filename = f"{metadata_name}_metadata.xlsx" @@ -247,22 +255,22 @@ def write_metadata_outline_to_excel( if not str(filename).endswith(".xlsx"): filename += ".xlsx" - writer(filename, skeleton_object, title) + writer(filename, skeleton_model, title) return filename def save_metadata_to_excel( self, - object: BaseModel, + metadata_model: BaseModel, filename: Optional[str] = None, title: Optional[str] = None, metadata_type: Optional[str] = None, verbose: bool = False, ) -> str: """ - Save an Excel document of the given metadata object. + Save an Excel document of the given metadata model. Args: - object (BaseModel): The pydantic object to save to the Excel file. + metadata_model (BaseModel): The pydantic model to save to the Excel file. filename (Optional[str]): The path to the Excel file. Defaults to {name}_metadata.xlsx title (Optional[str]): The title for the Excel sheet. Defaults to '{name} Metadata' metadata_type (Optional[str]): The name of the metadata type such as 'geospatial', 'document', etc. Used if @@ -274,19 +282,19 @@ def save_metadata_to_excel( str: filename of metadata file Outputs: - An Excel file containing the metadata from the pydantic object. This file can be updated as needed. + An Excel file containing the metadata from the pydantic model. This file can be updated as needed. """ if ( metadata_type is not None - # and object not in self._TYPE_TO_SCHEMA.values() - and type(object) not in self._TYPE_TO_SCHEMA.values() + # and metadata_model not in self._TYPE_TO_SCHEMA.values() + and type(metadata_model) not in self._TYPE_TO_SCHEMA.values() ): metadata_type = self.standardize_metadata_name(metadata_type) _, _, writer = self._get_name_schema_writer(metadata_type) - metadata_name, schema, _ = self._get_name_schema_writer(type(object)) + metadata_name, schema, _ = self._get_name_schema_writer(type(metadata_model)) else: - metadata_name, schema, writer = self._get_name_schema_writer(type(object)) - skeleton_object = self.create_metadata_outline(metadata_name_or_class=schema, debug=False) + metadata_name, schema, writer = self._get_name_schema_writer(type(metadata_model)) + skeleton_model = self.create_metadata_outline(metadata_name_or_class=schema, debug=False) if filename is None: filename = f"{metadata_name}_metadata.xlsx" @@ -296,8 +304,8 @@ def save_metadata_to_excel( title = f"{metadata_name.capitalize()} Metadata" combined_dict = merge_dicts( - skeleton_object.model_dump(), - object.model_dump(exclude_none=False, exclude_unset=True, exclude_defaults=True), + skeleton_model.model_dump(), + metadata_model.model_dump(exclude_none=False, exclude_unset=True, exclude_defaults=True), skeleton_mode=True, ) combined_dict = standardize_keys_in_dict(combined_dict) @@ -314,10 +322,10 @@ def get_metadata_type_info_from_excel_file(filename: str) -> str: sheet = workbook["metadata"] # Get the value of cell C1 type_info = sheet["C1"].value - except KeyError: - raise ValueError(f"Sheet 'metadata' not found. {error_message}") + except KeyError as e: + raise ValueError(f"Sheet 'metadata' not found. {error_message}") from e except Exception as e: - raise ValueError(f"Error reading Excel file: {e}") + raise ValueError("Error reading Excel file:") from e finally: # Close the workbook workbook.close() @@ -334,7 +342,7 @@ def read_metadata_from_excel( verbose: bool = False, ) -> BaseModel: """ - Read in metadata from an appropriately formatted Excel file as a pydantic object. + Read in metadata from an appropriately formatted Excel file as a pydantic model. If using standard metadata types (document, geospatial, image, indicator, indicators_db, microdata, resource, script, table, video) then there is no need to pass in the metadata_class. But if using a template, then the class should be provided to avoid compatability issues. Args: @@ -344,7 +352,7 @@ def read_metadata_from_excel( Returns: - BaseModel: a pydantic object containing the metadata from the file + BaseModel: a pydantic model containing the metadata from the file Raises: ValueError: If the metadata type is not supported or if the Excel file is improperly formatted @@ -363,27 +371,32 @@ def read_metadata_from_excel( if metadata_class.__metadata_type__ != metadata_name: warnings.warn( f"metadata_class metadata type {metadata_class.__metadata_type__} does not match the Excel file metadata type {metadata_name}" - "this may cause compatability issues" + "this may cause compatability issues", + stacklevel=1, ) elif metadata_class.__metadata_type_version__ != metadata_version: warnings.warn( f"metadata_class metadata version {metadata_class.__metadata_type_version__} does not match the Excel file metadata version {metadata_version}" - "this may cause issues" + "this may cause issues", + stacklevel=1, ) elif metadata_class.__template_uid__ is not None and template_uid is None: warnings.warn( f"metadata_class template_uid {metadata_class.__template_uid__} does not match the Excel file which is not from a template" - "this may cause compatability issues" + "this may cause compatability issues", + stacklevel=1, ) elif metadata_class.__template_uid__ is not None and metadata_class.__template_uid__ != template_uid: warnings.warn( f"metadata_class template_uid {metadata_class.__template_uid__} does not match the Excel file template_uid {metadata_type_info.get('template_uid', None)}" - "this may cause compatability issues" + "this may cause compatability issues", + stacklevel=1, ) elif metadata_class.__template_uid__ is None and template_uid is not None: warnings.warn( - f"metadata_class is not a template type but the Excel file is from a template" - "this may cause compatability issues" + "metadata_class is not a template type but the Excel file is from a template" + "this may cause compatability issues", + stacklevel=1, ) metadata_name = metadata_class.__metadata_type__ else: @@ -391,8 +404,7 @@ def read_metadata_from_excel( raise ValueError( "metadata_class must be provided when reading in a template Excel file, but none was provided" ) - else: - metadata_class = self.metadata_class_from_name(metadata_name) + metadata_class = self.metadata_class_from_name(metadata_name) try: metadata_name = self.standardize_metadata_name(metadata_class.__metadata_type__) @@ -401,32 +413,32 @@ def read_metadata_from_excel( reader = excel_single_sheet_to_pydantic warnings.warn( f"metadata_class metadata type {metadata_class.__metadata_type__} is not a standard type" - "falling back to excel_single_sheet_to_pydantic" + "falling back to excel_single_sheet_to_pydantic", + stacklevel=1, ) - read_object = reader(filename, metadata_class, verbose=verbose) + read_model = reader(filename, metadata_class, verbose=verbose) - skeleton_object = self.create_metadata_outline(metadata_name_or_class=metadata_class, debug=verbose) + skeleton_model = self.create_metadata_outline(metadata_name_or_class=metadata_class, debug=verbose) - read_object_dict = read_object.model_dump( + read_model_dict = read_model.model_dump( mode="json", exclude_none=False, exclude_unset=True, exclude_defaults=True ) if verbose: - print("read object dict", read_object_dict) + print("read model dict", read_model_dict) combined_dict = merge_dicts( - skeleton_object.model_dump(mode="json"), - read_object_dict, + skeleton_model.model_dump(mode="json"), + read_model_dict, skeleton_mode=True, ) combined_dict = standardize_keys_in_dict(combined_dict) - new_ob = metadata_class.model_validate(combined_dict) - return new_ob + return metadata_class.model_validate(combined_dict) def _raise_if_unsupported_metadata_name(self, metadata_name: str): """ If the type is specifically unsupported a NotImplementedError is raised If the type is simply unknown then a ValueError is raised. """ - if metadata_name not in self._TYPE_TO_SCHEMA.keys(): + if metadata_name not in self._TYPE_TO_SCHEMA: raise ValueError(f"'{metadata_name}' not supported. Must be: {list(self._TYPE_TO_SCHEMA.keys())}") diff --git a/pydantic_schemas/microdata_schema.py b/pydantic_schemas/microdata_schema.py index 257ef92..fbbd05f 100644 --- a/pydantic_schemas/microdata_schema.py +++ b/pydantic_schemas/microdata_schema.py @@ -43,10 +43,7 @@ class DatafileSchema(SchemaBaseModel): file_name: str = Field(..., title="File name") file_type: Optional[str] = Field( None, - description=( - "Types of data files include raw data (ASCII, EBCDIC, etc.) and software-dependent files such as SAS" - " datasets, SPSS export files, etc." - ), + description="Types of data files include raw data (ASCII, EBCDIC, etc.) and software-dependent files such as SAS datasets, SPSS export files, etc.", title="File type", ) description: Optional[str] = Field(None, title="File description") @@ -71,20 +68,28 @@ class VarIntrvl(Enum): class VarSumstatItem(SchemaBaseModel): type: Optional[str] = Field(None, title="Type") value: Optional[Union[int, str]] = Field(None, title="Value") - wgtd: Optional[str] = Field(None, description="For weighted values, enter `weighted`", title="Weighted") + wgtd: Optional[str] = Field( + None, description="For weighted values, enter `weighted`", title="Weighted" + ) class Stat(SchemaBaseModel): - type: Optional[str] = Field(None, description="Type such as frequency, percent, etc", title="Type") + type: Optional[str] = Field( + None, description="Type such as frequency, percent, etc", title="Type" + ) value: Optional[Union[int, str]] = Field(None, title="Value") - wgtd: Optional[str] = Field(None, description="For weighted values, enter `weighted`", title="Weighted") + wgtd: Optional[str] = Field( + None, description="For weighted values, enter `weighted`", title="Weighted" + ) class VarCatgryItem(SchemaBaseModel): value: Optional[str] = Field(None, title="Value") label: Optional[str] = Field(None, title="Label") stats: Optional[List[Stat]] = Field( - None, description="Category level statistics e.g. frequency", title="Category statistics" + None, + description="Category level statistics e.g. frequency", + title="Category statistics", ) @@ -116,40 +121,42 @@ class VarFormat(SchemaBaseModel): class VariableSchema(SchemaBaseModel): - file_id: str = Field(..., description="File to which the variable belongs", title="File ID e.g. F1") - vid: str = Field(..., description="Unique variable ID e.g. V1, V2", title="Variable unique ID") + file_id: str = Field( + ..., description="File to which the variable belongs", title="File ID e.g. F1" + ) + vid: str = Field( + ..., description="Unique variable ID e.g. V1, V2", title="Variable unique ID" + ) name: str = Field(..., title="Variable name") labl: str = Field(..., title="Variable label") var_intrvl: Optional[VarIntrvl] = Field( - None, description="indicates the interval type; options are discrete or continuous.", title="Interval type" + None, + description="indicates the interval type; options are discrete or continuous.", + title="Interval type", ) var_dcml: Optional[str] = Field( - None, description="Number of decimal points in the variable", title="Variable decimal points" + None, + description="Number of decimal points in the variable", + title="Variable decimal points", + ) + var_wgt: Optional[int] = Field( + 0, description="indicates whether the variable is a weight", title="Weight" ) - var_wgt: Optional[int] = Field(0, description="indicates whether the variable is a weight", title="Weight") loc_start_pos: Optional[int] = Field(None, title="Variable start position") loc_end_pos: Optional[int] = Field(None, title="Variable end position") loc_width: Optional[int] = Field(None, title="Variable width") loc_rec_seg_no: Optional[int] = Field( - None, title="Record segment number, deck or card number the variable is located on" + None, + title="Record segment number, deck or card number the variable is located on", ) var_imputation: Optional[str] = Field( None, - description=( - "According to the Statistical Terminology glossary maintained by the National Science Foundation, this is" - " `the process by which one estimates missing values for items that a survey respondent failed to provide,`" - " and if applicable in this context, it refers to the type of procedure used. " - ), + description="According to the Statistical Terminology glossary maintained by the National Science Foundation, this is `the process by which one estimates missing values for items that a survey respondent failed to provide,` and if applicable in this context, it refers to the type of procedure used. ", title="Imputation", ) var_derivation: Optional[str] = Field( None, - description=( - "Used only in the case of a derived variable, this element provides both a description of how the" - " derivation was performed and the command used to generate the derived variable, as well as a" - " specification of the other variables in the study used to generate the derivation. The `var` attribute" - " provides the ID values of the other variables in the study used to generate this derived variable." - ), + description="Used only in the case of a derived variable, this element provides both a description of how the derivation was performed and the command used to generate the derived variable, as well as a specification of the other variables in the study used to generate the derivation. The `var` attribute provides the ID values of the other variables in the study used to generate this derived variable.", title="Derivation", ) var_security: Optional[str] = Field(None, title="Security") @@ -163,55 +170,32 @@ class VariableSchema(SchemaBaseModel): var_qstn_postqtxt: Optional[str] = Field(None, title="Post-question text") var_forward: Optional[str] = Field( None, - description=( - "Contains a reference to IDs of possible following questions. This can be used to document forward skip" - " instructions." - ), + description="Contains a reference to IDs of possible following questions. This can be used to document forward skip instructions.", title="Forward skip", ) var_backward: Optional[str] = Field( None, - description=( - "Contains a reference to IDs of possible preceding questions. This can be used to document backward skip" - " instructions." - ), + description="Contains a reference to IDs of possible preceding questions. This can be used to document backward skip instructions.", title="Backward skip", ) var_qstn_ivulnstr: Optional[str] = Field(None, title="Interviewer instructions") var_universe: Optional[str] = Field(None, title="Universe") var_sumstat: Optional[List[VarSumstatItem]] = Field( None, - description=( - "One or more statistical measures that describe the responses to a particular variable and may include one" - " or more standard summaries, e.g., minimum and maximum values, median, mode, etc. \n\n The attribute" - " 'type' denotes the type of statistics being shown: mean, median, mode, valid cases, invalid cases," - " minimum, maximum, or standard deviation." - ), + description="One or more statistical measures that describe the responses to a particular variable and may include one or more standard summaries, e.g., minimum and maximum values, median, mode, etc. \n\n The attribute 'type' denotes the type of statistics being shown: mean, median, mode, valid cases, invalid cases, minimum, maximum, or standard deviation.", ) var_txt: Optional[str] = Field(None, title="Variable description") var_catgry: Optional[List[VarCatgryItem]] = Field(None, title="Categories") var_std_catgry: Optional[VarStdCatgry] = Field( None, - description=( - "Standard category codes used in the variable, like industry codes, employment codes, or social class" - " codes. The attribute `date` is provided to indicate the version of the code in place at the time of the" - " study. The attribute `URI` is provided to indicate a URN or URL that can be used to obtain an electronic" - " list of the category codes." - ), + description="Standard category codes used in the variable, like industry codes, employment codes, or social class codes. The attribute `date` is provided to indicate the version of the code in place at the time of the study. The attribute `URI` is provided to indicate a URN or URL that can be used to obtain an electronic list of the category codes.", title="Standard categories", ) var_codinstr: Optional[str] = Field(None, title="Recoding and derivation") var_concept: Optional[List[VarConceptItem]] = Field(None, title="Concepts") var_format: Optional[VarFormat] = Field( None, - description=( - "The technical format of the variable in question. Attributes for this element include: 'type', which" - " indicates if the variable is character or numeric; 'formatname,' which in some cases may provide the name" - " of the particular, proprietary format actually used; 'schema,' which identifies the vendor or standards" - " body that defined the format (acceptable choices are SAS, SPSS, IBM, ANSI, ISO, XML-data or other);" - " 'category,' which describes what kind of data the format represents, and includes date, time, currency," - " or 'other' conceptual possibilities." - ), + description="The technical format of the variable in question. Attributes for this element include: 'type', which indicates if the variable is character or numeric; 'formatname,' which in some cases may provide the name of the particular, proprietary format actually used; 'schema,' which identifies the vendor or standards body that defined the format (acceptable choices are SAS, SPSS, IBM, ANSI, ISO, XML-data or other); 'category,' which describes what kind of data the format represents, and includes date, time, currency, or 'other' conceptual possibilities.", title="Variable format", ) var_notes: Optional[str] = Field(None, title="Variable notes") @@ -236,10 +220,14 @@ class GroupType(Enum): class VariableGroupSchema(SchemaBaseModel): vgid: constr(max_length=45) = Field( - ..., description="Unique ID for the variable group e.g. VG1", title="Variable Group ID" + ..., + description="Unique ID for the variable group e.g. VG1", + title="Variable Group ID", ) variables: Optional[constr(max_length=5000)] = Field( - None, description="List of variables for the group seperated by space e.g. V1 V2 V3", title="Variables" + None, + description="List of variables for the group seperated by space e.g. V1 V2 V3", + title="Variables", ) variable_groups: Optional[constr(max_length=1000)] = Field( None, description="List of sub-groups e.g. VG2 VG3 VG4", title="Variable groups" @@ -282,11 +270,17 @@ class DocDesc(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) prod_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version_statement: Optional[VersionStatement] = Field( None, description="Version Statement", title="Version Statement" @@ -295,7 +289,9 @@ class DocDesc(SchemaBaseModel): class Identifier(SchemaBaseModel): type: Optional[str] = Field( - None, description="Type of identifier e.g. `doi`, `handle`, `other`", title="Identifier type" + None, + description="Type of identifier e.g. `doi`, `handle`, `other`", + title="Identifier type", ) identifier: str = Field(..., title="Identifier") @@ -307,35 +303,23 @@ class TitleStatement(SchemaBaseModel): idno: str = Field( ..., - description=( - "The ID number of a dataset is a unique number that is used to identify a particular survey. Define and use" - " a consistent scheme to use. Such an ID could be constructed as follows:" - " country-producer-survey-year-version where \n - country is the 3-letter ISO country abbreviation \n -" - " producer is the abbreviation of the producing agency \n - survey is the survey abbreviation \n - year is" - " the reference year (or the year the survey started) \n - version is the number dataset version number" - " (see Version Description below)" - ), + description="The ID number of a dataset is a unique number that is used to identify a particular survey. Define and use a consistent scheme to use. Such an ID could be constructed as follows: country-producer-survey-year-version where \n - country is the 3-letter ISO country abbreviation \n - producer is the abbreviation of the producing agency \n - survey is the survey abbreviation \n - year is the reference year (or the year the survey started) \n - version is the number dataset version number (see Version Description below)", title="Unique user defined ID", ) - identifiers: Optional[List[Identifier]] = Field(None, description="Other identifiers", title="Other identifiers") + identifiers: Optional[List[Identifier]] = Field( + None, description="Other identifiers", title="Other identifiers" + ) title: str = Field( ..., - description=( - "The title is the official name of the survey as it is stated on the questionnaire or as it appears in the" - " design documents. The following items should be noted:\n - Include the reference year(s) of the survey in" - " the title. \n - Do not include the abbreviation of the survey name in the title. \n - As the survey title" - " is a proper noun, the first letter of each word should be capitalized (except for prepositions or other" - " conjunctions).\n - Including the country name in the title is optional." - ), + description="The title is the official name of the survey as it is stated on the questionnaire or as it appears in the design documents. The following items should be noted:\n - Include the reference year(s) of the survey in the title. \n - Do not include the abbreviation of the survey name in the title. \n - As the survey title is a proper noun, the first letter of each word should be capitalized (except for prepositions or other conjunctions).\n - Including the country name in the title is optional.", title="Survey title", ) - sub_title: Optional[str] = Field(None, description="A short subtitle for the survey", title="Survey subtitle") + sub_title: Optional[str] = Field( + None, description="A short subtitle for the survey", title="Survey subtitle" + ) alternate_title: Optional[str] = Field( None, - description=( - "The abbreviation of a survey is usually the first letter of each word of the titled survey. The survey" - " reference year(s) may be included." - ), + description="The abbreviation of a survey is usually the first letter of each word of the titled survey. The survey reference year(s) may be included.", title="Abbreviation or Acronym", ) translated_title: Optional[str] = Field( @@ -368,26 +352,23 @@ class ProductionStatement(SchemaBaseModel): Production Statement """ - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) copyright: Optional[str] = Field(None, title="Copyright") prod_date: Optional[str] = Field( None, - description=( - "Date when the marked-up document/marked-up document source/data collection/other material(s) were produced" - " (not distributed or archived). The ISO standard for dates (YYYY-MM-DD) is recommended for use with the" - " date attribute. Production date for data collection (2.1.3.3) maps to Dublin Core Date element." - ), + description="Date when the marked-up document/marked-up document source/data collection/other material(s) were produced (not distributed or archived). The ISO standard for dates (YYYY-MM-DD) is recommended for use with the date attribute. Production date for data collection (2.1.3.3) maps to Dublin Core Date element.", title="Production Date", ) prod_place: Optional[str] = Field( - None, description="Address of the archive or organization that produced the work", title="Production Place" + None, + description="Address of the archive or organization that produced the work", + title="Production Place", ) funding_agencies: Optional[List[FundingAgency]] = Field( None, - description=( - "The source(s) of funds for production of the work. If different funding agencies sponsored different" - " stages of the production process, use the 'role' attribute to distinguish them." - ), + description="The source(s) of funds for production of the work. If different funding agencies sponsored different stages of the production process, use the 'role' attribute to distinguish them.", title="Funding Agency/Sponsor", ) @@ -420,16 +401,15 @@ class DistributionStatement(SchemaBaseModel): distributors: Optional[List[Distributor]] = Field( None, - description=( - "The organization designated by the author or producer to generate copies of the particular work including" - " any necessary editions or revisions. Names and addresses may be specified and other archives may be" - " co-distributors. A URI attribute is included to provide an URN or URL to the ordering service or download" - " facility on a Web site." - ), + description="The organization designated by the author or producer to generate copies of the particular work including any necessary editions or revisions. Names and addresses may be specified and other archives may be co-distributors. A URI attribute is included to provide an URN or URL to the ordering service or download facility on a Web site.", title="Distributor", ) - contact: Optional[List[ContactItem]] = Field(None, description="Contact", title="Contact") - depositor: Optional[List[DepositorItem]] = Field(None, description="Depositor", title="Depositor") + contact: Optional[List[ContactItem]] = Field( + None, description="Contact", title="Contact" + ) + depositor: Optional[List[DepositorItem]] = Field( + None, description="Depositor", title="Depositor" + ) deposit_date: Optional[str] = Field(None, title="Date of Deposit") distribution_date: Optional[str] = Field(None, title="Date of Distribution") @@ -440,17 +420,13 @@ class SeriesStatement(SchemaBaseModel): """ series_name: Optional[str] = Field( - None, description="The name of the series to which the work belongs.", title="Series Name" + None, + description="The name of the series to which the work belongs.", + title="Series Name", ) series_info: Optional[str] = Field( None, - description=( - "A survey may be repeated at regular intervals (such as an annual labour force survey), or be part of an" - " international survey program (such as the MICS, CWIQ, DHS, LSMS and others). The Series information is a" - " description of this `collection` of surveys. A brief description of the characteristics of the survey," - " including when it started, how many rounds were already implemented, and who is in charge would be" - " provided here." - ), + description="A survey may be repeated at regular intervals (such as an annual labour force survey), or be part of an international survey program (such as the MICS, CWIQ, DHS, LSMS and others). The Series information is a description of this `collection` of surveys. A brief description of the characteristics of the survey, including when it started, how many rounds were already implemented, and who is in charge would be provided here.", title="Series Information", ) @@ -476,10 +452,7 @@ class StudyAuthorization(SchemaBaseModel): date: Optional[str] = Field(None, title="Authorization Date") agency: Optional[List[AgencyItem]] = Field( None, - description=( - "The source(s) of funds for production of the work. If different funding agencies sponsored different" - " stages of the production process, use the 'role' attribute to distinguish them." - ), + description="The source(s) of funds for production of the work. If different funding agencies sponsored different stages of the production process, use the 'role' attribute to distinguish them.", title="Authorizing Agency", ) authorization_statement: Optional[str] = Field( @@ -511,7 +484,9 @@ class CollDate(TimePeriod): class NationItem(SchemaBaseModel): name: str = Field(..., description="Country name", title="Name") - abbreviation: Optional[str] = Field(None, description="Country ISO code", title="Country code") + abbreviation: Optional[str] = Field( + None, description="Country ISO code", title="Country code" + ) class BboxItem(SchemaBaseModel): @@ -524,18 +499,12 @@ class BboxItem(SchemaBaseModel): class BoundPolyItem(SchemaBaseModel): lat: Optional[str] = Field( None, - description=( - "Latitude (y coordinate) of a point. Valid range expressed in decimal degrees is as follows: -90,0 to 90,0" - " degrees (latitude)" - ), + description="Latitude (y coordinate) of a point. Valid range expressed in decimal degrees is as follows: -90,0 to 90,0 degrees (latitude)", title="Latitude", ) lon: Optional[str] = Field( None, - description=( - "Longitude (x coordinate) of a point. Valid range expressed in decimal degrees is as follows: -180,0 to" - " 180,0 degrees (longitude)" - ), + description="Longitude (x coordinate) of a point. Valid range expressed in decimal degrees is as follows: -180,0 to 180,0 degrees (longitude)", title="longitude", ) @@ -550,9 +519,15 @@ class QualityStatement(SchemaBaseModel): The quality statement provides elements to describe compliance with quality standards in the form of a statement and an itemized list of standards complied with, and an element to provide other quality statement. """ - compliance_description: Optional[str] = Field(None, title="Standard compliance description") - standards: Optional[List[Standard]] = Field(None, description="Standards", title="Standards") - other_quality_statement: Optional[str] = Field(None, title="Other quality statement") + compliance_description: Optional[str] = Field( + None, title="Standard compliance description" + ) + standards: Optional[List[Standard]] = Field( + None, description="Standards", title="Standards" + ) + other_quality_statement: Optional[str] = Field( + None, title="Other quality statement" + ) class EvaluatorItem(SchemaBaseModel): @@ -569,7 +544,9 @@ class ExPostEvaluation(SchemaBaseModel): completion_date: Optional[str] = Field(None, title="Evaluation completion date") type: Optional[str] = Field(None, title="Evaluation type") - evaluator: Optional[List[EvaluatorItem]] = Field(None, description="Evaluators", title="Evaluators") + evaluator: Optional[List[EvaluatorItem]] = Field( + None, description="Evaluators", title="Evaluators" + ) evaluation_process: Optional[str] = Field(None, title="Evaluation process") outcomes: Optional[str] = Field(None, title="Outcomes") @@ -581,16 +558,13 @@ class StudyInfo(SchemaBaseModel): study_budget: Optional[str] = Field( None, - description=( - "Provide a clear summary of the pDescribe the budget of the project in as much detail as needed. Use XHTML" - " structure elements to identify discrete pieces of information in a way that facilitates direct transfer" - " of information on the study budget between DDI 2 and DDI 3 structures.urposes, objectives and content of" - " the survey" - ), + description="Provide a clear summary of the pDescribe the budget of the project in as much detail as needed. Use XHTML structure elements to identify discrete pieces of information in a way that facilitates direct transfer of information on the study budget between DDI 2 and DDI 3 structures.urposes, objectives and content of the survey", title="Study Budget", ) keywords: Optional[List[Keyword]] = Field(None, description="Keywords") - topics: Optional[List[Topic]] = Field(None, description="Topic Classification", title="Topic Classification") + topics: Optional[List[Topic]] = Field( + None, description="Topic Classification", title="Topic Classification" + ) abstract: Optional[str] = Field( None, description="Provide a clear summary of the purposes, objectives and content of the survey", @@ -598,98 +572,60 @@ class StudyInfo(SchemaBaseModel): ) time_periods: Optional[List[TimePeriod]] = Field( None, - description=( - "This field will usually be left empty. Time period differs from the dates of collection as they represent" - " the period for which the data collected are applicable or relevant." - ), + description="This field will usually be left empty. Time period differs from the dates of collection as they represent the period for which the data collected are applicable or relevant.", title="Time periods (YYYY/MM/DD)", ) coll_dates: Optional[List[CollDate]] = Field( None, - description=( - "Enter the dates (at least month and year) of the start and end of the data collection. In some cases, data" - " collection for a same survey can be conducted in waves. In such case, you should enter the start and end" - " date of each wave separately, and identify each wave in the 'cycle' field." - ), + description="Enter the dates (at least month and year) of the start and end of the data collection. In some cases, data collection for a same survey can be conducted in waves. In such case, you should enter the start and end date of each wave separately, and identify each wave in the 'cycle' field.", title="Dates of Data Collection (YYYY/MM/DD)", ) nation: List[NationItem] = Field( ..., - description=( - "Indicates the country or countries covered in the file. Field `abbreviation` may be used to list common" - " abbreviations; use of ISO country codes is recommended. Maps to Dublin Core Coverage element. Inclusion" - " of this element is recommended." - ), + description="Indicates the country or countries covered in the file. Field `abbreviation` may be used to list common abbreviations; use of ISO country codes is recommended. Maps to Dublin Core Coverage element. Inclusion of this element is recommended.", title="Country", ) bbox: Optional[List[BboxItem]] = Field(None, title="Geographic bounding box") bound_poly: Optional[List[BoundPolyItem]] = Field( None, - description=( - "This field allows the creation of multiple polygons to describe in a more detailed manner the geographic" - " area covered by the dataset. It should only be used to define the outer boundaries of a covered area. For" - " example, in the United States, such polygons can be created to define boundaries for Hawaii, Alaska, and" - " the continental United States, but not interior boundaries for the contiguous states. This field is used" - " to refine a coordinate-based search, not to actually map an area. \nIf the boundPoly element is used," - " then geoBndBox MUST be present, and all points enclosed by the boundPoly MUST be contained within the" - " geoBndBox. Elements westBL, eastBL, southBL, and northBL of the geoBndBox should each be represented in" - " at least one point of the boundPoly description." - ), + description="This field allows the creation of multiple polygons to describe in a more detailed manner the geographic area covered by the dataset. It should only be used to define the outer boundaries of a covered area. For example, in the United States, such polygons can be created to define boundaries for Hawaii, Alaska, and the continental United States, but not interior boundaries for the contiguous states. This field is used to refine a coordinate-based search, not to actually map an area. \nIf the boundPoly element is used, then geoBndBox MUST be present, and all points enclosed by the boundPoly MUST be contained within the geoBndBox. Elements westBL, eastBL, southBL, and northBL of the geoBndBox should each be represented in at least one point of the boundPoly description.", title="Geographic Bounding Polygon", ) geog_coverage: Optional[str] = Field( None, - description=( - " Information on the geographic coverage of the data. Includes the total geographic scope of the data, and" - " any additional levels of geographic coding provided in the variables. Maps to Dublin Core Coverage" - " element. Inclusion of this element in the codebook is recommended." - ), + description=" Information on the geographic coverage of the data. Includes the total geographic scope of the data, and any additional levels of geographic coding provided in the variables. Maps to Dublin Core Coverage element. Inclusion of this element in the codebook is recommended.", title="Geographic Coverage", ) geog_coverage_notes: Optional[str] = Field( None, description="Geographic coverage notes", title="Geographic Coverage notes" ) geog_unit: Optional[str] = Field( - None, description="Lowest level of geographic aggregation covered by the data", title="Geographic Unit" + None, + description="Lowest level of geographic aggregation covered by the data", + title="Geographic Unit", ) analysis_unit: Optional[str] = Field( None, - description=( - "Basic unit(s) of analysis or observation that the study describes: individuals, families/households," - " groups, facilities, institutions/organizations, administrative units, physical locations, etc." - ), + description="Basic unit(s) of analysis or observation that the study describes: individuals, families/households, groups, facilities, institutions/organizations, administrative units, physical locations, etc.", title="Unit of Analysis", ) universe: Optional[str] = Field( None, - description=( - "We are interested here in the survey universe (not the universe of particular sections of the" - " questionnaires or variables), i.e. in the identification of the population of interest in the survey. The" - " universe will rarely be the entire population of the country. Sample household surveys, for example," - " usually do not cover homeless, nomads, diplomats, community households. Some surveys may cover only the" - " population of a particular age group, or only male (or female), etc." - ), + description="We are interested here in the survey universe (not the universe of particular sections of the questionnaires or variables), i.e. in the identification of the population of interest in the survey. The universe will rarely be the entire population of the country. Sample household surveys, for example, usually do not cover homeless, nomads, diplomats, community households. Some surveys may cover only the population of a particular age group, or only male (or female), etc.", title="Universe", ) - data_kind: Optional[str] = Field(None, description="Broad classification of the data", title="Kind of Data") + data_kind: Optional[str] = Field( + None, description="Broad classification of the data", title="Kind of Data" + ) notes: Optional[str] = Field(None, description="Study notes", title="Study notes") quality_statement: Optional[QualityStatement] = Field( None, - description=( - "The quality statement provides elements to describe compliance with quality standards in the form of a" - " statement and an itemized list of standards complied with, and an element to provide other quality" - " statement." - ), + description="The quality statement provides elements to describe compliance with quality standards in the form of a statement and an itemized list of standards complied with, and an element to provide other quality statement.", title="Quality Statement", ) ex_post_evaluation: Optional[ExPostEvaluation] = Field( None, - description=( - "This structure consists of two parts, standardsCompliance and otherQualityStatements. In" - " standardsCompliance list all specific standards complied with during the execution of this study. Note" - " the standard name and producer and how the study complied with the standard. Enter any additional quality" - " statements in otherQualityStatements." - ), + description="This structure consists of two parts, standardsCompliance and otherQualityStatements. In standardsCompliance list all specific standards complied with during the execution of this study. Note the standard name and producer and how the study complied with the standard. Enter any additional quality statements in otherQualityStatements.", title="Ex-Post Evaluation", ) @@ -701,13 +637,12 @@ class Participant(SchemaBaseModel): class Resource(SchemaBaseModel): - name: Optional[str] = Field(None, description="Name of the resource", title="Resource name") + name: Optional[str] = Field( + None, description="Name of the resource", title="Resource name" + ) origin: Optional[str] = Field( None, - description=( - "For historical materials, information about the origin(s) of the sources and the rules followed in" - " establishing the sources should be specified. May not be relevant to survey data. " - ), + description="For historical materials, information about the origin(s) of the sources and the rules followed in establishing the sources should be specified. May not be relevant to survey data. ", title="Origin of resource", ) characteristics: Optional[str] = Field( @@ -719,13 +654,21 @@ class Resource(SchemaBaseModel): class DevelopmentActivityItem(SchemaBaseModel): activity_type: Optional[str] = Field(None, title="Development activity type") - activity_description: Optional[str] = Field(None, title="Development activity description") - participants: Optional[List[Participant]] = Field(None, description="Participants", title="Participants") + activity_description: Optional[str] = Field( + None, title="Development activity description" + ) + participants: Optional[List[Participant]] = Field( + None, description="Participants", title="Participants" + ) resources: Optional[List[Resource]] = Field( - None, description="Development activity resources", title="Development activity resources" + None, + description="Development activity resources", + title="Development activity resources", ) outcome: Optional[str] = Field( - None, description="Development Activity Outcome", title="Development Activity Outcome" + None, + description="Development Activity Outcome", + title="Development Activity Outcome", ) @@ -734,7 +677,9 @@ class StudyDevelopment(SchemaBaseModel): Describe the process of study development as a series of development activities. These activities can be typed using a controlled vocabulary. Describe the activity, listing participants with their role and affiliation, resources used (sources of information), and the outcome of the development activity. """ - development_activity: Optional[List[DevelopmentActivityItem]] = Field(None, title="Development activity") + development_activity: Optional[List[DevelopmentActivityItem]] = Field( + None, title="Development activity" + ) class DataCollector(SchemaBaseModel): @@ -746,13 +691,19 @@ class DataCollector(SchemaBaseModel): class CollectorTrainingItem(SchemaBaseModel): type: Optional[str] = Field( - None, description="The percentage of sample members who provided information", title="Training type" + None, + description="The percentage of sample members who provided information", + title="Training type", + ) + training: Optional[str] = Field( + None, description="Training provided to data collectors", title="Training" ) - training: Optional[str] = Field(None, description="Training provided to data collectors", title="Training") class ValidPeriodItem(SchemaBaseModel): - event: Optional[str] = Field(None, description="Event e.g. start, end", title="Event") + event: Optional[str] = Field( + None, description="Event e.g. start, end", title="Event" + ) date: str = Field(..., description="Date", title="Date") @@ -761,17 +712,18 @@ class FrameUnit(SchemaBaseModel): Provides information about the sampling frame unit. The attribute `isPrimary` is boolean, indicating whether the unit is primary or not. """ - is_primary: Optional[Union[bool, str]] = Field(None, description="Is a primary unit?", title="Is Primary") + is_primary: Optional[Union[bool, str]] = Field( + None, description="Is a primary unit?", title="Is Primary" + ) unit_type: Optional[str] = Field( None, - description=( - "Describes the type of sampling frame unit. The field `num_of_units` provides the number of units in the" - " sampling frame." - ), + description="Describes the type of sampling frame unit. The field `num_of_units` provides the number of units in the sampling frame.", title="Unit Type", ) num_of_units: Optional[str] = Field( - None, description="Number of units in the sampling frame", title="Number of units" + None, + description="Number of units in the sampling frame", + title="Number of units", ) @@ -784,7 +736,9 @@ class SampleFrame(SchemaBaseModel): Sample frame describes the sampling frame used for identifying the population from which the sample was taken. For example, a telephone book may be a sample frame for a phone survey. In addition to the name, label and text describing the sample frame, this structure lists who maintains the sample frame, the period for which it is valid, a use statement, the universe covered, the type of unit contained in the frame as well as the number of units available, the reference period of the frame and procedures used to update the frame. """ - name: Optional[str] = Field(None, description="Sample frame name", title="Sample frame name") + name: Optional[str] = Field( + None, description="Sample frame name", title="Sample frame name" + ) valid_period: Optional[List[ValidPeriodItem]] = Field( None, description="Defines a time period for the validity of the sampling frame. Enter dates in YYYY-MM-DD format.", @@ -792,34 +746,22 @@ class SampleFrame(SchemaBaseModel): ) custodian: Optional[str] = Field( None, - description=( - "Custodian identifies the agency or individual who is responsible for creating or maintaining the sample" - " frame." - ), + description="Custodian identifies the agency or individual who is responsible for creating or maintaining the sample frame.", title="Custodian", ) universe: Optional[str] = Field( None, - description=( - "The group of persons or other elements that are the object of research and to which any analytic results" - " refer." - ), + description="The group of persons or other elements that are the object of research and to which any analytic results refer.", title="Universe", ) frame_unit: Optional[FrameUnit] = Field( None, - description=( - "Provides information about the sampling frame unit. The attribute `isPrimary` is boolean, indicating" - " whether the unit is primary or not." - ), + description="Provides information about the sampling frame unit. The attribute `isPrimary` is boolean, indicating whether the unit is primary or not.", title="Frame unit", ) reference_period: Optional[List[ReferencePeriodItem]] = Field( None, - description=( - "Indicates the period of time in which the sampling frame was actually used for the study in question. Use" - " ISO 8601 date/time formats to enter the relevant date(s)." - ), + description="Indicates the period of time in which the sampling frame was actually used for the study in question. Use ISO 8601 date/time formats to enter the relevant date(s).", title="Reference periods (YYYY/MM/DD)", ) update_procedure: Optional[str] = Field( @@ -830,13 +772,12 @@ class SampleFrame(SchemaBaseModel): class Source(SchemaBaseModel): - name: Optional[str] = Field(None, description="Name of the source", title="Source name") + name: Optional[str] = Field( + None, description="Name of the source", title="Source name" + ) origin: Optional[str] = Field( None, - description=( - "For historical materials, information about the origin(s) of the sources and the rules followed in" - " establishing the sources should be specified. May not be relevant to survey data. " - ), + description="For historical materials, information about the origin(s) of the sources and the rules followed in establishing the sources should be specified. May not be relevant to survey data. ", title="Origin of Source", ) characteristics: Optional[str] = Field( @@ -853,143 +794,82 @@ class DataCollection(SchemaBaseModel): time_method: Optional[str] = Field( None, - description=( - "The time method or time dimension of the data collection. Examples: `panel survey`, `h>cross-section`," - " `trend study`, `time-series`" - ), + description="The time method or time dimension of the data collection. Examples: `panel survey`, `h>cross-section`, `trend study`, `time-series`", title="Time Method", ) data_collectors: Optional[List[DataCollector]] = Field( None, - description=( - "The persons and/or agencies that took charge of the data collection. This element includes 3 fields: Name," - " Abbreviation and the Affiliation. In most cases, we will record here the name of the agency, not the name" - " of interviewers. Only in the case of very small-scale surveys, with a very limited number of" - " interviewers, the name of person will be included as well. The field Affiliation is optional and not" - " relevant in all cases." - ), + description="The persons and/or agencies that took charge of the data collection. This element includes 3 fields: Name, Abbreviation and the Affiliation. In most cases, we will record here the name of the agency, not the name of interviewers. Only in the case of very small-scale surveys, with a very limited number of interviewers, the name of person will be included as well. The field Affiliation is optional and not relevant in all cases.", title="Data Collectors", ) collector_training: Optional[List[CollectorTrainingItem]] = Field( None, - description=( - "Describes the training provided to data collectors including interviewer training, process testing," - " compliance with standards etc. This is repeatable for language and to capture different aspects of the" - " training process. The type attribute allows specification of the type of training being described." - ), + description="Describes the training provided to data collectors including interviewer training, process testing, compliance with standards etc. This is repeatable for language and to capture different aspects of the training process. The type attribute allows specification of the type of training being described.", title="Collector training", ) frequency: Optional[str] = Field( None, - description=( - "For data collected at more than one point in time, the frequency with which the data were collected." - " Examples `monthly`, `quarterly`, `yearly`" - ), + description="For data collected at more than one point in time, the frequency with which the data were collected. Examples `monthly`, `quarterly`, `yearly`", title="Frequency of Data Collection", ) sampling_procedure: Optional[str] = Field( None, - description=( - "The type of sample and sample design used to select the survey respondents to represent the population." - " \nThis field only applies to sample surveys. Information on sampling procedure is crucial (although not" - " applicable for censuses and administrative datasets). Examples `National multistage area probability" - " sample`, `Simple random sample`, `Quota sample`" - ), + description="The type of sample and sample design used to select the survey respondents to represent the population. \nThis field only applies to sample surveys. Information on sampling procedure is crucial (although not applicable for censuses and administrative datasets). Examples `National multistage area probability sample`, `Simple random sample`, `Quota sample`", title="Sampling Procedure", ) sample_frame: Optional[SampleFrame] = Field( None, - description=( - "Sample frame describes the sampling frame used for identifying the population from which the sample was" - " taken. For example, a telephone book may be a sample frame for a phone survey. In addition to the name," - " label and text describing the sample frame, this structure lists who maintains the sample frame, the" - " period for which it is valid, a use statement, the universe covered, the type of unit contained in the" - " frame as well as the number of units available, the reference period of the frame and procedures used to" - " update the frame." - ), + description="Sample frame describes the sampling frame used for identifying the population from which the sample was taken. For example, a telephone book may be a sample frame for a phone survey. In addition to the name, label and text describing the sample frame, this structure lists who maintains the sample frame, the period for which it is valid, a use statement, the universe covered, the type of unit contained in the frame as well as the number of units available, the reference period of the frame and procedures used to update the frame.", title="Sample Frame", ) sampling_deviation: Optional[str] = Field( None, - description=( - "This field only applies to sample surveys.\nSometimes the reality of the field requires a deviation from" - " the sampling design (for example due to difficulty to access to zones due to weather problems, political" - " instability, etc). If for any reason, the sample design has deviated, this should be reported here. " - ), + description="This field only applies to sample surveys.\nSometimes the reality of the field requires a deviation from the sampling design (for example due to difficulty to access to zones due to weather problems, political instability, etc). If for any reason, the sample design has deviated, this should be reported here. ", title="Deviations from the Sample Design", ) coll_mode: Optional[List[str]] = Field( None, - description=( - "The mode of data collection is the manner in which the interview was conducted or information was" - " gathered. In most cases, the response will be 'face to face interview'. But for some specific kinds of" - " datasets, such as for example data on rain fall, the response will be different." - ), + description="The mode of data collection is the manner in which the interview was conducted or information was gathered. In most cases, the response will be 'face to face interview'. But for some specific kinds of datasets, such as for example data on rain fall, the response will be different.", title="Mode of data collection", ) research_instrument: Optional[str] = Field( None, - description=( - "The type of data collection instrument used. \n`Structured` indicates an instrument in which all" - " respondents are asked the same questions/tests, possibly with precoded answers. If a small portion of" - " such a questionnaire includes open-ended questions, provide appropriate comments. \n`Semi-structured`" - " indicates that the research instrument contains mainly open-ended questions. \n`Unstructured` indicates" - " that in-depth interviews were conducted." - ), + description="The type of data collection instrument used. \n`Structured` indicates an instrument in which all respondents are asked the same questions/tests, possibly with precoded answers. If a small portion of such a questionnaire includes open-ended questions, provide appropriate comments. \n`Semi-structured` indicates that the research instrument contains mainly open-ended questions. \n`Unstructured` indicates that in-depth interviews were conducted.", title="Type of Research Instrument", ) instru_development: Optional[str] = Field( None, - description=( - "Describe any development work on the data collection instrument. Type attribute allows for the optional" - " use of a defined development type with or without use of a controlled vocabulary." - ), + description="Describe any development work on the data collection instrument. Type attribute allows for the optional use of a defined development type with or without use of a controlled vocabulary.", title="Instrument development", ) instru_development_type: Optional[str] = Field( - None, description="Instrument development type", title="Instrument development type" + None, + description="Instrument development type", + title="Instrument development type", ) sources: Optional[List[Source]] = Field( None, - description=( - "Description of sources used for the data collection. The element is nestable so that the sources statement" - " might encompass a series of discrete source statements, each of which could contain the facts about an" - " individual source. This element maps to Dublin Core Source element." - ), + description="Description of sources used for the data collection. The element is nestable so that the sources statement might encompass a series of discrete source statements, each of which could contain the facts about an individual source. This element maps to Dublin Core Source element.", title="Sources", ) coll_situation: Optional[str] = Field( None, - description=( - "Description of noteworthy aspects of the data collection situation. Includes information on factors such" - " as cooperativeness of respondents, duration of interviews, number of call-backs, etc." - ), + description="Description of noteworthy aspects of the data collection situation. Includes information on factors such as cooperativeness of respondents, duration of interviews, number of call-backs, etc.", title="Characteristics of Data Collection Situation - Notes on data collection", ) act_min: Optional[str] = Field( None, - description=( - "Summary of actions taken to minimize data loss. Includes information on actions such as follow-up visits," - " supervisory checks, historical matching, estimation, etc." - ), + description="Summary of actions taken to minimize data loss. Includes information on actions such as follow-up visits, supervisory checks, historical matching, estimation, etc.", title="Supervision", ) control_operations: Optional[str] = Field( None, - description=( - " Methods to facilitate data control performed by the primary investigator or by the data archive. Specify" - " any special programs used for such operations." - ), + description=" Methods to facilitate data control performed by the primary investigator or by the data archive. Specify any special programs used for such operations.", title="Control Operations", ) weight: Optional[str] = Field( None, - description=( - "The use of sampling procedures may make it necessary to apply weights to produce accurate statistical" - " results. Describe here the criteria for using weights in analysis of a collection. If a weighting formula" - " or coefficient was developed, provide this formula, define its elements, and indicate how the formula is" - " applied to data." - ), + description="The use of sampling procedures may make it necessary to apply weights to produce accurate statistical results. Describe here the criteria for using weights in analysis of a collection. If a weighting formula or coefficient was developed, provide this formula, define its elements, and indicate how the formula is applied to data.", title="Weighting", ) cleaning_operations: Optional[str] = Field( @@ -1005,7 +885,9 @@ class AnalysisInfo(SchemaBaseModel): """ response_rate: Optional[str] = Field( - None, description="The percentage of sample members who provided information", title="Response Rate" + None, + description="The percentage of sample members who provided information", + title="Response Rate", ) sampling_error_estimates: Optional[str] = Field( None, @@ -1014,10 +896,7 @@ class AnalysisInfo(SchemaBaseModel): ) data_appraisal: Optional[str] = Field( None, - description=( - "Other issues pertaining to data appraisal. Describe here issues such as response variance, nonresponse" - " rate and testing for bias, interviewer and response bias, confidence levels, question bias, etc." - ), + description="Other issues pertaining to data appraisal. Describe here issues such as response variance, nonresponse rate and testing for bias, interviewer and response bias, confidence levels, question bias, etc.", title="Data Appraisal", ) @@ -1033,10 +912,7 @@ class CodingInstruction(SchemaBaseModel): txt: Optional[str] = Field(None, title="Coding instructions text") command: Optional[str] = Field( None, - description=( - "Provide command code for the coding instruction. The formalLanguage attribute identifies the language of" - " the command code." - ), + description="Provide command code for the coding instruction. The formalLanguage attribute identifies the language of the command code.", title="Command", ) formal_language: Optional[str] = Field( @@ -1052,35 +928,29 @@ class Method(SchemaBaseModel): """ data_collection: Optional[DataCollection] = Field( - None, description="Information about the methodology employed in a data collection", title="Data Collection" + None, + description="Information about the methodology employed in a data collection", + title="Data Collection", + ) + method_notes: Optional[str] = Field( + None, description="Methodology notes", title="Methodology notes" ) - method_notes: Optional[str] = Field(None, description="Methodology notes", title="Methodology notes") analysis_info: Optional[AnalysisInfo] = Field( None, description="Information about Data Appraisal", title="Data Appraisal" ) study_class: Optional[Union[str, List[Any]]] = Field( None, - description=( - "Generally used to give the data archive's class or study status number, which indicates the processing" - " status of the study. May also be used as a text field to describe processing status. Example: `DDA Class" - " C`, `Study is available from http://example.com` " - ), + description="Generally used to give the data archive's class or study status number, which indicates the processing status of the study. May also be used as a text field to describe processing status. Example: `DDA Class C`, `Study is available from http://example.com` ", title="Class of the Study", ) data_processing: Optional[List[DataProcessingItem]] = Field( None, - description=( - "Describes various data processing procedures not captured elsewhere in the documentation, such as" - " topcoding, recoding, suppression, tabulation, etc. The `type` attribute supports better classification of" - " this activity, including the optional use of a controlled vocabulary" - ), + description="Describes various data processing procedures not captured elsewhere in the documentation, such as topcoding, recoding, suppression, tabulation, etc. The `type` attribute supports better classification of this activity, including the optional use of a controlled vocabulary", title="Data Processing", ) coding_instructions: Optional[List[CodingInstruction]] = Field( None, - description=( - "Describe specific coding instructions used in data processing, cleaning, assession, or tabulation." - ), + description="Describe specific coding instructions used in data processing, cleaning, assession, or tabulation.", title="Coding Instructions", ) @@ -1092,18 +962,12 @@ class DatasetAvailability(SchemaBaseModel): access_place: Optional[str] = Field( None, - description=( - "Location where the data collection is currently stored. Use the URL field `access_place_url` to provide a" - " URN or URL for the storage site or the actual address from which the data may be downloaded" - ), + description="Location where the data collection is currently stored. Use the URL field `access_place_url` to provide a URN or URL for the storage site or the actual address from which the data may be downloaded", title="Location of Data Collection", ) access_place_url: Optional[str] = Field( None, - description=( - "Location where the data collection is currently stored. Provide a URN or URL for the storage site or the" - " actual address from which the data may be downloaded" - ), + description="Location where the data collection is currently stored. Provide a URN or URL for the storage site or the actual address from which the data may be downloaded", title="URL for Location of Data Collection", ) original_archive: Optional[str] = Field( @@ -1113,41 +977,32 @@ class DatasetAvailability(SchemaBaseModel): ) status: Optional[str] = Field( None, - description=( - "Statement of collection availability. An archive may need to indicate that a collection is unavailable" - " because it is embargoed for a period of time, because it has been superseded, because a new edition is" - " imminent, etc." - ), + description="Statement of collection availability. An archive may need to indicate that a collection is unavailable because it is embargoed for a period of time, because it has been superseded, because a new edition is imminent, etc.", title="Availability Status", ) coll_size: Optional[str] = Field( None, - description=( - "Summarizes the number of physical files that exist in a collection, recording the number of files that" - " contain data and noting whether the collection contains machine-readable documentation and/or other" - " supplementary files and information such as data dictionaries, data definition statements, or data" - " collection instruments." - ), + description="Summarizes the number of physical files that exist in a collection, recording the number of files that contain data and noting whether the collection contains machine-readable documentation and/or other supplementary files and information such as data dictionaries, data definition statements, or data collection instruments.", title="Extent of Collection", ) complete: Optional[str] = Field( None, - description=( - "This item indicates the relationship of the data collected to the amount of data coded and stored in the" - " data collection. Information as to why certain items of collected information were not included in the" - " data file stored by the archive should be provided" - ), + description="This item indicates the relationship of the data collected to the amount of data coded and stored in the data collection. Information as to why certain items of collected information were not included in the data file stored by the archive should be provided", title="Completeness of Study Stored", ) file_quantity: Optional[str] = Field( - None, description="Total number of physical files associated with a collection", title="Number of Files" + None, + description="Total number of physical files associated with a collection", + title="Number of Files", ) notes: Optional[str] = Field(None, description="Notes and comments", title="Notes") class ConfDecItem(SchemaBaseModel): txt: Optional[str] = Field( - None, description="Confidentiality declaration text", title="Confidentiality declaration text" + None, + description="Confidentiality declaration text", + title="Confidentiality declaration text", ) required: Optional[str] = Field( None, @@ -1160,22 +1015,30 @@ class ConfDecItem(SchemaBaseModel): title="Confidentiality declaration form URL", ) form_id: Optional[str] = Field( - None, description="Indicates the number or ID of the form that the user must fill out", title="Form ID" + None, + description="Indicates the number or ID of the form that the user must fill out", + title="Form ID", ) class SpecPermItem(SchemaBaseModel): txt: Optional[str] = Field( - None, description="Confidentiality declaration text", title="Special permissions description" + None, + description="Confidentiality declaration text", + title="Special permissions description", ) required: Optional[str] = Field( None, description="Indicate if special permissions are required to access a resource", title="Indicate if special permissions are required to access a resource", ) - form_url: Optional[str] = Field(None, description="Link to the form URL", title="Form URL") + form_url: Optional[str] = Field( + None, description="Link to the form URL", title="Form URL" + ) form_id: Optional[str] = Field( - None, description="Indicates the number or ID of the form that the user must fill out", title="Form ID" + None, + description="Indicates the number or ID of the form that the user must fill out", + title="Form ID", ) @@ -1193,10 +1056,7 @@ class DatasetUse(SchemaBaseModel): conf_dec: Optional[List[ConfDecItem]] = Field( None, - description=( - " This element is used to determine if signing of a confidentiality declaration is needed to access a" - " resource." - ), + description=" This element is used to determine if signing of a confidentiality declaration is needed to access a resource.", title="Confidentiality Declaration", ) spec_perm: Optional[List[SpecPermItem]] = Field( @@ -1206,41 +1066,31 @@ class DatasetUse(SchemaBaseModel): ) restrictions: Optional[str] = Field( None, - description=( - "Any restrictions on access to or use of the collection such as privacy certification or distribution" - " restrictions should be indicated here. These can be restrictions applied by the author, producer, or" - " disseminator of the data collection. If the data are restricted to only a certain class of user, specify" - " which type." - ), + description="Any restrictions on access to or use of the collection such as privacy certification or distribution restrictions should be indicated here. These can be restrictions applied by the author, producer, or disseminator of the data collection. If the data are restricted to only a certain class of user, specify which type.", title="Restrictions", ) - contact: Optional[List[ContactItem1]] = Field(None, description="Contact", title="Contact") + contact: Optional[List[ContactItem1]] = Field( + None, description="Contact", title="Contact" + ) cit_req: Optional[str] = Field( None, - description=( - "Text of requirement that a data collection should be cited properly in articles or other publications that" - " are based on analysis of the data." - ), + description="Text of requirement that a data collection should be cited properly in articles or other publications that are based on analysis of the data.", title="Citation requirement", ) deposit_req: Optional[str] = Field( None, - description=( - "Information regarding user responsibility for informing archives of their use of data through providing" - " citations to the published work or providing copies of the manuscripts." - ), + description="Information regarding user responsibility for informing archives of their use of data through providing citations to the published work or providing copies of the manuscripts.", title="Deposit requirement", ) conditions: Optional[str] = Field( None, - description=( - "Indicates any additional information that will assist the user in understanding the access and use" - " conditions of the data collection." - ), + description="Indicates any additional information that will assist the user in understanding the access and use conditions of the data collection.", title="Conditions", ) disclaimer: Optional[str] = Field( - None, description="Information regarding responsibility for uses of the data collection", title="Disclaimer" + None, + description="Information regarding responsibility for uses of the data collection", + title="Disclaimer", ) @@ -1250,10 +1100,14 @@ class DataAccess(SchemaBaseModel): """ dataset_availability: Optional[DatasetAvailability] = Field( - None, description="Information on availability and storage of the collection", title="Data Set Availability" + None, + description="Information on availability and storage of the collection", + title="Data Set Availability", ) dataset_use: Optional[DatasetUse] = Field( - None, description=" Information on terms of use for the data collection", title="Data Set Availability" + None, + description=" Information on terms of use for the data collection", + title="Data Set Availability", ) notes: Optional[str] = Field(None, description="Notes and comments", title="Notes") @@ -1269,11 +1123,7 @@ class StudyDesc(SchemaBaseModel): title_statement: TitleStatement = Field(..., description="Study title") authoring_entity: Optional[List[AuthoringEntityItem]] = Field( None, - description=( - "The person, corporate body, or agency responsible for the work's substantive and intellectual content." - " Repeat the element for each author, and use 'affiliation' attribute if available. Invert first and last" - " name and use commas." - ), + description="The person, corporate body, or agency responsible for the work's substantive and intellectual content. Repeat the element for each author, and use 'affiliation' attribute if available. Invert first and last name and use commas.", title="Authoring entity/Primary investigators", ) oth_id: Optional[List[OthIdItem]] = Field( @@ -1287,17 +1137,15 @@ class StudyDesc(SchemaBaseModel): distribution_statement: Optional[DistributionStatement] = Field( None, description="Distribution Statement", title="Distribution Statement" ) - series_statement: Optional[SeriesStatement] = Field(None, description="Series Statement", title="Series Statement") + series_statement: Optional[SeriesStatement] = Field( + None, description="Series Statement", title="Series Statement" + ) version_statement: Optional[VersionStatement] = Field( None, description="Version Statement", title="Version Statement" ) bib_citation: Optional[str] = Field( None, - description=( - "Complete bibliographic reference containing all of the standard elements of a citation that can be used to" - " cite the work. The `'bib_citation_format'` field is provided to enable specification of the particular" - " citation style used, e.g., APA, MLA, Chicago, etc." - ), + description="Complete bibliographic reference containing all of the standard elements of a citation that can be used to cite the work. The `'bib_citation_format'` field is provided to enable specification of the particular citation style used, e.g., APA, MLA, Chicago, etc.", title="Bibliographic Citation", ) bib_citation_format: Optional[str] = Field( @@ -1307,59 +1155,56 @@ class StudyDesc(SchemaBaseModel): ) holdings: Optional[List[Holding]] = Field( None, - description=( - "Information concerning either the physical or electronic holdings of the cited work. Attributes include:" - " location--The physical location where a copy is held; callno--The call number for a work at the location" - " specified; and URI--A URN or URL for accessing the electronic copy of the cited work." - ), + description="Information concerning either the physical or electronic holdings of the cited work. Attributes include: location--The physical location where a copy is held; callno--The call number for a work at the location specified; and URI--A URN or URL for accessing the electronic copy of the cited work.", title="Holdings Information", ) study_notes: Optional[str] = Field(None, title="Study notes") study_authorization: Optional[StudyAuthorization] = Field( None, - description=( - "Provides structured information on the agency that authorized the study, the date of authorization, and an" - " authorization statement" - ), + description="Provides structured information on the agency that authorized the study, the date of authorization, and an authorization statement", title="Study Authorization", ) study_info: StudyInfo = Field( ..., - description=( - "This section contains information about the data collection's scope across several dimensions, including" - " substantive content, geography, and time." - ), + description="This section contains information about the data collection's scope across several dimensions, including substantive content, geography, and time.", title="Study Scope", ) study_development: Optional[StudyDevelopment] = Field( None, - description=( - "Describe the process of study development as a series of development activities. These activities can be" - " typed using a controlled vocabulary. Describe the activity, listing participants with their role and" - " affiliation, resources used (sources of information), and the outcome of the development activity." - ), + description="Describe the process of study development as a series of development activities. These activities can be typed using a controlled vocabulary. Describe the activity, listing participants with their role and affiliation, resources used (sources of information), and the outcome of the development activity.", title="Study Development", ) - method: Optional[Method] = Field(None, description="Methodology and processing", title="Methodology and Processing") + method: Optional[Method] = Field( + None, + description="Methodology and processing", + title="Methodology and Processing", + ) data_access: Optional[DataAccess] = Field(None, description="Data Access") class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -1368,16 +1213,17 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class DdiSchema(SchemaBaseModel): """ Schema for Microdata data type based on DDI 2.5 """ - __metadata_type__ = "microdata" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" doc_desc: Optional[DocDesc] = None study_desc: Optional[StudyDesc] = None @@ -1399,10 +1245,20 @@ class MicrodataSchema(DdiSchema): title="Collection ID that owns the survey", ) access_policy: Optional[AccessPolicy] = Field( - "data_na", description="Data access policy for attached microdata resources", title="Data access policy" + "data_na", + description="Data access policy for attached microdata resources", + title="Data access policy", + ) + published: Optional[int] = Field( + 0, description="Status of the survey - 0=draft, 1=published" + ) + overwrite: Optional[Overwrite] = Field( + "no", description="Overwrite survey if already exists?" ) - published: Optional[int] = Field(0, description="Status of the survey - 0=draft, 1=published") - overwrite: Optional[Overwrite] = Field("no", description="Overwrite survey if already exists?") provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") - tags: Optional[List[Tag]] = Field(None, description="Tags", title="Tags (user-defined)") - additional: Optional[Dict[str, Any]] = Field(None, description="Additional metadata not covered by DDI elements") + tags: Optional[List[Tag]] = Field( + None, description="Tags", title="Tags (user-defined)" + ) + additional: Optional[Dict[str, Any]] = Field( + None, description="Additional metadata not covered by DDI elements" + ) diff --git a/pydantic_schemas/resource_schema.py b/pydantic_schemas/resource_schema.py index 8ade9d5..cf23f66 100644 --- a/pydantic_schemas/resource_schema.py +++ b/pydantic_schemas/resource_schema.py @@ -14,36 +14,17 @@ class Model(SchemaBaseModel): """ External resource schema """ - __metadata_type__ = "resource" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" dctype: Optional[str] = Field( "doc/oth", - description=( - "Document types for external resource e.g. `doc/adm` \n* `doc/adm` - Document, Administrative [doc/adm] \n*" - " `doc/anl` - Document, Analytical [doc/anl] \n* `doc/oth` - Document, Other [doc/oth] \n* `doc/qst` -" - " Document, Questionnaire [doc/qst] \n* `doc/ref` - Document, Reference [doc/ref] \n* `doc/rep` - Document," - " Report [doc/rep] \n* `doc/tec` - Document, Technical [doc/tec] \n* `aud` - Audio [aud]\n* `dat` -" - " Database [dat]\n* `map` - Map [map]\n* `dat/micro` - Microdata File [dat/micro]\n* `pic` - Photo [pic]\n*" - " `prg` - Program [prg]\n* `tbl` - Table [tbl]\n* `vid` - Video [vid] \n* `web` - Web Site [web]" - ), + description="Document types for external resource e.g. `doc/adm` \n* `doc/adm` - Document, Administrative [doc/adm] \n* `doc/anl` - Document, Analytical [doc/anl] \n* `doc/oth` - Document, Other [doc/oth] \n* `doc/qst` - Document, Questionnaire [doc/qst] \n* `doc/ref` - Document, Reference [doc/ref] \n* `doc/rep` - Document, Report [doc/rep] \n* `doc/tec` - Document, Technical [doc/tec] \n* `aud` - Audio [aud]\n* `dat` - Database [dat]\n* `map` - Map [map]\n* `dat/micro` - Microdata File [dat/micro]\n* `pic` - Photo [pic]\n* `prg` - Program [prg]\n* `tbl` - Table [tbl]\n* `vid` - Video [vid] \n* `web` - Web Site [web]", title="Resource type", ) dcformat: Optional[str] = Field( None, - description=( - "Document file format e.g. `application/zip` \n* `application/x-compressed` - Compressed, Generic \n*" - " `application/zip` - Compressed, ZIP \n* `application/x-cspro` - Data, CSPro \n* `application/dbase` -" - " Data, dBase \n* `application/msaccess` - Data, Microsoft Access \n* `application/x-sas` - Data, SAS " - " \n* `application/x-spss` - Data, SPSS \n* `application/x-stata` - Data, Stata \n* `text` - Document," - " Generic \n* `text/html` - Document, HTML \n* `application/msexcel` - Document, Microsoft Excel \n*" - " `application/mspowerpoint` - Document, Microsoft PowerPoint \n* `application/msword` - Document," - " Microsoft Word \n* `application/pdf` - Document, PDF \n* `application/postscript` - Document," - " Postscript \n* `text/plain` - Document, Plain \n* `text/wordperfect` - Document, WordPerfect \n*" - " `image/gif` - Image, GIF \n* `image/jpeg` - Image, JPEG \n* `image/png` - Image, PNG \n*" - " `image/tiff` - Image, TIFF" - ), + description="Document file format e.g. `application/zip` \n* `application/x-compressed` - Compressed, Generic \n* `application/zip` - Compressed, ZIP \n* `application/x-cspro` - Data, CSPro \n* `application/dbase` - Data, dBase \n* `application/msaccess` - Data, Microsoft Access \n* `application/x-sas` - Data, SAS \n* `application/x-spss` - Data, SPSS \n* `application/x-stata` - Data, Stata \n* `text` - Document, Generic \n* `text/html` - Document, HTML \n* `application/msexcel` - Document, Microsoft Excel \n* `application/mspowerpoint` - Document, Microsoft PowerPoint \n* `application/msword` - Document, Microsoft Word \n* `application/pdf` - Document, PDF \n* `application/postscript` - Document, Postscript \n* `text/plain` - Document, Plain \n* `text/wordperfect` - Document, WordPerfect \n* `image/gif` - Image, GIF \n* `image/jpeg` - Image, JPEG \n* `image/png` - Image, PNG \n* `image/tiff` - Image, TIFF", title="Resource Format", ) title: str = Field(..., description="Title") @@ -59,8 +40,5 @@ class Model(SchemaBaseModel): toc: Optional[str] = Field(None, description="TOC") filename: Optional[str] = Field( None, - description=( - "Resource file name or URL. For uploading a file, use the field `file` in formData or use the `Upload file`" - " endpoint." - ), + description="Resource file name or URL. For uploading a file, use the field `file` in formData or use the `Upload file` endpoint.", ) diff --git a/pydantic_schemas/script_schema.py b/pydantic_schemas/script_schema.py index 763b87d..8a12b2a 100644 --- a/pydantic_schemas/script_schema.py +++ b/pydantic_schemas/script_schema.py @@ -35,22 +35,30 @@ class DocDesc(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") producers: Optional[List[Producer]] = Field( None, description="List of producers of the document", title="Producers" ) prod_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of production", ) version: Optional[str] = Field( - None, description="Identify and describe the current version of the document", title="Document version" + None, + description="Identify and describe the current version of the document", + title="Document version", ) class Identifier(SchemaBaseModel): type: Optional[str] = Field( - None, description="Type of identifier e.g. `doi`, `handle`, `other`", title="Identifier type" + None, + description="Type of identifier e.g. `doi`, `handle`, `other`", + title="Identifier type", ) identifier: str = Field(..., title="Identifier") @@ -62,28 +70,23 @@ class TitleStatement(SchemaBaseModel): idno: str = Field( ..., - description=( - "The ID number of a research project is a unique number that is used to identify a particular project." - " Define and use a consistent scheme to use." - ), + description="The ID number of a research project is a unique number that is used to identify a particular project. Define and use a consistent scheme to use.", title="Unique user defined ID", ) - identifiers: Optional[List[Identifier]] = Field(None, description="Other identifiers", title="Other identifiers") + identifiers: Optional[List[Identifier]] = Field( + None, description="Other identifiers", title="Other identifiers" + ) title: str = Field( ..., - description=( - "The title is the name of the project, which may correspond to the title of an academic paper, of a project" - " impact evaluation, etc." - ), + description="The title is the name of the project, which may correspond to the title of an academic paper, of a project impact evaluation, etc.", title="Project title", ) - sub_title: Optional[str] = Field(None, description="A short subtitle for the project", title="Project subtitle") + sub_title: Optional[str] = Field( + None, description="A short subtitle for the project", title="Project subtitle" + ) alternate_title: Optional[str] = Field( None, - description=( - "The abbreviation of a project is usually the first letter of each word of the project title. The project" - " reference year(s) may be included." - ), + description="The abbreviation of a project is usually the first letter of each word of the project title. The project reference year(s) may be included.", title="Abbreviation or acronym", ) translated_title: Optional[str] = Field( @@ -96,25 +99,25 @@ class TitleStatement(SchemaBaseModel): class OutputItem(SchemaBaseModel): type: Optional[str] = Field( None, - description=( - "Type of outputs of the script/research project. Example: `Working paper`, `On-line interactive data" - " visualization` (ideally, a controlled vocabulary should be used)" - ), + description="Type of outputs of the script/research project. Example: `Working paper`, `On-line interactive data visualization` (ideally, a controlled vocabulary should be used)", title="Type of output", ) title: str = Field(..., description="Title of the output", title="Title") authors: Optional[str] = Field(None, description="Authors", title="Authors") description: Optional[str] = Field( None, - description=( - "Brief description of the output; for articles and working papers, this can include the bibliographic" - " citation." - ), + description="Brief description of the output; for articles and working papers, this can include the bibliographic citation.", title="Description", ) - abstract: Optional[str] = Field(None, description="Abstract (for papers, articles, books)", title="Abstract") - uri: Optional[str] = Field(None, description="On-line location of the output", title="URI") - doi: Optional[str] = Field(None, description="Digital Object Identifier (DOI) of the output", title="DOI") + abstract: Optional[str] = Field( + None, description="Abstract (for papers, articles, books)", title="Abstract" + ) + uri: Optional[str] = Field( + None, description="On-line location of the output", title="URI" + ) + doi: Optional[str] = Field( + None, description="Digital Object Identifier (DOI) of the output", title="DOI" + ) class ApprovalProces(SchemaBaseModel): @@ -148,7 +151,9 @@ class VersionStatement(SchemaBaseModel): class Erratum(SchemaBaseModel): date: Optional[str] = Field( - None, description="Date when the erratum was reported or published", title="Date of erratum" + None, + description="Date when the erratum was reported or published", + title="Date of erratum", ) description: Optional[str] = Field( None, @@ -158,7 +163,11 @@ class Erratum(SchemaBaseModel): class Proces(SchemaBaseModel): - name: Optional[str] = Field(None, description="A short name for the implementation phase", title="Phase name") + name: Optional[str] = Field( + None, + description="A short name for the implementation phase", + title="Phase name", + ) date_start: Optional[str] = Field( None, description="Start date of the phase period (as a string; recommended ISO format YYY or YYY-MM or YYY-MM-DD)", @@ -170,24 +179,27 @@ class Proces(SchemaBaseModel): title="Phase end date", ) description: Optional[str] = Field( - None, description="Description of the implementation phase", title="Phase description" + None, + description="Description of the implementation phase", + title="Phase description", ) class AuthorIdItem(SchemaBaseModel): - type: Optional[str] = Field(None, description="Source of identifier, e.g. ORCID", title="Type") + type: Optional[str] = Field( + None, description="Source of identifier, e.g. ORCID", title="Type" + ) id: Optional[str] = Field( - None, description="Author's unique identifier for the corresponding source", title="Identifier" + None, + description="Author's unique identifier for the corresponding source", + title="Identifier", ) class AuthoringEntityItem(SchemaBaseModel): name: str = Field( ..., - description=( - "Name of the person, corporate body, or agency responsible for the work's substantive and intellectual" - " content. If a person, invert first and last name and use commas." - ), + description="Name of the person, corporate body, or agency responsible for the work's substantive and intellectual content. If a person, invert first and last name and use commas.", title="Author (or primary investigator) name", ) role: Optional[str] = Field( @@ -195,8 +207,12 @@ class AuthoringEntityItem(SchemaBaseModel): description="Title of the person (if any) responsible for the work's substantive and intellectual content.", title="Role", ) - affiliation: Optional[str] = Field(None, title="Affiliation of the author/primary investigator") - abbreviation: Optional[str] = Field(None, description="Abbreviation", title="Abbreviation") + affiliation: Optional[str] = Field( + None, title="Affiliation of the author/primary investigator" + ) + abbreviation: Optional[str] = Field( + None, description="Abbreviation", title="Abbreviation" + ) email: Optional[str] = Field(None, description="Email", title="Email") author_id: Optional[List[AuthorIdItem]] = Field( None, @@ -208,10 +224,7 @@ class AuthoringEntityItem(SchemaBaseModel): class Contributor(SchemaBaseModel): name: str = Field( ..., - description=( - "Name of the person, corporate body, or agency responsible for the work's substantive and intellectual" - " content. If a person, invert first and last name and use commas." - ), + description="Name of the person, corporate body, or agency responsible for the work's substantive and intellectual content. If a person, invert first and last name and use commas.", title="Name", ) role: Optional[str] = Field( @@ -220,7 +233,9 @@ class Contributor(SchemaBaseModel): title="Role", ) affiliation: Optional[str] = Field(None, title="Affiliation") - abbreviation: Optional[str] = Field(None, description="Abbreviation", title="Abbreviation") + abbreviation: Optional[str] = Field( + None, description="Abbreviation", title="Abbreviation" + ) email: Optional[str] = Field(None, description="Email", title="Email") url: Optional[str] = Field(None, description="URL", title="URL") @@ -235,17 +250,18 @@ class Sponsor(SchemaBaseModel): class Curator(SchemaBaseModel): name: str = Field( ..., - description=( - "Name of the person, corporate body, or agency responsible for the project curation. If a person, invert" - " first and last name and use commas." - ), + description="Name of the person, corporate body, or agency responsible for the project curation. If a person, invert first and last name and use commas.", title="Name", ) role: Optional[str] = Field( - None, description="Title of the person (if any) responsible for the project curation.", title="Role" + None, + description="Title of the person (if any) responsible for the project curation.", + title="Role", ) affiliation: Optional[str] = Field(None, title="Affiliation") - abbreviation: Optional[str] = Field(None, description="Abbreviation", title="Abbreviation") + abbreviation: Optional[str] = Field( + None, description="Abbreviation", title="Abbreviation" + ) email: Optional[str] = Field(None, description="Email", title="Email") url: Optional[str] = Field(None, description="URL", title="URL") @@ -256,7 +272,9 @@ class ReviewsComment(SchemaBaseModel): """ comment_date: Optional[str] = Field( - None, description="Date when the comment was provided", title="Date of the comment" + None, + description="Date when the comment was provided", + title="Date of the comment", ) comment_by: Optional[str] = Field( None, @@ -264,7 +282,9 @@ class ReviewsComment(SchemaBaseModel): title="Provider of the comment", ) comment_description: Optional[str] = Field( - None, description="A description of the comment", title="Description of the comment" + None, + description="A description of the comment", + title="Description of the comment", ) comment_response: Optional[str] = Field( None, @@ -287,18 +307,26 @@ class RelatedProject(SchemaBaseModel): class GeographicUnit(SchemaBaseModel): name: str = Field( - ..., description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", title="Location name" + ..., + description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", + title="Location name", ) code: Optional[str] = Field( - None, description="Code of the geographic unit (for countries, preferred = ISO3 code)", title="Location code" + None, + description="Code of the geographic unit (for countries, preferred = ISO3 code)", + title="Location code", ) type: Optional[str] = Field( - None, description="Type of geographic unit e.g. country, state, region, province, town, etc", title="Type" + None, + description="Type of geographic unit e.g. country, state, region, province, town, etc", + title="Type", ) class Keyword(SchemaBaseModel): - name: Optional[str] = Field(None, description="Keyword, composed of one or multiple words", title="Name") + name: Optional[str] = Field( + None, description="Keyword, composed of one or multiple words", title="Name" + ) vocabulary: Optional[str] = Field( None, description="Vocabulary name (for keywords extracted from controlled vocabularies)", @@ -311,7 +339,9 @@ class Theme(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Name") parent_id: Optional[str] = Field(None, title="Parent Identifier") - vocabulary: Optional[str] = Field(None, description="Name of the controlled vocabulary", title="Vocabulary") + vocabulary: Optional[str] = Field( + None, description="Name of the controlled vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field( None, description="Link to the controlled vocabulary web page, if the theme is from a taxonomy.", @@ -323,10 +353,14 @@ class Topic(SchemaBaseModel): id: str = Field(..., title="Unique identifier") name: str = Field(..., title="Topic") parent_id: Optional[str] = Field( - None, description="For subtopics, provide the ID of the parent topic", title="Parent topic identifier" + None, + description="For subtopics, provide the ID of the parent topic", + title="Parent topic identifier", ) vocabulary: Optional[str] = Field( - None, description="Name of the controlled vocabulary, if the topic is from a taxonomy.", title="Vocabulary name" + None, + description="Name of the controlled vocabulary, if the topic is from a taxonomy.", + title="Vocabulary name", ) uri: Optional[str] = Field( None, @@ -338,8 +372,12 @@ class Topic(SchemaBaseModel): class Discipline(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Discipline title or name") - parent_id: Optional[str] = Field(None, description="Parent discipline ID", title="Parent discipline Identifier") - vocabulary: Optional[str] = Field(None, description="Vocabulary", title="Vocabulary") + parent_id: Optional[str] = Field( + None, description="Parent discipline ID", title="Parent discipline Identifier" + ) + vocabulary: Optional[str] = Field( + None, description="Vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field(None, description="Website link", title="URI") @@ -349,8 +387,12 @@ class RepositoryUriItem(SchemaBaseModel): description="Name of the repository where code is hosted. e.g. `Github`, `Bitbucket`, etc.", title="Repository name", ) - type: Optional[str] = Field(None, description="Repo type e.g. `git`, `svn`, `other`", title="Type") - uri: Optional[Any] = Field(None, description="URI of the project repository", title="URI") + type: Optional[str] = Field( + None, description="Repo type e.g. `git`, `svn`, `other`", title="Type" + ) + uri: Optional[Any] = Field( + None, description="URI of the project repository", title="URI" + ) class LicenseItem(SchemaBaseModel): @@ -370,7 +412,9 @@ class SoftwareItem(SchemaBaseModel): name: Optional[str] = Field(None, title="Name") version: Optional[str] = Field(None, title="Version") library: Optional[List[str]] = Field( - None, description="Software-specific libraries or packages used", title="Libraries or packages used" + None, + description="Software-specific libraries or packages used", + title="Libraries or packages used", ) @@ -388,17 +432,23 @@ class LicenseItem1(SchemaBaseModel): class Script(SchemaBaseModel): file_name: Optional[str] = Field(None, title="File name") zip_package: Optional[str] = Field( - None, description="Provide the name of the zip file, if the file is included in a zip", title="Zip file" + None, + description="Provide the name of the zip file, if the file is included in a zip", + title="Zip file", ) title: str = Field(..., title="Title") - authors: Optional[List[Author]] = Field(None, description="Author(s) of the script", title="Authors") + authors: Optional[List[Author]] = Field( + None, description="Author(s) of the script", title="Authors" + ) date: Optional[str] = Field(None, title="Date") format: Optional[str] = Field(None, title="Format") software: Optional[str] = Field(None, title="Software") description: Optional[str] = Field(None, title="Description") methods: Optional[str] = Field(None, title="Methods") dependencies: Optional[str] = Field(None, title="Dependencies") - instructions: Optional[str] = Field(None, title="Instructions or note for running the script") + instructions: Optional[str] = Field( + None, title="Instructions or note for running the script" + ) source_code_repo: Optional[str] = Field(None, title="Source code repositor") notes: Optional[str] = Field(None, title="Notes") license: Optional[List[LicenseItem1]] = Field(None, title="License") @@ -406,13 +456,12 @@ class Script(SchemaBaseModel): class Dataset(SchemaBaseModel): name: Optional[str] = Field(None, title="Dataset name") - idno: Optional[str] = Field(None, description="unique ID of the dataset", title="Dataset ID") + idno: Optional[str] = Field( + None, description="unique ID of the dataset", title="Dataset ID" + ) note: Optional[str] = Field( None, - description=( - "Brief description of the dataset (note: ideally, the dataset will be documented using a specific metadata" - " schema like the DDI)." - ), + description="Brief description of the dataset (note: ideally, the dataset will be documented using a specific metadata schema like the DDI).", title="Description", ) access_type: Optional[str] = Field(None, title="Data access policy") @@ -443,68 +492,64 @@ class ProjectDesc(SchemaBaseModel): abstract: Optional[str] = Field(None, title="Abstract") review_board: Optional[str] = Field( None, - description=( - "Information on whether and when the project was submitted, reviewed, and approved by an institutional" - " review board (or independent ethics committee, ethical review board (ERB), research ethics board, or" - " equivalent)." - ), + description="Information on whether and when the project was submitted, reviewed, and approved by an institutional review board (or independent ethics committee, ethical review board (ERB), research ethics board, or equivalent).", title="Institutional review board", ) output: Optional[List[OutputItem]] = Field( - None, description="Description of outputs of the research project", title="Output" + None, + description="Description of outputs of the research project", + title="Output", ) approval_process: Optional[List[ApprovalProces]] = Field( - None, description="A description of the project output review process", title="Approval process" + None, + description="A description of the project output review process", + title="Approval process", + ) + project_website: Optional[List[str]] = Field( + None, description="Project website link", title="Project website" ) - project_website: Optional[List[str]] = Field(None, description="Project website link", title="Project website") language: Optional[List[LanguageItem]] = Field( - None, description="Documentation language e.g. English, French, etc.", title="Language" + None, + description="Documentation language e.g. English, French, etc.", + title="Language", ) production_date: Optional[List[str]] = Field( None, - description=( - "Date in ISO format when the dissemination-ready version of the research project was produced. It can be a" - " year (YYYY), year-month (YYYY-MM), or year-month-day (YYYY-MM-DD)" - ), + description="Date in ISO format when the dissemination-ready version of the research project was produced. It can be a year (YYYY), year-month (YYYY-MM), or year-month-day (YYYY-MM-DD)", title="Date of production (YYYY-MM-DD)", ) version_statement: Optional[VersionStatement] = Field( None, description="Version statement", title="Version statement" ) errata: Optional[List[Erratum]] = Field( - None, description="List of corrected errors in data, scripts or output", title="Errata" + None, + description="List of corrected errors in data, scripts or output", + title="Errata", ) process: Optional[List[Proces]] = Field( None, - description=( - "A description, following a logical sequence, of the various phases of the research project implementation." - " This field may be used to document explorations steps that may have resulted in dead ends, to document" - " intermediary steps at which a project may have been reviewed and approved, etc." - ), + description="A description, following a logical sequence, of the various phases of the research project implementation. This field may be used to document explorations steps that may have resulted in dead ends, to document intermediary steps at which a project may have been reviewed and approved, etc.", title="Process", ) authoring_entity: Optional[List[AuthoringEntityItem]] = Field( None, - description=( - "The person, corporate body, or agency responsible for the project's substantive and intellectual content." - " Repeat the element for each author/primary investigator, and use 'affiliation' attribute if available." - " Invert first and last name and use commas." - ), + description="The person, corporate body, or agency responsible for the project's substantive and intellectual content. Repeat the element for each author/primary investigator, and use 'affiliation' attribute if available. Invert first and last name and use commas.", title="Authoring entity", ) contributors: Optional[List[Contributor]] = Field( - None, description="The person, corporate body, or agency who contributed to the project.", title="Contributors" + None, + description="The person, corporate body, or agency who contributed to the project.", + title="Contributors", ) sponsors: Optional[List[Sponsor]] = Field( None, - description=( - "The source(s) of funds for production of the work. If different funding agencies sponsored different" - " stages of the production process, use the 'role' attribute to distinguish them." - ), + description="The source(s) of funds for production of the work. If different funding agencies sponsored different stages of the production process, use the 'role' attribute to distinguish them.", title="Sponsors / Funding agencies", ) curators: Optional[List[Curator]] = Field( - None, description="The person, corporate body, or agency who curated the project.", title="Curators" + None, + description="The person, corporate body, or agency who curated the project.", + title="Curators", ) reviews_comments: Optional[List[ReviewsComment]] = None acknowledgements: Optional[List[Acknowledgement]] = Field( @@ -518,27 +563,24 @@ class ProjectDesc(SchemaBaseModel): disclaimer: Optional[str] = Field(None, title="Disclaimer") confidentiality: Optional[str] = Field(None, title="Confidentiality") citation_requirement: Optional[str] = Field( - None, description="Citation requirement (can include a specific recommended citation)" + None, + description="Citation requirement (can include a specific recommended citation)", ) related_projects: Optional[List[RelatedProject]] = Field( - None, description="A list and bried description of related research projects", title="Related research projects" + None, + description="A list and bried description of related research projects", + title="Related research projects", ) geographic_units: Optional[List[GeographicUnit]] = Field( None, - description=( - "List of geographic locations (regions, countries, states, provinces, etc.) describing the geographic" - " coverahe of the research project." - ), + description="List of geographic locations (regions, countries, states, provinces, etc.) describing the geographic coverahe of the research project.", title="Geographic locations", ) keywords: Optional[List[Keyword]] = Field(None, title="Keywords") themes: Optional[List[Theme]] = Field(None, description="Themes") topics: Optional[List[Topic]] = Field( None, - description=( - "Topics covered by the project (ideally, a controlled vocabulary should be used). This can be a" - " hierarchical list of topics." - ), + description="Topics covered by the project (ideally, a controlled vocabulary should be used). This can be a hierarchical list of topics.", title="Topics", ) disciplines: Optional[List[Discipline]] = Field( @@ -551,10 +593,7 @@ class ProjectDesc(SchemaBaseModel): ) license: Optional[List[LicenseItem]] = Field( None, - description=( - "Overall statement on license. Note: information on license specific to scripts and/or datasets should be" - " provided in the documentation of scripts and datasets." - ), + description="Overall statement on license. Note: information on license specific to scripts and/or datasets should be provided in the documentation of scripts and datasets.", title="License", ) copyright: Optional[str] = Field(None, title="Copyright") @@ -568,25 +607,34 @@ class ProjectDesc(SchemaBaseModel): description="Software/hardware or other technology requirements needed to replicate the scripts", title="Technology requirements", ) - reproduction_instructions: Optional[str] = Field(None, description="Reproduction instructions") + reproduction_instructions: Optional[str] = Field( + None, description="Reproduction instructions" + ) methods: Optional[List[Method]] = Field( - None, description="Methods or algorithms applied", title="Methods or algorithms applied" + None, + description="Methods or algorithms applied", + title="Methods or algorithms applied", ) software: Optional[List[SoftwareItem]] = Field( - None, description="List of software applications used for the project", title="Software" + None, + description="List of software applications used for the project", + title="Software", + ) + scripts: Optional[List[Script]] = Field( + None, description="Description of each script file", title="Script files" ) - scripts: Optional[List[Script]] = Field(None, description="Description of each script file", title="Script files") data_statement: Optional[str] = Field( None, - description=( - "Overall statement on data used by the project. More detailed description of the datasets should be" - " provided in the 'datasets' field." - ), + description="Overall statement on data used by the project. More detailed description of the datasets should be provided in the 'datasets' field.", ) datasets: Optional[List[Dataset]] = Field( - None, description="List and description of datasets used by the research project", title="Datasets" + None, + description="List and description of datasets used by the research project", + title="Datasets", + ) + contacts: Optional[List[Contact]] = Field( + None, description="Contacts", title="Contacts" ) - contacts: Optional[List[Contact]] = Field(None, description="Contacts", title="Contacts") class Tag(SchemaBaseModel): @@ -595,21 +643,28 @@ class Tag(SchemaBaseModel): class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -618,32 +673,43 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class ResearchProjectSchemaDraft(SchemaBaseModel): """ Schema for documenting research projects and data analysis scripts """ - __metadata_type__ = "script" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" repositoryid: Optional[str] = Field( None, description="Abbreviation for the collection that owns the research project", title="Collection ID that owns the project", ) - published: Optional[int] = Field(0, description="Status of the project - 0=draft, 1=published", title="Status") - overwrite: Optional[Overwrite] = Field("no", description="Overwrite document if already exists?") + published: Optional[int] = Field( + 0, description="Status of the project - 0=draft, 1=published", title="Status" + ) + overwrite: Optional[Overwrite] = Field( + "no", description="Overwrite document if already exists?" + ) doc_desc: Optional[DocDesc] = Field( None, description="Document description; the Document is the file containing the structured metadata", title="Document description", ) project_desc: Optional[ProjectDesc] = Field( - None, description="Description of the research project", title="Project description" + None, + description="Description of the research project", + title="Project description", ) provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") - tags: Optional[List[Tag]] = Field(None, description="Tags", title="Tags (user-defined)") - additional: Optional[Dict[str, Any]] = Field(None, description="Additional metadata") + tags: Optional[List[Tag]] = Field( + None, description="Tags", title="Tags (user-defined)" + ) + additional: Optional[Dict[str, Any]] = Field( + None, description="Additional metadata" + ) diff --git a/pydantic_schemas/table_schema.py b/pydantic_schemas/table_schema.py index 96359a1..7bbb3fa 100644 --- a/pydantic_schemas/table_schema.py +++ b/pydantic_schemas/table_schema.py @@ -37,12 +37,18 @@ class MetadataInformation(SchemaBaseModel): ) idno: Optional[str] = Field(None, title="Unique ID number for the document") title: Optional[str] = Field(None, title="Document title") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) production_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version: Optional[str] = Field( - None, description="Identify and describe the current version of the document", title="Document version" + None, + description="Identify and describe the current version of the document", + title="Document version", ) @@ -53,19 +59,16 @@ class TitleStatement(SchemaBaseModel): idno: str = Field( ..., - description=( - "The ID number of a dataset is a unique number that is used to identify a particular survey. Define and use" - " a consistent scheme to use. Such an ID could be constructed as follows:" - " country-producer-survey-year-version where \n - country is the 3-letter ISO country abbreviation \n -" - " producer is the abbreviation of the producing agency \n - survey is the survey abbreviation \n - year is" - " the reference year (or the year the survey started) \n - version is the number dataset version number" - " (see Version Description below)" - ), + description="The ID number of a dataset is a unique number that is used to identify a particular survey. Define and use a consistent scheme to use. Such an ID could be constructed as follows: country-producer-survey-year-version where \n - country is the 3-letter ISO country abbreviation \n - producer is the abbreviation of the producing agency \n - survey is the survey abbreviation \n - year is the reference year (or the year the survey started) \n - version is the number dataset version number (see Version Description below)", title="Unique user defined ID", ) - table_number: Optional[str] = Field(None, description="Table number", title="Table number") + table_number: Optional[str] = Field( + None, description="Table number", title="Table number" + ) title: str = Field(..., description="Table title", title="Table title") - sub_title: Optional[str] = Field(None, description="A short subtitle for the table", title="Table subtitle") + sub_title: Optional[str] = Field( + None, description="A short subtitle for the table", title="Table subtitle" + ) alternate_title: Optional[str] = Field( None, description="Any form of the title used as a substitute or alternative to the formal title of the resource.", @@ -76,7 +79,9 @@ class TitleStatement(SchemaBaseModel): class Identifier(SchemaBaseModel): type: Optional[str] = Field( - None, description="Type of identifier e.g. `doi`, `handle`, `other`", title="Identifier type" + None, + description="Type of identifier e.g. `doi`, `handle`, `other`", + title="Identifier type", ) identifier: str = Field(..., title="Identifier") @@ -91,9 +96,13 @@ class PublisherItem(SchemaBaseModel): class TableColumn(SchemaBaseModel): label: str = Field(..., title="Label") - var_name: Optional[str] = Field(None, description="Variable name", title="Variable name") + var_name: Optional[str] = Field( + None, description="Variable name", title="Variable name" + ) dataset: Optional[str] = Field( - None, description="Identifies the dataset that contains the variable reported in var_name", title="Dataset" + None, + description="Identifies the dataset that contains the variable reported in var_name", + title="Dataset", ) @@ -102,7 +111,9 @@ class TableRow(TableColumn): class TableFootnote(SchemaBaseModel): - number: Optional[str] = Field(None, description="Footnote number", title="Footnote number") + number: Optional[str] = Field( + None, description="Footnote number", title="Footnote number" + ) text: str = Field(..., title="Footnote text") @@ -124,14 +135,13 @@ class UnitObservationItem(Statistic): class DataSource(SchemaBaseModel): name: Optional[str] = Field( None, - description=( - "The name (title) of the data source. For example, a table data may be extracted from the `Population" - " Census 2020`." - ), + description="The name (title) of the data source. For example, a table data may be extracted from the `Population Census 2020`.", title="Name", ) abbreviation: Optional[str] = Field( - None, description="The abbreviation (acronym) of the data source.", title="Abbreviation" + None, + description="The abbreviation (acronym) of the data source.", + title="Abbreviation", ) source_id: Optional[str] = Field( None, @@ -140,12 +150,12 @@ class DataSource(SchemaBaseModel): ) note: Optional[str] = Field( None, - description=( - "A note that describes how the source was used, possibly mentioning issues in the use of the source." - ), + description="A note that describes how the source was used, possibly mentioning issues in the use of the source.", title="Note", ) - uri: Optional[str] = Field(None, description="A link (URL) to the source dataset.", title="URI") + uri: Optional[str] = Field( + None, description="A link (URL) to the source dataset.", title="URI" + ) class TimePeriod(SchemaBaseModel): @@ -156,7 +166,9 @@ class TimePeriod(SchemaBaseModel): title="Start date", ) to: Optional[str] = Field( - None, description="Date in ISO format (YYYY-MM-DD). Partial dates are supported", title="End date" + None, + description="Date in ISO format (YYYY-MM-DD). Partial dates are supported", + title="End date", ) @@ -171,13 +183,19 @@ class RefCountryItem(SchemaBaseModel): class GeographicUnit(SchemaBaseModel): name: str = Field( - ..., description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", title="Location name" + ..., + description="Name of the geographic unit e.g. 'World', 'Africa', 'Afghanistan'", + title="Location name", ) code: Optional[str] = Field( - None, description="Code of the geographic unit (for countries, preferred = ISO3 code)", title="Location code" + None, + description="Code of the geographic unit (for countries, preferred = ISO3 code)", + title="Location code", ) type: Optional[str] = Field( - None, description="Type of geographic unit e.g. country, state, region, province etc", title="Type" + None, + description="Type of geographic unit e.g. country, state, region, province etc", + title="Type", ) @@ -212,7 +230,9 @@ class Theme(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Name") parent_id: Optional[str] = Field(None, title="Parent Identifier") - vocabulary: Optional[str] = Field(None, description="Name of the controlled vocabulary", title="Vocabulary") + vocabulary: Optional[str] = Field( + None, description="Name of the controlled vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field( None, description="Link to the controlled vocabulary web page, if the theme is from a taxonomy.", @@ -224,10 +244,14 @@ class Topic(SchemaBaseModel): id: str = Field(..., title="Unique Identifier") name: str = Field(..., title="Topic") parent_id: Optional[str] = Field( - None, description="For subtopics, provide the ID of the parent topic", title="Parent topic Identifier" + None, + description="For subtopics, provide the ID of the parent topic", + title="Parent topic Identifier", ) vocabulary: Optional[str] = Field( - None, description="Name of the controlled vocabulary, if the topic is from a taxonomy.", title="Vocabulary" + None, + description="Name of the controlled vocabulary, if the topic is from a taxonomy.", + title="Vocabulary", ) uri: Optional[str] = Field( None, @@ -239,14 +263,20 @@ class Topic(SchemaBaseModel): class Discipline(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Discipline title or name") - parent_id: Optional[str] = Field(None, description="Parent discipline ID", title="Parent discipline Identifier") - vocabulary: Optional[str] = Field(None, description="Vocabulary", title="Vocabulary") + parent_id: Optional[str] = Field( + None, description="Parent discipline ID", title="Parent discipline Identifier" + ) + vocabulary: Optional[str] = Field( + None, description="Vocabulary", title="Vocabulary" + ) uri: Optional[str] = Field(None, description="Website link", title="URI") class Definition(SchemaBaseModel): name: str = Field(..., title="Definition") - definition: Optional[str] = Field(None, description="Definition", title="Definition") + definition: Optional[str] = Field( + None, description="Definition", title="Definition" + ) uri: Optional[str] = Field(None, description="Website link", title="URI") @@ -254,7 +284,9 @@ class Classification(SchemaBaseModel): name: str = Field(..., title="Classification name") version: Optional[str] = Field(None, description="Version number", title="Version") organization: Optional[str] = Field( - None, description="Organization responsible for the classification", title="Organization" + None, + description="Organization responsible for the classification", + title="Organization", ) uri: Optional[str] = Field(None, description="Website link", title="URI") @@ -302,21 +334,28 @@ class Tag(SchemaBaseModel): class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -325,13 +364,19 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class AuthorIdItem(SchemaBaseModel): - type: Optional[Any] = Field(None, description="Source of identifier, e.g. ORCID", title="Type") + type: Optional[Any] = Field( + None, description="Source of identifier, e.g. ORCID", title="Type" + ) id: Optional[Any] = Field( - None, description="Author's unique identifier for the corresponding source", title="Identifier" + None, + description="Author's unique identifier for the corresponding source", + title="Identifier", ) @@ -365,38 +410,59 @@ class TableDescription(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title_statement: Optional[TitleStatement] = Field(None, description="Title statement") - identifiers: Optional[List[Identifier]] = Field(None, description="Other identifiers", title="Other identifiers") + title_statement: Optional[TitleStatement] = Field( + None, description="Title statement" + ) + identifiers: Optional[List[Identifier]] = Field( + None, description="Other identifiers", title="Other identifiers" + ) authoring_entity: Optional[List[AuthoringEntityItem]] = Field( None, description="Authoring entity", title="Authoring entity" ) - contributors: Optional[List[ContributorItem]] = Field(None, description="Contributors", title="Contributors") - publisher: Optional[List[PublisherItem]] = Field(None, description="Publisher", title="Publisher") - date_created: Optional[str] = Field(None, description="Date created", title="Date created") + contributors: Optional[List[ContributorItem]] = Field( + None, description="Contributors", title="Contributors" + ) + publisher: Optional[List[PublisherItem]] = Field( + None, description="Publisher", title="Publisher" + ) + date_created: Optional[str] = Field( + None, description="Date created", title="Date created" + ) date_published: Optional[str] = Field(None, title="Date published") date_modified: Optional[str] = Field( - None, description="Date on which the resource was changed.", title="Date last modified" + None, + description="Date on which the resource was changed.", + title="Date last modified", ) version: Optional[str] = Field(None, title="Version") - description: Optional[str] = Field(None, description="Description", title="Description") + description: Optional[str] = Field( + None, description="Description", title="Description" + ) table_columns: Optional[List[TableColumn]] = Field( None, description="List of table column names", title="Table column names" ) - table_rows: Optional[List[TableRow]] = Field(None, description="Table row level data", title="Table row level data") - table_footnotes: Optional[List[TableFootnote]] = Field(None, description="Footnotes", title="Chart footnotes") - table_series: Optional[List[TableSery]] = Field(None, description="Table series", title="Table series") + table_rows: Optional[List[TableRow]] = Field( + None, description="Table row level data", title="Table row level data" + ) + table_footnotes: Optional[List[TableFootnote]] = Field( + None, description="Footnotes", title="Chart footnotes" + ) + table_series: Optional[List[TableSery]] = Field( + None, description="Table series", title="Table series" + ) statistics: Optional[List[Statistic]] = Field(None, title="Statistics") - unit_observation: Optional[List[UnitObservationItem]] = Field(None, title="Unit observation") + unit_observation: Optional[List[UnitObservationItem]] = Field( + None, title="Unit observation" + ) data_sources: Optional[List[DataSource]] = Field(None, title="Data sources") - time_periods: Optional[List[TimePeriod]] = Field(None, description="Time periods", title="Time periods") + time_periods: Optional[List[TimePeriod]] = Field( + None, description="Time periods", title="Time periods" + ) universe: Optional[List[UniverseItem]] = Field(None, title="Universe") ref_country: Optional[List[RefCountryItem]] = Field(None, title="Reference country") geographic_units: Optional[List[GeographicUnit]] = Field( None, - description=( - "List of geographic units (regions, countries, states, provinces, etc.) for which data are available in the" - " database." - ), + description="List of geographic units (regions, countries, states, provinces, etc.) for which data are available in the database.", title="Geographic locations", ) geographic_granularity: Optional[str] = Field( @@ -407,9 +473,13 @@ class TableDescription(SchemaBaseModel): bbox: Optional[List[BboxItem]] = Field(None, title="Geographic bounding box") languages: Optional[List[Language]] = Field(None, description="languages") links: Optional[List[Link]] = Field(None, title="Links") - api_documentation: Optional[List[ApiDocumentationItem]] = Field(None, description="API Documentation") + api_documentation: Optional[List[ApiDocumentationItem]] = Field( + None, description="API Documentation" + ) publications: Optional[List[Publication]] = Field(None, title="Publications") - keywords: Optional[List[KeywordItem]] = Field(None, description="Keywords", title="Keywords") + keywords: Optional[List[KeywordItem]] = Field( + None, description="Keywords", title="Keywords" + ) themes: Optional[List[Theme]] = Field(None, description="Themes") topics: Optional[List[Topic]] = Field( None, @@ -422,48 +492,53 @@ class TableDescription(SchemaBaseModel): title="Disciplines", ) definitions: Optional[List[Definition]] = Field( - None, description="Definitions or concepts covered by the table", title="Definitions" + None, + description="Definitions or concepts covered by the table", + title="Definitions", ) classifications: Optional[List[Classification]] = Field( None, description="Classifications used in the table", title="Classifications" ) rights: Optional[str] = Field(None, title="Rights") license: Optional[List[LicenseItem]] = Field(None, title="License") - citation: Optional[str] = Field(None, description="A bibliographic reference for the resource.", title="Citation") + citation: Optional[str] = Field( + None, + description="A bibliographic reference for the resource.", + title="Citation", + ) confidentiality: Optional[str] = Field(None, title="Confidentiality") sdc: Optional[str] = Field( None, - description=( - "Information on statistical disclosure control measures applied to the table. This can include cell" - " suppression, or other techniques. Specialized packages have been developed for this purpose, like" - " [*sdcTable: Methods for Statistical Disclosure Control in Tabular" - " Data*](https://cran.r-project.org/web/packages/sdcTable/index.html) and" - " https://cran.r-project.org/web/packages/sdcTable/sdcTable.pdf \nThe information provided here should be" - " such that it does not provide intruders with useful information for reverse-engineering the protection" - " measures applied to the table." - ), + description="Information on statistical disclosure control measures applied to the table. This can include cell suppression, or other techniques. Specialized packages have been developed for this purpose, like [*sdcTable: Methods for Statistical Disclosure Control in Tabular Data*](https://cran.r-project.org/web/packages/sdcTable/index.html) and https://cran.r-project.org/web/packages/sdcTable/sdcTable.pdf \nThe information provided here should be such that it does not provide intruders with useful information for reverse-engineering the protection measures applied to the table.", title="Statistical disclosure control", ) - contacts: Optional[List[Contact]] = Field(None, description="Contacts", title="Contacts") + contacts: Optional[List[Contact]] = Field( + None, description="Contacts", title="Contacts" + ) notes: Optional[List[Note]] = Field(None, title="Notes") - relations: Optional[List[Relation]] = Field(None, description="Related documents", title="Relations") + relations: Optional[List[Relation]] = Field( + None, description="Related documents", title="Relations" + ) class Model(SchemaBaseModel): """ Draft Schema for Table data type """ - __metadata_type__ = "table" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" repositoryid: Optional[str] = Field( None, description="Abbreviation for the collection that owns the document", title="Collection ID that owns the document", ) - published: Optional[int] = Field(0, description="Status - 0=draft, 1=published", title="Status") - overwrite: Optional[Overwrite] = Field("no", description="Overwrite document if already exists?") + published: Optional[int] = Field( + 0, description="Status - 0=draft, 1=published", title="Status" + ) + overwrite: Optional[Overwrite] = Field( + "no", description="Overwrite document if already exists?" + ) metadata_information: Optional[MetadataInformation] = Field( None, description="Document description", title="Document metadata information" ) @@ -472,4 +547,6 @@ class Model(SchemaBaseModel): ) provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") tags: Optional[List[Tag]] = Field(None, description="Tags", title="Tags") - additional: Optional[Dict[str, Any]] = Field(None, description="Additional metadata") + additional: Optional[Dict[str, Any]] = Field( + None, description="Additional metadata" + ) diff --git a/pydantic_schemas/tests/test_generators.py b/pydantic_schemas/tests/test_generators.py index cfae612..0b50a89 100644 --- a/pydantic_schemas/tests/test_generators.py +++ b/pydantic_schemas/tests/test_generators.py @@ -9,7 +9,7 @@ def test_yaml_file(): # Load the YAML file - with open("json_to_python_config.yaml", "r") as file: + with open("json_to_python_config.yaml") as file: data = yaml.safe_load(file) # Get the version from importlib.metadata @@ -39,7 +39,7 @@ def test_yaml_file(): details["version"].count(".") == 2 ), f"Version {details['version']} in section {section} is not formatted as digits.digits.digits" assert all( - [x.isdigit() for x in details["version"].split(".")] + x.isdigit() for x in details["version"].split(".") ), f"Version {details['version']} in section {section} is not formatted as digits.digits.digits" diff --git a/pydantic_schemas/tests/test_metadata_manager.py b/pydantic_schemas/tests/test_metadata_manager.py index 13cf2d2..018f351 100644 --- a/pydantic_schemas/tests/test_metadata_manager.py +++ b/pydantic_schemas/tests/test_metadata_manager.py @@ -1,8 +1,7 @@ -from copy import copy from typing import List, Optional import pytest -from pydantic import BaseModel, ValidationError +from pydantic import BaseModel from utils.schema_base_model import SchemaBaseModel from utils.test_utils import assert_pydantic_models_equal, fill_in_pydantic_outline @@ -32,7 +31,7 @@ def test_metadata_by_name(tmpdir, metadata_name): # Save the read metadata to a new file filename2 = tmpdir.join(f"test_{metadata_name}_save.xlsx") - mm.save_metadata_to_excel(object=tmp, filename=filename2, title=metadata_name) + mm.save_metadata_to_excel(metadata_model=tmp, filename=filename2, title=metadata_name) for i in range(10): modl = mm.create_metadata_outline(metadata_name_or_class=metadata_name) @@ -40,13 +39,11 @@ def test_metadata_by_name(tmpdir, metadata_name): # Write filled in metadata filename3 = tmpdir.join(f"test_{metadata_name}_{i}.xlsx") - # filename3 = f"test_{metadata_name}_{i}.xlsx" - mm.save_metadata_to_excel(object=modl, filename=filename3, title=metadata_name) + mm.save_metadata_to_excel(metadata_model=modl, filename=filename3, title=metadata_name) # Read the metadata back actual = mm.read_metadata_from_excel(filename=filename3) assert_pydantic_models_equal(modl, actual) - # assert modl == actual, actual @pytest.mark.parametrize( @@ -59,7 +56,7 @@ def test_metadata_by_class(tmpdir, metadata_name): metadata_class = mm.metadata_class_from_name(metadata_name=metadata_name) # outline from class - outline = mm.create_metadata_outline(metadata_name_or_class=metadata_class) + mm.create_metadata_outline(metadata_name_or_class=metadata_class) # write and read from class filename_class = mm.write_metadata_outline_to_excel( @@ -130,7 +127,7 @@ class TopLevel(SchemaBaseModel): __metadata_type_version__ = "1.0.0" mm = MetadataManager() - filename1 = tmpdir.join(f"test_templates_1.xlsx") + filename1 = tmpdir.join("test_templates_1.xlsx") mm.write_metadata_outline_to_excel(TopLevel, filename=filename1, title="Outline Test") @@ -152,7 +149,7 @@ class TopLevel(SchemaBaseModel): __metadata_type_version__="1.0.0", ) - filename2 = tmpdir.join(f"test_templates_2.xlsx") + filename2 = tmpdir.join("test_templates_2.xlsx") mm.save_metadata_to_excel(example, filename2) assert mm.get_metadata_type_info_from_excel_file(filename2) == { diff --git a/pydantic_schemas/tests/test_pydantic_to_excel.py b/pydantic_schemas/tests/test_pydantic_to_excel.py index 0e39f52..8eab213 100644 --- a/pydantic_schemas/tests/test_pydantic_to_excel.py +++ b/pydantic_schemas/tests/test_pydantic_to_excel.py @@ -2,7 +2,6 @@ from enum import Enum from typing import Any, Dict, List, Optional, Union -import pandas as pd import pytest from pydantic import BaseModel, Field from utils.schema_base_model import SchemaBaseModel @@ -21,16 +20,9 @@ excel_single_sheet_to_pydantic, ) from pydantic_schemas.utils.pydantic_to_excel import ( - correct_column_widths, - create_sheet, create_version, - open_or_create_workbook, parse_version, - shade_80_rows_and_protect_sheet, - shade_locked_cells, write_across_many_sheets, - write_pydantic_to_sheet, - write_title_and_version_info, write_to_single_sheet, ) from pydantic_schemas.utils.quick_start import make_skeleton @@ -47,7 +39,7 @@ class Simple(SchemaBaseModel): idno="AVal", title="BVal", author="CVal", __metadata_type__="simple", __metadata_type_version__="1.0" ) - filename = tmpdir.join(f"integration_test_simple_schema_.xlsx") + filename = tmpdir.join("integration_test_simple_schema_.xlsx") write_to_single_sheet(filename, simple_original, "simple_original", "Simple Metadata") parsed_simple = excel_sheet_to_pydantic(filename, "metadata", Simple) @@ -75,7 +67,7 @@ class ProductionAndCountries(SchemaBaseModel): __metadata_type_version__="1.0", ) - filename = tmpdir.join(f"integration_test_two_layer_simple_schema.xlsx") + filename = tmpdir.join("integration_test_two_layer_simple_schema.xlsx") write_to_single_sheet(filename, inp, "ProductionAndCountries", "Production and Countries") parsed_outp = excel_sheet_to_pydantic(filename, "metadata", ProductionAndCountries) @@ -126,7 +118,7 @@ class ProductionAndCountries(SchemaBaseModel): __metadata_type_version__="1.0", ) - filename = tmpdir.join(f"integration_test_multilayer_simple_schema_.xlsx") + filename = tmpdir.join("integration_test_multilayer_simple_schema_.xlsx") write_to_single_sheet(filename, inp, "ProductionAndCountries", "Production and Countries") parsed_outp = excel_sheet_to_pydantic(filename, "metadata", ProductionAndCountries) assert parsed_outp == inp, parsed_outp @@ -144,7 +136,7 @@ class Production(SchemaBaseModel): original_production = Production(idno="", subtitle=None, author="author", deprecatedFeature="toberemoved") - filename = tmpdir.join(f"integration_test_optional_missing_deprecated_new_simple_.xlsx") + filename = tmpdir.join("integration_test_optional_missing_deprecated_new_simple_.xlsx") write_to_single_sheet(filename, original_production, "Production", "Production") class Production(SchemaBaseModel): @@ -189,7 +181,7 @@ class ProductionAndCountries(SchemaBaseModel): __metadata_type_version__="1.0", ) - filename = tmpdir.join(f"integration_test_optional_missing_deprecated_new_two_level_.xlsx") + filename = tmpdir.join("integration_test_optional_missing_deprecated_new_two_level_.xlsx") write_to_single_sheet( filename, example_production_and_country, "ProductionAndCountries", "Production and Countries" @@ -276,7 +268,7 @@ class ProductionAndCountries(SchemaBaseModel): __metadata_type_version__="1.0", ) - filename = tmpdir.join(f"integration_test_lists_.xlsx") + filename = tmpdir.join("integration_test_lists_.xlsx") # filename = "integration_test_lists_.xlsx" write_to_single_sheet( filename, example_production_and_country, "ProductionAndCountries", "Production and Countries" @@ -341,8 +333,7 @@ class ProductionAndCountries(SchemaBaseModel): __metadata_type_version__="1.0", ) - filename = tmpdir.join(f"integration_test_optional_missing_deprecated_new_two_level_.xlsx") - # filename = f"integration_test_optional_missing_deprecated_new_two_level_.xlsx" + filename = tmpdir.join("integration_test_optional_missing_deprecated_new_two_level_.xlsx") write_across_many_sheets( filename, example_production_and_country, "ProductionAndCountries", "Production and Countries" ) @@ -401,7 +392,7 @@ class MicrodataSchema(SchemaBaseModel): __metadata_type__="microdata", __metadata_type_version__="1.0", ) - filename = tmpdir.join(f"integration_test_union_list_.xlsx") + filename = tmpdir.join("integration_test_union_list_.xlsx") write_across_many_sheets(filename, ms, "UnionList", "Looking at a union with a list") parsed_outp = excel_doc_to_pydantic(filename, MicrodataSchema) @@ -423,7 +414,7 @@ class WithDict(SchemaBaseModel): __metadata_type__="with_dict", __metadata_type_version__="1.0", ) - filename = tmpdir.join(f"integration_test_dictionaries_.xlsx") + filename = tmpdir.join("integration_test_dictionaries_.xlsx") write_across_many_sheets(filename, wd, "WithDict", "Looking at dictionaries") parsed_outp = excel_doc_to_pydantic(filename, WithDict) @@ -505,12 +496,7 @@ class MetaDataOfVariousHierarchies(SchemaBaseModel): __metadata_type_version__="1.0", ) - # index = pd.MultiIndex.from_tuples([("identification_info", "citation", "title"), ("identification_info", "citation", "alternateTitle"), ("service_identification", "restrictions", "legalConstraints", "useLimitation"), ("service_identification", "restrictions", "legalConstraints", "accessConstraints")]) - - # expected = pd.DataFrame([["citation_title", None], ["alt_title_1", "alt_title_2"], [[], None], [[], None]], index=index) - - filename = tmpdir.join(f"integration_test_list_of_lists_.xlsx") - # filename = "integration_test_list_of_lists_.xlsx" + filename = tmpdir.join("integration_test_list_of_lists_.xlsx") if os.path.exists(filename): os.remove(filename) write_across_many_sheets(filename, inp, "ListOfLists", "Looking at lists of lists") @@ -518,19 +504,12 @@ class MetaDataOfVariousHierarchies(SchemaBaseModel): expected = inp expected.citation.alternateTitle = None actual = excel_doc_to_pydantic(filename, MetaDataOfVariousHierarchies, verbose=True) - # assert actual == inp, actual - # outp = pydantic_to_dataframe(inp) - # actual = outp[0] - # list_indices = outp[1] - # enums = outp[2] assert expected.citation == actual.citation, actual.citation assert expected.identification_info == actual.identification_info, actual.identification_info assert expected.service_identification == actual.service_identification, actual.service_identification assert expected.lst == actual.lst, actual.lst assert expected == actual, actual - # assert list_indices == [1, 2, 3], list_indices - # assert enums == {}, enums NAME_TO_TYPE = { @@ -550,18 +529,16 @@ class MetaDataOfVariousHierarchies(SchemaBaseModel): } -@pytest.mark.parametrize("name, type_writer_reader", [(k, v) for k, v in NAME_TO_TYPE.items()]) +@pytest.mark.parametrize("name, type_writer_reader", tuple((k, v) for k, v in NAME_TO_TYPE.items())) def test_write_real_skeleton(tmpdir, name, type_writer_reader): - type, writer, reader = type_writer_reader - # folder = "excel_sheets" + schema, writer, reader = type_writer_reader filename = os.path.join(tmpdir, f"{name}_metadata.xlsx") - # filename = f"{name}_metadata_real_sckele.xlsx" if os.path.exists(filename): os.remove(filename) - ob = make_skeleton(type) + ob = make_skeleton(schema) writer(filename, ob, name, f"{name} Metadata") - reader(filename, type, verbose=True) + reader(filename, schema, verbose=True) # assert False diff --git a/pydantic_schemas/tests/test_pydantic_to_pandas.py b/pydantic_schemas/tests/test_pydantic_to_pandas.py index e46696b..bac613f 100644 --- a/pydantic_schemas/tests/test_pydantic_to_pandas.py +++ b/pydantic_schemas/tests/test_pydantic_to_pandas.py @@ -277,42 +277,44 @@ class Embedding(BaseModel): emb = Embedding(id="sjc", description="ekjrv", date="2024-01-01", vector={"1": "a", "2": "b"}) df, _, _ = pydantic_to_dataframe(emb, debug=True) - assert df.loc["id"].values[0][0] == "sjc", df.loc["id"] - assert df.loc["description"].values[0][0] == "ekjrv", df.loc["description"] - assert df.loc["date"].values[0][0] == "2024-01-01", df.loc["date"] - assert df.loc["vector"].loc["key"].values[0] == "1", df.loc["vector"].loc["key"] - assert df.loc["vector"].loc["key"].values[1] == "2", df.loc["vector"].loc["key"] - assert df.loc["vector"].loc["value"].values[0] == "a", df.loc["vector"].loc["value"] - assert df.loc["vector"].loc["value"].values[1] == "b", df.loc["vector"].loc["value"] + assert df.loc["id"].to_numpy()[0][0] == "sjc", df.loc["id"] + assert df.loc["description"].to_numpy()[0][0] == "ekjrv", df.loc["description"] + assert df.loc["date"].to_numpy()[0][0] == "2024-01-01", df.loc["date"] + assert df.loc["vector"].loc["key"].to_numpy()[0] == "1", df.loc["vector"].loc["key"] + assert df.loc["vector"].loc["key"].to_numpy()[1] == "2", df.loc["vector"].loc["key"] + assert df.loc["vector"].loc["value"].to_numpy()[0] == "a", df.loc["vector"].loc["value"] + assert df.loc["vector"].loc["value"].to_numpy()[1] == "b", df.loc["vector"].loc["value"] emb = Embedding(id="sjc", description="ekjrv", date="2024-01-01", vector=[1, 2, 3]) df, _, _ = pydantic_to_dataframe(emb, debug=True) - assert df.loc["id"].values[0] == "sjc", df.loc["id"] - assert df.loc["description"].values[0] == "ekjrv", df.loc["description"] - assert df.loc["date"].values[0] == "2024-01-01", df.loc["date"] - assert df.loc["vector"].values[0] == 1, df.loc["vector"] - assert df.loc["vector"].values[1] == 2, df.loc["vector"] - assert df.loc["vector"].values[2] == 3, df.loc["vector"] + assert df.loc["id"].to_numpy()[0] == "sjc", df.loc["id"] + assert df.loc["description"].to_numpy()[0] == "ekjrv", df.loc["description"] + assert df.loc["date"].to_numpy()[0] == "2024-01-01", df.loc["date"] + assert df.loc["vector"].to_numpy()[0] == 1, df.loc["vector"] + assert df.loc["vector"].to_numpy()[1] == 2, df.loc["vector"] + assert df.loc["vector"].to_numpy()[2] == 3, df.loc["vector"] # # lists of embeddings - # TODO make a list of dicts work + # noqa: ERA001 + # + # TODO(gblackadder): make a list of dicts work # class Parent(BaseModel): # embeddings: Optional[List[Embedding]] = Field(None, description="Word embeddings", title="Word embeddings") - + # # emb = make_skeleton(Parent) # df, _, _ = pydantic_to_dataframe(emb, debug=True) - + # # emb = Parent(embeddings=[Embedding(id="sjc", description="ekjrv", date="2024-01-01", vector={"1": "a", "2": "b"})]) # df, _, _ = pydantic_to_dataframe(emb, debug=True) - # assert df.loc["embeddings"].loc["id"].values[0][0] == "sjc", df.loc["embeddings"].loc["id"] - # assert df.loc["embeddings"].loc["description"].values[0][0] == "ekjrv", df.loc["embeddings"].loc["description"] - # assert df.loc["embeddings"].loc["date"].values[0][0] == "2024-01-01", df.loc["embeddings"].loc["date"] + # assert df.loc["embeddings"].loc["id"].to_numpy()[0][0] == "sjc", df.loc["embeddings"].loc["id"] + # assert df.loc["embeddings"].loc["description"].to_numpy()[0][0] == "ekjrv", df.loc["embeddings"].loc["description"] + # assert df.loc["embeddings"].loc["date"].to_numpy()[0][0] == "2024-01-01", df.loc["embeddings"].loc["date"] # # assert False, df.loc["embeddings"] - # assert df.loc["embeddings"].loc["vector"].loc["key"].values[0] == "1", df.loc["embeddings"].loc["vector"].loc["key"] - # assert df.loc["embeddings"].loc["vector"].loc["key"].values[1] == "2", df.loc["embeddings"].loc["vector"].loc["key"] - # assert df.loc["embeddings"].loc["vector"].loc["value"].values[0] == "a", ( + # assert df.loc["embeddings"].loc["vector"].loc["key"].to_numpy()[0] == "1", df.loc["embeddings"].loc["vector"].loc["key"] + # assert df.loc["embeddings"].loc["vector"].loc["key"].to_numpy()[1] == "2", df.loc["embeddings"].loc["vector"].loc["key"] + # assert df.loc["embeddings"].loc["vector"].loc["value"].to_numpy()[0] == "a", ( # df.loc["embeddings"].loc["vector"].loc["value"] # ) - # assert df.loc["embeddings"].loc["vector"].loc["value"].values[1] == "b", ( + # assert df.loc["embeddings"].loc["vector"].loc["value"].to_numpy()[1] == "b", ( # df.loc["embeddings"].loc["vector"].loc["value"] # ) diff --git a/pydantic_schemas/tests/test_quick_start.py b/pydantic_schemas/tests/test_quick_start.py index 8dd77fa..b467820 100644 --- a/pydantic_schemas/tests/test_quick_start.py +++ b/pydantic_schemas/tests/test_quick_start.py @@ -5,7 +5,10 @@ from pydantic import AnyUrl, BaseModel, Field, confloat from pydantic_schemas.metadata_manager import MetadataManager -from pydantic_schemas.utils.quick_start import DEFAULT_URL, make_skeleton # create_empty_schema_from_path, +from pydantic_schemas.utils.quick_start import ( # create_empty_schema_from_path, + DEFAULT_URL, + make_skeleton, +) def test_simple_strings(): @@ -227,7 +230,6 @@ class RegistryEntry(BaseModel): def test_fieldname_is_protected(): class BadFieldNames(BaseModel): from_: str = Field(..., alias="from") - # import_: str other: str expected = BadFieldNames(**{"from": "", "other": ""}) @@ -244,7 +246,7 @@ class Production(BaseModel): productions: Optional["Production"] = None # Forward reference Production.model_rebuild() - ob = make_skeleton(Production) + make_skeleton(Production) class ProductionWithList(BaseModel): idno: Optional[str] = None @@ -254,10 +256,10 @@ class ProductionWithList(BaseModel): productions: Optional[List["Production"]] = None # Forward reference ProductionWithList.model_rebuild() - ob = make_skeleton(ProductionWithList) + make_skeleton(ProductionWithList) -@pytest.mark.parametrize("n", [n for n in MetadataManager().metadata_type_names]) +@pytest.mark.parametrize("n", (n for n in MetadataManager().metadata_type_names)) def test_actual_schemas(n): if n == "geospatial": return diff --git a/pydantic_schemas/utils/excel_to_pydantic.py b/pydantic_schemas/utils/excel_to_pydantic.py index ebe6ba5..2566ca9 100644 --- a/pydantic_schemas/utils/excel_to_pydantic.py +++ b/pydantic_schemas/utils/excel_to_pydantic.py @@ -1,5 +1,4 @@ import json -import warnings from typing import Annotated, Any, List, Optional, Type, Union, get_args, get_origin import numpy as np @@ -47,33 +46,13 @@ def find_string_and_count_nans(arr, search_str): return int(index), nan_count -# def is_horizontally_organized(m: Type[BaseModel], df: pd.DataFrame): -# """True if the index is along the top with the values below. False if the index is on the left side with the values to the right""" -# rows, cols = df.shape -# if rows == 1: -# return True -# elif cols == 1: -# return False - -# print("is_horizontally_organized is looking at ", m) -# if is_list_annotation(m): -# m = get_subtype_of_optional_or_list(m) -# expected_fields = m.model_json_schema()["properties"].keys() -# fields_if_horizontally_arranged = df.iloc[0, :].values -# fields_if_vertically_arranged = df.iloc[:, 0].values - -# horizontal_intersection = len(set(expected_fields).intersection(fields_if_horizontally_arranged)) -# vertical_intersection = len(set(expected_fields).intersection(fields_if_vertically_arranged)) -# return horizontal_intersection > vertical_intersection - - def get_relevant_sub_frame(m: Type[BaseModel], df: pd.DataFrame, name_of_field: Optional[str] = None, debug=False): """ THe dataframe likely contains lots and lots of information about other models. THis function obtains only that information that pertains to this model """ - names = df.iloc[:, 0].values + names = df.iloc[:, 0].to_numpy() if debug: print(f"getting subframe for {m} or {name_of_field} given {names}") try: @@ -94,9 +73,8 @@ def get_relevant_sub_frame(m: Type[BaseModel], df: pd.DataFrame, name_of_field: error_message += f"and '{name_of_field}' " error_message += f"not found in {names}" raise IndexError(error_message) - else: - if debug: - print(f"get relevant sub frame sze={sze}, idx={idx}") + if debug: + print(f"get relevant sub frame sze={sze}, idx={idx}") sub = df.iloc[idx : idx + sze + 1, 1:] if debug: @@ -105,14 +83,11 @@ def get_relevant_sub_frame(m: Type[BaseModel], df: pd.DataFrame, name_of_field: sub = sub.dropna(how="all", axis=1) # drop all null columns if debug: print("SubFrame = \n", sub) - # if is_horizontally_organized(m, sub): - # sub = sub.T return sub def handle_optional(name, annotation, df, from_within_list: bool = False, debug=False): args = [a for a in get_args(annotation) if a is not type(None)] - # assert len(args) == 1, f"handle_optional encountered {args}" if len(args) > 1: list_args = [a for a in args if is_list_annotation(a)] if len(list_args): @@ -129,13 +104,11 @@ def handle_optional(name, annotation, df, from_within_list: bool = False, debug= if debug: print(f"optional ret: {ret}") print(f"isinstance(ret, list): {isinstance(ret, list)}") - # print(f"len(ret): {len(ret)}") - if (isinstance(ret, list) or isinstance(ret, dict)) and len(ret) == 0: + if isinstance(ret, (list, dict)) and len(ret) == 0: return None - elif isinstance(ret, str) and ret == "": + if isinstance(ret, str) and ret == "": return None - else: - return ret + return ret def handle_list(name, anno, df, debug=False): @@ -174,12 +147,10 @@ def handle_list(name, anno, df, debug=False): print(f"instantiated: {sub}") list_of_subs.append(sub) return list_of_subs - # raise NotImplementedError(f"handle_list - {name}, {anno}, {subframe}") - else: - values = df.set_index(df.columns[0]).loc[name] - if debug: - print(f"handle_list anno:{anno}, value: {values}") - return [v for v in values if v is not None] + values = df.set_index(df.columns[0]).loc[name] + if debug: + print(f"handle_list anno:{anno}, value: {values}") + return [v for v in values if v is not None] def handle_list_within_list(name, anno, df, debug=False): @@ -201,17 +172,17 @@ def handle_list_within_list(name, anno, df, debug=False): if debug: print(f"getting entry for '{name}'") print(values) - values = values.values[-1] # , df.columns[1] + values = values.to_numpy()[-1] # , df.columns[1] if debug: print(f"values: {values}, {type(values)}") if values is None: return [] try: values = json.loads(values.replace("'", '"').replace("None", "null")) - except json.JSONDecodeError as e: + except json.JSONDecodeError: try: values = json.loads(values.replace("None", "null")) - except json.JSONDecodeError as e: + except json.JSONDecodeError: try: appostrophe_string = "__APOSTROPHE__" values = json.loads( @@ -223,18 +194,16 @@ def handle_list_within_list(name, anno, df, debug=False): except json.JSONDecodeError as e: raise ValueError(f"cannot decode {name}:{anno} with values {values}") from e if debug: - print(f"decoded values:", values) + print("decoded values:", values) if len(values) == 0: return [] sub_type = get_subtype_of_optional_or_list(anno) - is_dicts = any([isinstance(v, dict) for v in values]) + is_dicts = any(isinstance(v, dict) for v in values) if is_dicts and annotation_contains_pydantic(sub_type): return [sub_type(**standardize_keys_in_dict(v)) for v in values] - elif not is_dicts and not annotation_contains_pydantic(sub_type): - # return [sub_type(v) for v in values] + if not is_dicts and not annotation_contains_pydantic(sub_type): return values - else: - raise NotImplementedError(f"handle_list_within_list unexpected values - {name}, {anno}, {values}, {df}") + raise NotImplementedError(f"handle_list_within_list unexpected values - {name}, {anno}, {values}, {df}") def handle_builtin_or_enum(name, anno, df, debug=False): @@ -245,7 +214,6 @@ def handle_builtin_or_enum(name, anno, df, debug=False): df_indexed = df.set_index(df.columns[0]) if debug: print("handle_builtin_or_enum", df_indexed) - # return df_indexed.loc[name, df.columns[1]] if name not in df_indexed.index: return "" values = df_indexed.loc[name] @@ -254,14 +222,13 @@ def handle_builtin_or_enum(name, anno, df, debug=False): values = [v for v in values if v is not None] if len(values) == 0: return "" - elif len(values) >= 2: + if len(values) >= 2: raise ValueError(f"Expected only a single value but got {values}") - else: - return values[0] + return values[0] def handle_dict(name, anno, df): - dictionary_type = create_model(name, **{"key": (Optional[List[str]], None), "value": (Optional[List[Any]], None)}) + dictionary_type = create_model(name, key=(Optional[List[str]], None), value=(Optional[List[Any]], None)) dict_results = annotation_switch(name, dictionary_type, df) if ( dict_results.key is None @@ -270,10 +237,7 @@ def handle_dict(name, anno, df): or len(dict_results.value) == 0 ): return {} - else: - ret = {k: v for k, v in zip(dict_results.key, dict_results.value) if k is not None} - return ret - # raise NotImplementedError(f"Dictionary: {name}, {anno}, {dict_results}, {ret}") + return {k: v for k, v in zip(dict_results.key, dict_results.value) if k is not None} def annotation_switch(name: str, anno, df: pd.DataFrame, from_within_list=False, debug=False) -> Any: @@ -283,18 +247,17 @@ def annotation_switch(name: str, anno, df: pd.DataFrame, from_within_list=False, if debug: print("optional") return handle_optional(name, anno, df, from_within_list=from_within_list, debug=debug) - elif is_dict_annotation(anno): + if is_dict_annotation(anno): return handle_dict(name, anno, df) - elif is_list_annotation(anno): + if is_list_annotation(anno): if from_within_list: if debug: print("list within a list") return handle_list_within_list(name, anno, df, debug=debug) - else: - if debug: - print("list") - return handle_list(name, anno, df, debug=debug) - elif isinstance(anno, type(BaseModel)): + if debug: + print("list") + return handle_list(name, anno, df, debug=debug) + if isinstance(anno, type(BaseModel)): if debug: print("pydantic") print(anno) @@ -308,17 +271,16 @@ def annotation_switch(name: str, anno, df: pd.DataFrame, from_within_list=False, except IndexError: return make_skeleton(anno) return instantiate_pydantic_object(anno, sub, from_within_list=from_within_list, debug=debug) - elif len(get_args(anno)) == 0: + if len(get_args(anno)) == 0: if debug: print("builtin or enum") return handle_builtin_or_enum(name, anno, df) - elif get_origin(anno) is Annotated: + if get_origin(anno) is Annotated: if debug: print(f"got Annotated type: {anno}, treating as builtin or enum") datatype = getattr(anno, "__origin__", None) return handle_builtin_or_enum(name, datatype, df) - else: - raise NotImplementedError(anno) + raise NotImplementedError(anno) def instantiate_pydantic_object( @@ -344,12 +306,7 @@ def excel_sheet_to_pydantic( if debug: print(f"excel_sheet_to_pydantic, sheetname={sheetname}, model_type={model_type}") df = pd.read_excel(filename, sheet_name=sheetname, header=None) - df = df.where(df.notnull(), None) - # if sheetname != "metadata" and sheetname != "additional": - # try: - # df = get_relevant_sub_frame(model_type, df, debug=debug) - # except (KeyError, IndexError): - # pass + df = df.where(df.notna(), None) if debug: print("line 304", model_type) print(df) @@ -357,8 +314,7 @@ def excel_sheet_to_pydantic( if is_optional_annotation(model_type): if not annotation_contains_pydantic(model_type): return handle_optional(df.iloc[0, 0], model_type, df, debug=debug) - else: - model_type = [x for x in get_args(model_type) if x is not type(None)][0] + model_type = [x for x in get_args(model_type) if x is not type(None)][0] if is_list_annotation(model_type): return handle_list(df.iloc[0, 0], model_type, df, debug=debug) @@ -387,7 +343,7 @@ def excel_sheet_to_pydantic( anno = model_type.model_fields[name].annotation ret[name] = annotation_switch(name, anno, df, from_within_list=False, debug=debug) for k, v in ret.items(): - if isinstance(v, list) or isinstance(v, np.ndarray): + if isinstance(v, (list, np.ndarray)): ret[k] = [elem for elem in v if elem is not None] if debug: print(ret) diff --git a/pydantic_schemas/utils/pydantic_to_excel.py b/pydantic_schemas/utils/pydantic_to_excel.py index 0b2d2ce..b22ffc9 100644 --- a/pydantic_schemas/utils/pydantic_to_excel.py +++ b/pydantic_schemas/utils/pydantic_to_excel.py @@ -146,9 +146,7 @@ def replace_row_with_multiple_rows(original_df, new_df, row_to_replace): df_after = original_df.loc[row_to_replace:].drop(row_to_replace, axis=0) # Concatenate the parts with the new rows - df_replaced = pd.concat([df_before, new_df, df_after]) - # df_replaced = df_replaced.dropna(how="all", axis=1) - return df_replaced + return pd.concat([df_before, new_df, df_after]) def count_lists(model_fields, idx: str): @@ -160,15 +158,11 @@ def count_lists(model_fields, idx: str): for part in idx.split("."): try: anno = model_fields[part].annotation - except KeyError: - raise KeyError(f"bad model fields given {idx}, for {part} of {model_fields}") + except KeyError as e: + raise KeyError(f"bad model fields given {idx}, for {part} of {model_fields}") from e n_lists += annotation_contains_list(anno) if is_optional_annotation(anno) or is_list_annotation(anno): anno = get_subtype_of_optional_or_list(anno) - # if hasattr(anno, "model_fields"): - # model_fields = anno.model_fields - # else: - # break if hasattr(anno, "model_fields"): model_fields = anno.model_fields else: @@ -190,12 +184,12 @@ def pydantic_to_dataframe( if isinstance(ob, list): ob_dict = [elem.model_dump() for elem in ob] annotations = {k: v.annotation for k, v in ob[0].model_fields.items()} - model_fields = {k: v for k, v in ob[0].model_fields.items()} + model_fields = ob[0].model_fields is_list_of_objects = True else: ob_dict = ob.model_dump() annotations = {k: v.annotation for k, v in ob.model_fields.items()} - model_fields = {k: v for k, v in ob.model_fields.items()} + model_fields = ob.model_fields is_list_of_objects = False df = pd.json_normalize(ob_dict).T if debug: @@ -225,7 +219,6 @@ def pydantic_to_dataframe( if debug: print(f"annotation contains dict, {ob_dict[idx.split('.')[0]]}") fieldname = idx.split(".")[0] - # field = ob_dict[fieldname] subdf = df[df.index.str.startswith(f"{fieldname}.")] field = {"".join(i.split(".")[1:]): v[0] for i, v in zip(subdf.index, subdf.values)} if debug: @@ -248,7 +241,7 @@ def pydantic_to_dataframe( dict_df = pd.DataFrame([field.keys(), field.values()], index=["key", "value"]) if debug: print(f"created a dict_df:\n{dict_df}") - dict_df.index = dict_df.index.map(lambda x: f"{fieldname}.{x}") + dict_df.index = dict_df.index.map(lambda x, fieldname=fieldname: f"{fieldname}.{x}") df = df[~df.index.str.startswith(f"{fieldname}.")] df = df[df.index != fieldname] df = pd.concat([df, dict_df]) @@ -260,8 +253,6 @@ def pydantic_to_dataframe( if number_of_lists >= 1: #: or annotation_contains_dict(annotations[idx.split(".")[0]]): # if number_of_lists > 0: subtype = anno - # else: - # subtype = dict if debug: print("subtype = ", subtype) print("isinstance(subtype, BaseModel)", isinstance(subtype, type(BaseModel))) @@ -271,28 +262,18 @@ def pydantic_to_dataframe( print("list of lists") list_indices.append(i) i += 1 - # elif number_of_lists == 0: # dicts - # list_indices += list(range(i, i + 2)) - # if debug: - # print(list_indices) - # i += 2 elif isinstance(subtype, type(BaseModel)): # isinstance(subtype, type(dict)) if debug: print("list of base models", vals, vals[0]) print("experiment:", vals[0]) print("experiment:", pd.DataFrame(vals[0]).T) - if vals[0] is None: - vals[0] = [None] - elif isinstance(vals[0], list) and len(vals[0]) == 0: + if vals[0] is None or isinstance(vals[0], list) and len(vals[0]) == 0: vals[0] = [None] sub = pd.json_normalize(vals[0]).T if debug: print(sub) - # if len(sub.index) == 1: - # sub.index = [idx] - # else: - sub.index = sub.index.map(lambda x: f"{idx}." + x) + sub.index = sub.index.map(lambda x, idx=idx: f"{idx}." + x) if debug: print(sub) df = replace_row_with_multiple_rows(df, sub, idx) @@ -309,15 +290,13 @@ def pydantic_to_dataframe( else: if debug: print("list of builtins or else empty") - if vals[0] is None: - vals[0] = [None] - elif isinstance(vals[0], list) and len(vals[0]) == 0: + if vals[0] is None or isinstance(vals[0], list) and len(vals[0]) == 0: vals[0] = [None] sub = pd.DataFrame(vals[0]).T if len(sub.index) == 1: sub.index = [idx] else: - sub.index = sub.index.map(lambda x: f"{idx}." + x) + sub.index = sub.index.map(lambda x, idx=idx: f"{idx}." + x) df = replace_row_with_multiple_rows(df, sub, idx) if debug: print("new df:", df) @@ -347,21 +326,19 @@ def pydantic_to_dataframe( def stringify_enum(elem): if isinstance(elem, Enum): return str(elem.value) - else: - raise TypeError(f"{elem} is not an enum") + raise TypeError(f"{elem} is not an enum") def stringify_cell_element(elem): if isinstance(elem, list): return json.dumps(elem, default=stringify_enum) - elif isinstance(elem, Enum): + if isinstance(elem, Enum): return str(elem.value) - elif isinstance(elem, dict): + if isinstance(elem, dict): return json.dumps(elem, default=stringify_enum) - elif isinstance(elem, AnyUrl): + if isinstance(elem, AnyUrl): return elem.unicode_string() - else: - return elem + return elem def write_pydantic_to_excel(ws, ob, row_number, debug=False): @@ -371,13 +348,13 @@ def write_pydantic_to_excel(ws, ob, row_number, debug=False): for i, r in enumerate(dataframe_to_rows(df, index=True, header=False)): if debug: print(r) - if all(map(lambda x: x is None, r)): + if all(x is None for x in r): continue - r = [stringify_cell_element(val) for val in r] - r = [""] + r + string_r = [stringify_cell_element(val) for val in r] + string_r = [""] + string_r if debug: - print("about to append", r) - ws.append(r) + print("about to append", string_r) + ws.append(string_r) for col in range(2, df.index.nlevels + 2): cell = ws.cell(row=row_number, column=col) cell.font = Font(bold=True) diff --git a/pydantic_schemas/utils/quick_start.py b/pydantic_schemas/utils/quick_start.py index f5155f7..f1b82df 100644 --- a/pydantic_schemas/utils/quick_start.py +++ b/pydantic_schemas/utils/quick_start.py @@ -1,8 +1,7 @@ -import importlib import inspect import typing from enum import Enum -from typing import Any, Callable, Dict, List, Type +from typing import Any, Callable, List, Type from pydantic import AnyUrl, BaseModel @@ -22,10 +21,7 @@ def _is_typing_annotation(annotation): # Handle special cases for generic types like List[int], Dict[str, int], etc. origin = getattr(annotation, "__origin__", None) - if origin and getattr(origin, "__module__", None) == "typing": - return True - - return False + return origin and getattr(origin, "__module__", None) == "typing" def _is_builtin_type(tp): @@ -76,32 +72,28 @@ def _create_default_class_from_annotation( print(" " * recursion_level, "STR") if is_optional: return None - else: - return "" - elif p is float: + return "" + if p is float: if debug: print(" " * recursion_level, "STR") if is_optional: return None - else: - raise ValueError("Cannot create default float as it's not optional") - elif _is_enum_type(p): + raise ValueError("Cannot create default float as it's not optional") + if _is_enum_type(p): if debug: print(" " * recursion_level, "ENUM") if is_optional: return None - else: - return list(p)[0].value # get first value of the enum - elif _is_pydantic_subclass(p) and recursion_level < MAX_DEPTH: + return list(p)[0].value # get first value of the enum + if _is_pydantic_subclass(p) and recursion_level < MAX_DEPTH: if debug: print(" " * recursion_level, "pydantic CLASS") return make_skeleton(p, debug=debug, recursion_level=recursion_level + 1) - elif _is_pydantic_subclass(p) and is_optional: + if _is_pydantic_subclass(p) and is_optional: return None - elif isinstance(p, type(AnyUrl)): + if isinstance(p, type(AnyUrl)): return DEFAULT_URL - else: - raise ValueError(f"Unknown annotation: {p}") + raise ValueError(f"Unknown annotation: {p}") def _create_default_from_list_of_args(args: List[Any], is_optional=True, debug=False, recursion_level=0): @@ -133,34 +125,29 @@ def _create_default_from_list_of_args(args: List[Any], is_optional=True, debug=F return _create_default_from_typing_annotation( chosen_type, is_optional=is_optional, debug=debug, recursion_level=recursion_level ) - elif len(pydantic_args): + if len(pydantic_args): return make_skeleton(pydantic_args[0], debug=debug, recursion_level=recursion_level + 1) - elif len(_filter_list_for_condition(args, lambda a: _is_builtin_type(a) or _is_enum_type(a))): + if len(_filter_list_for_condition(args, lambda a: _is_builtin_type(a) or _is_enum_type(a))): if debug: print(" " * recursion_level, "all builtins or enums") if is_optional: return None - elif len(_filter_list_for_condition(args, lambda a: a is str)): + if len(_filter_list_for_condition(args, lambda a: a is str)): return "" - else: - raise ValueError(f"Can't create a default of {args}") - elif len(args) == 1 and _is_pydantic_annotated_string(args[0], debug=debug, recursion_level=recursion_level): + raise ValueError(f"Can't create a default of {args}") + if len(args) == 1 and _is_pydantic_annotated_string(args[0], debug=debug, recursion_level=recursion_level): if is_optional: return None - else: - return "" - elif len(args) == 1 and _is_pydantic_annotated_float(args[0], debug=debug, recursion_level=recursion_level): + return "" + if len(args) == 1 and _is_pydantic_annotated_float(args[0], debug=debug, recursion_level=recursion_level): if is_optional: return None - else: - raise ValueError(f"Can't create a default of {args}") - elif len(args) == 1 and isinstance(args[0], type(AnyUrl)): + raise ValueError(f"Can't create a default of {args}") + if len(args) == 1 and isinstance(args[0], type(AnyUrl)): if is_optional: return None - else: - return DEFAULT_URL - else: - raise ValueError(f"Can't create a default of {args}") + return DEFAULT_URL + raise ValueError(f"Can't create a default of {args}") def _create_default_from_typing_annotation(p: Any, is_optional: bool = False, debug: bool = False, recursion_level=0): @@ -178,30 +165,27 @@ def _create_default_from_typing_annotation(p: Any, is_optional: bool = False, de if recursion_level >= MAX_DEPTH: return None return _create_default_from_list_of_args(args, is_optional=True, debug=debug, recursion_level=recursion_level) - elif getattr(p, "__origin__", None) is list: + if getattr(p, "__origin__", None) is list: if debug: print(" " * recursion_level, "isLIST") if _is_pydantic_subclass(args[0]): return [make_skeleton(args[0], debug=debug, recursion_level=recursion_level + 1)] - else: - if is_optional: - return [] - else: - return [_create_default(args[0], is_optional=False, debug=debug, recursion_level=recursion_level + 1)] - elif getattr(p, "__origin__", None) is dict: + if is_optional: + return [] + return [_create_default(args[0], is_optional=False, debug=debug, recursion_level=recursion_level + 1)] + if getattr(p, "__origin__", None) is dict: if debug: print(" " * recursion_level, "isDICT") k = _create_default(args[0], debug=debug, recursion_level=recursion_level + 1) v = _create_default(args[1], debug=debug, recursion_level=recursion_level + 1) return {k: v} - elif len(args) > 1: + if len(args) > 1: if debug: print(" " * recursion_level, "isUNION") return _create_default_from_list_of_args( args, is_optional=is_optional, debug=debug, recursion_level=recursion_level ) - else: - raise ValueError(f"Unknown typing {p}") + raise ValueError(f"Unknown typing {p}") def _create_default(p: inspect.Parameter, is_optional: bool = False, debug: bool = False, recursion_level: int = 0): @@ -213,21 +197,19 @@ def _create_default(p: inspect.Parameter, is_optional: bool = False, debug: bool return _create_default_class_from_annotation( p, is_optional=is_optional, debug=debug, recursion_level=recursion_level ) - elif _is_typing_annotation(p): + if _is_typing_annotation(p): if debug: print(" " * recursion_level, "TYPED") return _create_default_from_typing_annotation( p, is_optional=is_optional, debug=debug, recursion_level=recursion_level ) - elif _is_pydantic_annotated_string(p, debug=debug, recursion_level=recursion_level): + if _is_pydantic_annotated_string(p, debug=debug, recursion_level=recursion_level): if debug: print(" " * recursion_level, "ANNOTATED STRING") if is_optional: return None - else: - return "" - else: - raise ValueError(f"Unknown parameter {p}") + return "" + raise ValueError(f"Unknown parameter {p}") def make_skeleton(cl: Type[BaseModel], debug=False, recursion_level=0): @@ -241,8 +223,3 @@ def make_skeleton(cl: Type[BaseModel], debug=False, recursion_level=0): print(" " * recursion_level, f"Parameter: {name}, value: {param_values[name]}") param_values = standardize_keys_in_dict(param_values) return cl(**param_values) - - -# def create_empty_schema_from_path(module_name, class_name, debug=False): -# MyClass = getattr(importlib.import_module(module_name), class_name) -# return make_skeleton(MyClass, debug=debug) diff --git a/pydantic_schemas/utils/schema_base_model.py b/pydantic_schemas/utils/schema_base_model.py index 77a798c..a4e9774 100644 --- a/pydantic_schemas/utils/schema_base_model.py +++ b/pydantic_schemas/utils/schema_base_model.py @@ -1,6 +1,6 @@ from typing import Optional -from pydantic import BaseModel, ConfigDict, Field +from pydantic import BaseModel, ConfigDict from rich import print as print_rich # from rich.pretty import pretty_repr @@ -19,26 +19,6 @@ def pretty_print(self): __template_name__: Optional[str] = None __template_uid__: Optional[str] = None - # metadata_type_: Optional[str] = Field(default=None, alias="__metadata_type__") - # metadata_type_version_: Optional[str] = Field(default=None, alias="__metadata_type_version__") - # template_name_: Optional[str] = Field(default=None, alias="__template_name__") - # template_uid_: Optional[str] = Field(default=None, alias="__template_uid__") - - # @property - # def __metadata_type__(self): - # return self.metadata_type_ - - # @property - # def __metadata_type_version__(self): - # return self.metadata_type_version_ - - # @property - # def __template_name__(self): - # return self.template_name_ - # @property - # def __template_uid__(self): - # return self.template_uid_ - # def __repr__(self): # return pretty_repr(self) diff --git a/pydantic_schemas/utils/test_utils.py b/pydantic_schemas/utils/test_utils.py index 8a9a660..2f15288 100644 --- a/pydantic_schemas/utils/test_utils.py +++ b/pydantic_schemas/utils/test_utils.py @@ -27,7 +27,7 @@ def fill_in_pydantic_outline(model: BaseModel, debug=False): elif isinstance(field_value, BaseModel): fill_in_pydantic_outline(field_value) elif isinstance(field_value, dict): - for key, item in field_value.items(): + for item in field_value.values(): if isinstance(item, BaseModel): fill_in_pydantic_outline(item) elif isinstance(field_value, list): @@ -57,7 +57,6 @@ def fill_in_pydantic_outline(model: BaseModel, debug=False): if debug: print("found list of basemodels") try: - # skeleton = make_skeleton(type(field_value[0])) # make a deep copy of the skeleton pydantic object new_vals = [field_value[0].model_copy(deep=True) for i in range(n_elements)] if debug: @@ -97,7 +96,7 @@ def fill_in_pydantic_outline(model: BaseModel, debug=False): def is_empty(m): if isinstance(m, str): return m == "" - elif isinstance(m, BaseModel): + if isinstance(m, BaseModel): iterabl = [v for _, v in m.model_dump().items()] elif isinstance(m, dict): if len(m) == 0: @@ -111,7 +110,7 @@ def is_empty(m): return m is None for v in iterabl: - if isinstance(v, dict) or isinstance(v, BaseModel) or isinstance(v, list) or isinstance(v, str): + if isinstance(v, (dict, BaseModel, list, str)): if is_empty(v) == False: return False elif v is not None: @@ -122,8 +121,7 @@ def is_empty(m): # Recursive function to compare two Pydantic models def assert_pydantic_models_equal(model1: BaseModel, model2: BaseModel) -> bool: # First, check if the two models are of the same type - if type(model1) is not type(model2): - assert False, f"mismatched types {type(model1)}, {type(model2)}" + assert type(model1) == type(model2), f"{type(model1)}, {type(model2)}" if not hasattr(model1, "model_fields"): assert model1 == model2, f"{model1}, {model2}" @@ -170,20 +168,11 @@ def assert_pydantic_models_equal(model1: BaseModel, model2: BaseModel) -> bool: assert_pydantic_models_equal(v1, v2) else: assert v1 == v2, field_name - # if not compare_pydantic_models(v1, v2): - # assert False, field_name - # elif v1 != v2: - # assert False, field_name - # elif isinstance(value1, list) and value2 is None: - # continue - # If both are dicts, compare their items elif isinstance(value1, dict) and isinstance(value2, dict): assert value1.keys() == value2.keys(), f"{field_name} mismatched keys, {value1.keys()}, {value2.keys()}" for key in value1: if isinstance(value1[key], BaseModel) and isinstance(value2[key], BaseModel): assert_pydantic_models_equal(value1[key], value2[key]) - # if not compare_pydantic_models(value1[key], value2[key]): - # assert False, field_name else: assert value1[key] == value2[key], field_name else: diff --git a/pydantic_schemas/utils/utils.py b/pydantic_schemas/utils/utils.py index 69ed8e4..21c4fda 100644 --- a/pydantic_schemas/utils/utils.py +++ b/pydantic_schemas/utils/utils.py @@ -11,7 +11,6 @@ def is_optional_annotation(anno: typing._UnionGenericAlias) -> bool: def is_union_annotation(anno: typing._UnionGenericAlias) -> bool: - # return len(typing.get_args(anno))>=2 origin = typing.get_origin(anno) return origin in [Optional, Union] @@ -48,17 +47,15 @@ def get_subtype_of_optional_or_list(anno: typing._UnionGenericAlias, debug=False print(f"checking arg {arg} -- {hasattr(arg, 'annotation')} -- {is_list_annotation(arg)}") if hasattr(arg, "annotation") and is_list_annotation(arg.annotation): return get_subtype_of_optional_or_list(arg.annotation, debug=debug) - elif is_list_annotation(arg): + if is_list_annotation(arg): return get_subtype_of_optional_or_list(arg, debug=debug) if len(args) == 1: return args[0] - elif len(args) > 1: + if len(args) > 1: if str in args: return str - else: - return args[0] - else: - raise NotImplementedError("Only optional lists optional builtin types implemented") + return args[0] + raise NotImplementedError("Only optional lists optional builtin types implemented") def _annotation_contains_generic( @@ -131,7 +128,7 @@ def merge_dicts(base, update, skeleton_mode=False): """ if len(update) == 0: return base - elif len(base) == 0: + if len(base) == 0: return update new_dict = {} for key, base_value in base.items(): @@ -268,8 +265,7 @@ def subset_pydantic_model_type( # Create a new Pydantic model with the filtered fields if name is None: name = "SubsetModel" - SubModel = create_model(name, **fields) - return SubModel + return create_model(name, **fields) def subset_pydantic_model(model: BaseModel, feature_names: List[str], name: Optional[str] = None) -> BaseModel: @@ -278,5 +274,5 @@ def subset_pydantic_model(model: BaseModel, feature_names: List[str], name: Opti input_dict_standardized = standardize_keys_in_dict(input_dict) try: return SubModel.model_validate(input_dict_standardized) - except: - raise ValueError(input_dict_standardized) + except Exception as e: + raise ValueError(input_dict_standardized) from e diff --git a/pydantic_schemas/video_schema.py b/pydantic_schemas/video_schema.py index e9d1149..4432dbc 100644 --- a/pydantic_schemas/video_schema.py +++ b/pydantic_schemas/video_schema.py @@ -35,20 +35,30 @@ class MetadataInformation(SchemaBaseModel): model_config = ConfigDict( extra="forbid", ) - title: Optional[str] = Field(None, description="Document title", title="Document title") + title: Optional[str] = Field( + None, description="Document title", title="Document title" + ) idno: Optional[str] = Field(None, title="Unique ID number for the document") - producers: Optional[List[Producer]] = Field(None, description="List of producers", title="Producers") + producers: Optional[List[Producer]] = Field( + None, description="List of producers", title="Producers" + ) production_date: Optional[str] = Field( - None, description="Document production date using format(YYYY-MM-DD)", title="Date of Production" + None, + description="Document production date using format(YYYY-MM-DD)", + title="Date of Production", ) version: Optional[str] = Field( - None, description="Identify and describe the current version of the document", title="Document version" + None, + description="Identify and describe the current version of the document", + title="Document version", ) class Identifier(SchemaBaseModel): type: Optional[str] = Field( - None, description="Type of identifier e.g. `doi`, `handle`, `other`", title="Identifier type" + None, + description="Type of identifier e.g. `doi`, `handle`, `other`", + title="Identifier type", ) identifier: str = Field(..., title="Identifier") @@ -63,10 +73,14 @@ class Topic(SchemaBaseModel): id: Optional[str] = Field(None, title="Unique Identifier") name: str = Field(..., title="Topic") parent_id: Optional[str] = Field( - None, description="For subtopics, provide the ID of the parent topic", title="Parent topic Identifier" + None, + description="For subtopics, provide the ID of the parent topic", + title="Parent topic Identifier", ) vocabulary: Optional[str] = Field( - None, description="Name of the controlled vocabulary, if the topic is from a taxonomy.", title="Vocabulary" + None, + description="Name of the controlled vocabulary, if the topic is from a taxonomy.", + title="Vocabulary", ) uri: Optional[str] = Field( None, @@ -146,7 +160,9 @@ class VideoDescription(SchemaBaseModel): """ idno: str = Field(..., title="Unique video identifier") - identifiers: Optional[List[Identifier]] = Field(None, description="Other identifiers", title="Other identifiers") + identifiers: Optional[List[Identifier]] = Field( + None, description="Other identifiers", title="Other identifiers" + ) title: str = Field(..., description="Title") alt_title: Optional[str] = Field(None, description="Alternate title or other title") description: Optional[str] = Field(None, description="Description") @@ -158,30 +174,36 @@ class VideoDescription(SchemaBaseModel): title="Topics", ) persons: Optional[List[Person]] = Field(None, title="Persons shown in the video") - main_entity: Optional[str] = Field(None, description="Primary entity described in the video") - date_created: Optional[str] = Field(None, description="Date of creation (YYYY-MM-DD)") - date_published: Optional[str] = Field(None, description="Date published (YYYY-MM-DD)") + main_entity: Optional[str] = Field( + None, description="Primary entity described in the video" + ) + date_created: Optional[str] = Field( + None, description="Date of creation (YYYY-MM-DD)" + ) + date_published: Optional[str] = Field( + None, description="Date published (YYYY-MM-DD)" + ) version: Optional[str] = Field(None, description="Version") status: Optional[str] = Field( None, - description=( - "Status of a creative work in terms of its stage in lifecycle. e.g. `incomplete`, `draft`, `published`," - " `obsolete`" - ), + description="Status of a creative work in terms of its stage in lifecycle. e.g. `incomplete`, `draft`, `published`, `obsolete`", title="Creative work status", ) country: Optional[List[CountryItem]] = Field(None, title="Countries") - spatial_coverage: Optional[str] = Field(None, description="Place(s) which are the focus of the content") + spatial_coverage: Optional[str] = Field( + None, description="Place(s) which are the focus of the content" + ) content_reference_time: Optional[str] = Field( None, - description=( - "Specific time described by a creative work, for works that emphasize a particular moment within an Event" - ), + description="Specific time described by a creative work, for works that emphasize a particular moment within an Event", ) temporal_coverage: Optional[str] = Field( - None, description="Period that the content applies to using ISO 8601 date time format" + None, + description="Period that the content applies to using ISO 8601 date time format", + ) + recorded_at: Optional[str] = Field( + None, description="Location where video was recorded" ) - recorded_at: Optional[str] = Field(None, description="Location where video was recorded") audience: Optional[str] = Field(None, description="Intended audience") bbox: Optional[List[BboxItem]] = Field(None, title="Geographic bounding box") language: Optional[List[LanguageItem]] = Field(None, description="languages") @@ -189,46 +211,58 @@ class VideoDescription(SchemaBaseModel): production_company: Optional[str] = Field(None, description="Production company") publisher: Optional[str] = Field(None, description="Publisher") repository: Optional[str] = Field(None, title="Repository") - contacts: Optional[List[Contact]] = Field(None, description="Contacts", title="Contacts") + contacts: Optional[List[Contact]] = Field( + None, description="Contacts", title="Contacts" + ) contributors: Optional[List[Contributor]] = None sponsors: Optional[List[Sponsor]] = Field(None, title="Funding Agency/Sponsor") - translators: Optional[List[Translator]] = Field(None, description="Translators", title="Translators") + translators: Optional[List[Translator]] = Field( + None, description="Translators", title="Translators" + ) is_based_on: Optional[str] = Field( None, description="A resource from which this work is derived or from which it is a modification or adaption", title="A resource from which this work is derived", ) - is_part_of: Optional[str] = Field(None, title="Indicate an item that this item is part of") + is_part_of: Optional[str] = Field( + None, title="Indicate an item that this item is part of" + ) relations: Optional[List[str]] = Field( None, - title=( - "Defines, as a free text field, the relation between the video being documented and other resources. This" - " is a Dublin Core element." - ), + title="Defines, as a free text field, the relation between the video being documented and other resources. This is a Dublin Core element.", + ) + video_provider: Optional[str] = Field( + None, description="Video provider e.g. youtube, vimeo, facebook" ) - video_provider: Optional[str] = Field(None, description="Video provider e.g. youtube, vimeo, facebook") video_url: Optional[str] = Field(None, description="Video URL") embed_url: Optional[str] = Field(None, description="Video embed URL") - encoding_format: Optional[str] = Field(None, description="Media type using a MIME format", title="Encoding format") + encoding_format: Optional[str] = Field( + None, description="Media type using a MIME format", title="Encoding format" + ) duration: Optional[str] = Field( - None, description="The duration of the video in ISO 8601 date time format - `hh:mm:ss`", title="Duration" + None, + description="The duration of the video in ISO 8601 date time format - `hh:mm:ss`", + title="Duration", ) rights: Optional[str] = Field(None, description="Rights") copyright_holder: Optional[str] = Field( - None, description="The party holding the legal copyright", title="Copyright holder" + None, + description="The party holding the legal copyright", + title="Copyright holder", ) copyright_notice: Optional[str] = Field( - None, description="Text of a notice describing the copyright", title="Copyright text" + None, + description="Text of a notice describing the copyright", + title="Copyright text", ) copyright_year: Optional[str] = Field( - None, description="Year during which claimed copyright for the video was first asserted", title="Copyright year" + None, + description="Year during which claimed copyright for the video was first asserted", + title="Copyright year", ) credit_text: Optional[str] = Field( None, - description=( - "This element that can be used to credit the person(s) and/or organization(s) associated with a published" - " video. It corresponds to the `creditText` element of VideoObject." - ), + description="This element that can be used to credit the person(s) and/or organization(s) associated with a published video. It corresponds to the `creditText` element of VideoObject.", title="Credits", ) citation: Optional[str] = Field( @@ -247,21 +281,28 @@ class Tag(SchemaBaseModel): class OriginDescription(SchemaBaseModel): - harvest_date: Optional[str] = Field(None, description="Harvest date using UTC date format") + harvest_date: Optional[str] = Field( + None, description="Harvest date using UTC date format" + ) altered: Optional[bool] = Field( - None, description="If the metadata was altered before dissemination", title="Metadata altered" + None, + description="If the metadata was altered before dissemination", + title="Metadata altered", + ) + base_url: Optional[str] = Field( + None, description="Base URL of the originating repository" + ) + identifier: Optional[str] = Field( + None, + description="Unique idenifiter of the item from the originating repository", ) - base_url: Optional[str] = Field(None, description="Base URL of the originating repository") - identifier: Optional[str] = Field(None, description="Unique idenifiter of the item from the originating repository") date_stamp: Optional[str] = Field( None, description="Datestamp (UTC date format) of the metadata record disseminated by the originating repository", ) metadata_namespace: Optional[str] = Field( None, - description=( - "Metadata namespace URI of the metadata format of the record harvested from the originating repository" - ), + description="Metadata namespace URI of the metadata format of the record harvested from the originating repository", ) @@ -270,24 +311,29 @@ class ProvenanceSchema(SchemaBaseModel): Provenance of metadata based on the OAI provenance schema (http://www.openarchives.org/OAI/2.0/provenance.xsd) """ - origin_description: Optional[OriginDescription] = Field(None, title="Origin description") + origin_description: Optional[OriginDescription] = Field( + None, title="Origin description" + ) class Model(SchemaBaseModel): """ Video schema based on the elements from Dublin Core and Schema.org's VideoObject """ - __metadata_type__ = "video" - __metadata_type_version__ = "0.1.0" + __metadata_type_version__ = "0.1.0" repositoryid: Optional[str] = Field( None, description="Abbreviation for the collection that owns the document", title="Collection ID that owns the document", ) - published: Optional[int] = Field(0, description="Status - 0=draft, 1=published", title="Status") - overwrite: Optional[Overwrite] = Field("no", description="Overwrite document if already exists?") + published: Optional[int] = Field( + 0, description="Status - 0=draft, 1=published", title="Status" + ) + overwrite: Optional[Overwrite] = Field( + "no", description="Overwrite document if already exists?" + ) metadata_information: Optional[MetadataInformation] = Field( None, description="Document description", title="Document metadata information" ) @@ -296,4 +342,6 @@ class Model(SchemaBaseModel): ) provenance: Optional[List[ProvenanceSchema]] = Field(None, description="Provenance") tags: Optional[List[Tag]] = Field(None, description="Tags", title="Tags") - additional: Optional[Dict[str, Any]] = Field(None, description="Additional metadata") + additional: Optional[Dict[str, Any]] = Field( + None, description="Additional metadata" + ) diff --git a/pyproject.toml b/pyproject.toml index 5cd2cbc..0f0c461 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,27 +22,17 @@ rich = "^13.9.4" [tool.poetry.group.dev.dependencies] pytest = "^8.2.2" pre-commit = "^3.7.1" -isort = "^5.13.2" ruff = "^0.5.0" -black = "^24.4.2" detect-secrets = "^1.5.0" ipykernel = "^6.29.5" datamodel-code-generator = "^0.25.9" [tool.ruff] -line-length = 120 fix = true exclude = [ - "pydantic_schemas/**" + "pydantic_schemas/*_schema.py" ] -[tool.isort] -line_length = 120 -profile = "black" - -[tool.black] -line-length = 120 - [tool.detect-secrets] exclude-lines = "\\s*\"image/png\": \".+\""