From ea0ababed980de6c337a8aeedd115dadb3968fad Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sat, 16 Mar 2024 16:16:40 +0000 Subject: [PATCH 1/7] add ResourceType enum and assocaite with Resource model --- dandischema/models.py | 109 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 3 deletions(-) diff --git a/dandischema/models.py b/dandischema/models.py index 20af8bd..c1dd2a7 100644 --- a/dandischema/models.py +++ b/dandischema/models.py @@ -336,6 +336,103 @@ class RoleType(Enum): Other = "dcite:Other" +class ResourceType(Enum): + """An enumeration of resource types""" + + #: Audiovisual: A series of visual representations imparting an impression of motion when shown in succession. May + # or may not include sound. + Audiovisual = "dcite:Audiovisual" + + #: Book: A medium for recording information in the form of writing or images, typically composed of many pages bound + # together and protected by a cover. + Book = "dcite:Book" + + #: BookChapter: One of the main divisions of a book. + BookChapter = "dcite:BookChapter" + + #: Collection: An aggregation of resources, which may encompass collections of one resourceType as well as those of + # mixed types. A collection is described as a group; its parts may also be separately described. + Collection = "dcite:Collection" + + #: ComputationalNotebook: A virtual notebook environment used for literate programming. + ComputationalNotebook = "dcite:ComputationalNotebook" + + #: ConferencePaper: Article that is written with the goal of being accepted to a conference. + ConferencePaper = "dcite:ConferencePaper" + + #: ConferenceProceeding: Collection of academic papers published in the context of an academic conference. + ConferenceProceeding = "dcite:ConferenceProceeding" + + #: DataPaper: A factual and objective publication with a focused intent to identify and describe specific data, sets of data, or data collections to facilitate discoverability. + DataPaper = "dcite:DataPaper" + + #: Dataset: Data encoded in a defined structure. + Dataset = "dcite:Dataset" + + #: Dissertation: A written essay, treatise, or thesis, especially one written by a candidate for the degree of Doctor of Philosophy. + Dissertation = "dcite:Dissertation" + + #: Event: A non-persistent, time-based occurrence. + Event = "dcite:Event" + + #: Image: A visual representation other than text. + Image = "dcite:Image" + + #: Instrument: A device, tool or apparatus used to obtain, measure and/or analyze data. + Instrument = "dcite:Instrument" + + #: InteractiveResource: A resource requiring interaction from the user to be understood, executed, or experienced. + InteractiveResource = "dcite:InteractiveResource" + + #: Journal: A scholarly publication consisting of articles that is published regularly throughout the year. + Journal = "dcite:Journal" + + #: JournalArticle: A written composition on a topic of interest, which forms a separate part of a journal. + JournalArticle = "dcite:JournalArticle" + + #: Model: An abstract, conceptual, graphical, mathematical or visualization model that represents empirical objects, phenomena, or physical processes. + Model = "dcite:Model" + + #: OutputManagementPlan: A formal document that outlines how research outputs are to be handled both during a research project and after the project is completed. + OutputManagementPlan = "dcite:OutputManagementPlan" + + #: PeerReview: Evaluation of scientific, academic, or professional work by others working in the same field. + PeerReview = "dcite:PeerReview" + + #: PhysicalObject: A physical object or substance. + PhysicalObject = "dcite:PhysicalObject" + + #: Preprint: A version of a scholarly or scientific paper that precedes formal peer review and publication in a peer-reviewed scholarly or scientific journal. + Preprint = "dcite:Preprint" + + #: Report: A document that presents information in an organized format for a specific audience and purpose. + Report = "dcite:Report" + + #: Service: An organized system of apparatus, appliances, staff, etc., for supplying some function(s) required by end users. + Service = "dcite:Service" + + #: Software: A computer program other than a computational notebook, in either source code (text) or compiled form. Use this type for general software components supporting scholarly research. Use the “ComputationalNotebook” value for virtual notebooks. + Software = "dcite:Software" + + #: Sound: A resource primarily intended to be heard. + Sound = "dcite:Sound" + + #: Standard: Something established by authority, custom, or general consent as a model, example, or point of reference. + Standard = "dcite:Standard" + + #: StudyRegistration: A detailed, time-stamped description of a research plan, often openly shared in a registry or published in a journal before the study is conducted to lend accountability and transparency in the hypothesis generating and testing process. + StudyRegistration = "dcite:StudyRegistration" + + #: Text: A resource consisting primarily of words for reading that is not covered by any other textual resource type in this list. + Text = "dcite:Text" + + #: Workflow: A structured series of steps which can be executed to produce a final outcome, allowing users a means to specify and enact their work in a more reproducible manner. + Workflow = "dcite:Workflow" + + #: Other: A resource that does not fit into any of the other categories. + Other = "dcite:Other" + + class AgeReferenceType(Enum): """An enumeration of age reference""" @@ -888,6 +985,12 @@ class Resource(DandiBaseModel): "This relation should satisfy: dandiset resource.", json_schema_extra={"nskey": "dandi"}, ) + resourceType: Optional[ResourceType] = Field( + title="Resource type", + description="The type of resource.", + json_schema_extra={"nskey": "dandi"}, + ) + schemaKey: Literal["Resource"] = Field( "Resource", validate_default=True, json_schema_extra={"readOnly": True} ) @@ -1045,9 +1148,9 @@ class Activity(DandiBaseModel): # isPartOf: Optional["Activity"] = Field(None, json_schema_extra={"nskey": "schema"}) # hasPart: Optional["Activity"] = Field(None, json_schema_extra={"nskey": "schema"}) - wasAssociatedWith: Optional[List[Union[Person, Organization, Software, Agent]]] = ( - Field(None, json_schema_extra={"nskey": "prov"}) - ) + wasAssociatedWith: Optional[ + List[Union[Person, Organization, Software, Agent]] + ] = Field(None, json_schema_extra={"nskey": "prov"}) used: Optional[List[Equipment]] = Field( None, description="A listing of equipment used for the activity.", From a110e46e2712952b0abcd2c2730e4494c7cab7d7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:17:39 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dandischema/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dandischema/models.py b/dandischema/models.py index c1dd2a7..e6721ec 100644 --- a/dandischema/models.py +++ b/dandischema/models.py @@ -1148,9 +1148,9 @@ class Activity(DandiBaseModel): # isPartOf: Optional["Activity"] = Field(None, json_schema_extra={"nskey": "schema"}) # hasPart: Optional["Activity"] = Field(None, json_schema_extra={"nskey": "schema"}) - wasAssociatedWith: Optional[ - List[Union[Person, Organization, Software, Agent]] - ] = Field(None, json_schema_extra={"nskey": "prov"}) + wasAssociatedWith: Optional[List[Union[Person, Organization, Software, Agent]]] = ( + Field(None, json_schema_extra={"nskey": "prov"}) + ) used: Optional[List[Equipment]] = Field( None, description="A listing of equipment used for the activity.", From af4e830b252fbed20d50da1062308410f78c4afa Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sat, 16 Mar 2024 16:20:48 +0000 Subject: [PATCH 3/7] give resourceType default=None --- dandischema/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dandischema/models.py b/dandischema/models.py index c1dd2a7..c616d8e 100644 --- a/dandischema/models.py +++ b/dandischema/models.py @@ -986,6 +986,7 @@ class Resource(DandiBaseModel): json_schema_extra={"nskey": "dandi"}, ) resourceType: Optional[ResourceType] = Field( + default=None, title="Resource type", description="The type of resource.", json_schema_extra={"nskey": "dandi"}, From 4b5b1ecfc81a1487eb34764abc11c19d8caa1969 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sat, 16 Mar 2024 16:23:54 +0000 Subject: [PATCH 4/7] flake8 --- dandischema/models.py | 79 +++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/dandischema/models.py b/dandischema/models.py index 050d0e2..2de8299 100644 --- a/dandischema/models.py +++ b/dandischema/models.py @@ -339,37 +339,44 @@ class RoleType(Enum): class ResourceType(Enum): """An enumeration of resource types""" - #: Audiovisual: A series of visual representations imparting an impression of motion when shown in succession. May - # or may not include sound. + #: Audiovisual: A series of visual representations imparting an impression of motion + # when shown in succession. May or may not include sound. Audiovisual = "dcite:Audiovisual" - #: Book: A medium for recording information in the form of writing or images, typically composed of many pages bound - # together and protected by a cover. + #: Book: A medium for recording information in the form of writing or images, + # typically composed of many pages bound together and protected by a cover. Book = "dcite:Book" #: BookChapter: One of the main divisions of a book. BookChapter = "dcite:BookChapter" - #: Collection: An aggregation of resources, which may encompass collections of one resourceType as well as those of - # mixed types. A collection is described as a group; its parts may also be separately described. + #: Collection: An aggregation of resources, which may encompass collections of one + # resourceType as well as those of mixed types. A collection is described as a + # group; its parts may also be separately described. Collection = "dcite:Collection" - #: ComputationalNotebook: A virtual notebook environment used for literate programming. + #: ComputationalNotebook: A virtual notebook environment used for literate + # programming. ComputationalNotebook = "dcite:ComputationalNotebook" - #: ConferencePaper: Article that is written with the goal of being accepted to a conference. + #: ConferencePaper: Article that is written with the goal of being accepted to a + # conference. ConferencePaper = "dcite:ConferencePaper" - #: ConferenceProceeding: Collection of academic papers published in the context of an academic conference. + #: ConferenceProceeding: Collection of academic papers published in the context of + # an academic conference. ConferenceProceeding = "dcite:ConferenceProceeding" - #: DataPaper: A factual and objective publication with a focused intent to identify and describe specific data, sets of data, or data collections to facilitate discoverability. + #: DataPaper: A factual and objective publication with a focused intent to identify + # and describe specific data, sets of data, or data collections to facilitate + # discoverability. DataPaper = "dcite:DataPaper" #: Dataset: Data encoded in a defined structure. Dataset = "dcite:Dataset" - #: Dissertation: A written essay, treatise, or thesis, especially one written by a candidate for the degree of Doctor of Philosophy. + #: Dissertation: A written essay, treatise, or thesis, especially one written by a + # candidate for the degree of Doctor of Philosophy. Dissertation = "dcite:Dissertation" #: Event: A non-persistent, time-based occurrence. @@ -378,55 +385,75 @@ class ResourceType(Enum): #: Image: A visual representation other than text. Image = "dcite:Image" - #: Instrument: A device, tool or apparatus used to obtain, measure and/or analyze data. + #: Instrument: A device, tool or apparatus used to obtain, measure and/or analyze + # data. Instrument = "dcite:Instrument" - #: InteractiveResource: A resource requiring interaction from the user to be understood, executed, or experienced. + #: InteractiveResource: A resource requiring interaction from the user to be + # understood, executed, or experienced. InteractiveResource = "dcite:InteractiveResource" - #: Journal: A scholarly publication consisting of articles that is published regularly throughout the year. + #: Journal: A scholarly publication consisting of articles that is published + # regularly throughout the year. Journal = "dcite:Journal" - #: JournalArticle: A written composition on a topic of interest, which forms a separate part of a journal. + #: JournalArticle: A written composition on a topic of interest, which forms a + # separate part of a journal. JournalArticle = "dcite:JournalArticle" - #: Model: An abstract, conceptual, graphical, mathematical or visualization model that represents empirical objects, phenomena, or physical processes. + #: Model: An abstract, conceptual, graphical, mathematical or visualization model + # that represents empirical objects, phenomena, or physical processes. Model = "dcite:Model" - #: OutputManagementPlan: A formal document that outlines how research outputs are to be handled both during a research project and after the project is completed. + #: OutputManagementPlan: A formal document that outlines how research outputs are to + # be handled both during a research project and after the project is completed. OutputManagementPlan = "dcite:OutputManagementPlan" - #: PeerReview: Evaluation of scientific, academic, or professional work by others working in the same field. + #: PeerReview: Evaluation of scientific, academic, or professional work by others + # working in the same field. PeerReview = "dcite:PeerReview" #: PhysicalObject: A physical object or substance. PhysicalObject = "dcite:PhysicalObject" - #: Preprint: A version of a scholarly or scientific paper that precedes formal peer review and publication in a peer-reviewed scholarly or scientific journal. + #: Preprint: A version of a scholarly or scientific paper that precedes formal peer + # review and publication in a peer-reviewed scholarly or scientific journal. Preprint = "dcite:Preprint" - #: Report: A document that presents information in an organized format for a specific audience and purpose. + #: Report: A document that presents information in an organized format for a + # specific audience and purpose. Report = "dcite:Report" - #: Service: An organized system of apparatus, appliances, staff, etc., for supplying some function(s) required by end users. + #: Service: An organized system of apparatus, appliances, staff, etc., for supplying + # some function(s) required by end users. Service = "dcite:Service" - #: Software: A computer program other than a computational notebook, in either source code (text) or compiled form. Use this type for general software components supporting scholarly research. Use the “ComputationalNotebook” value for virtual notebooks. + #: Software: A computer program other than a computational notebook, in either + # source code (text) or compiled form. Use this type for general software components + # supporting scholarly research. Use the “ComputationalNotebook” value for virtual + # notebooks. Software = "dcite:Software" #: Sound: A resource primarily intended to be heard. Sound = "dcite:Sound" - #: Standard: Something established by authority, custom, or general consent as a model, example, or point of reference. + #: Standard: Something established by authority, custom, or general consent as a + # model, example, or point of reference. Standard = "dcite:Standard" - #: StudyRegistration: A detailed, time-stamped description of a research plan, often openly shared in a registry or published in a journal before the study is conducted to lend accountability and transparency in the hypothesis generating and testing process. + #: StudyRegistration: A detailed, time-stamped description of a research plan, often + # openly shared in a registry or published in a journal before the study is + # conducted to lend accountability and transparency in the hypothesis generating and + # testing process. StudyRegistration = "dcite:StudyRegistration" - #: Text: A resource consisting primarily of words for reading that is not covered by any other textual resource type in this list. + #: Text: A resource consisting primarily of words for reading that is not covered by + # any other textual resource type in this list. Text = "dcite:Text" - #: Workflow: A structured series of steps which can be executed to produce a final outcome, allowing users a means to specify and enact their work in a more reproducible manner. + #: Workflow: A structured series of steps which can be executed to produce a final + # outcome, allowing users a means to specify and enact their work in a more + # reproducible manner. Workflow = "dcite:Workflow" #: Other: A resource that does not fit into any of the other categories. From b212bcc3b4a93b4af7e46f89e29df767a64ba7e9 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sat, 16 Mar 2024 16:25:49 +0000 Subject: [PATCH 5/7] add test for resourceType --- dandischema/tests/test_datacite.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dandischema/tests/test_datacite.py b/dandischema/tests/test_datacite.py index 4d7de07..9d6b082 100644 --- a/dandischema/tests/test_datacite.py +++ b/dandischema/tests/test_datacite.py @@ -11,7 +11,7 @@ from .utils import skipif_no_network from ..datacite import _get_datacite_schema, to_datacite -from ..models import LicenseType, PublishedDandiset, RelationType, RoleType +from ..models import LicenseType, PublishedDandiset, RelationType, RoleType, ResourceType def datacite_post(datacite: dict, doi: str) -> None: @@ -337,6 +337,7 @@ def test_datacite(dandi_id: str, schema: Any) -> None: { "identifier": "doi:10.123/123", "relation": RelationType("dcite:IsDocumentedBy"), + "resourceType": ResourceType("dcite:JournalArticle"), }, ], }, From 9e492c2e940256eab8c064463340b0812c29b7dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:26:07 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dandischema/tests/test_datacite.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dandischema/tests/test_datacite.py b/dandischema/tests/test_datacite.py index 9d6b082..b02e439 100644 --- a/dandischema/tests/test_datacite.py +++ b/dandischema/tests/test_datacite.py @@ -11,7 +11,13 @@ from .utils import skipif_no_network from ..datacite import _get_datacite_schema, to_datacite -from ..models import LicenseType, PublishedDandiset, RelationType, RoleType, ResourceType +from ..models import ( + LicenseType, + PublishedDandiset, + RelationType, + ResourceType, + RoleType, +) def datacite_post(datacite: dict, doi: str) -> None: From 2f8e27f7913465c51057f8a32353f24f77bbd78f Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sun, 17 Mar 2024 13:10:32 -0400 Subject: [PATCH 7/7] Update consts.py --- dandischema/consts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dandischema/consts.py b/dandischema/consts.py index 88c42d2..0d7959d 100644 --- a/dandischema/consts.py +++ b/dandischema/consts.py @@ -1,4 +1,4 @@ -DANDI_SCHEMA_VERSION = "0.6.6" +DANDI_SCHEMA_VERSION = "0.6.7" ALLOWED_INPUT_SCHEMAS = [ "0.4.4", "0.5.1", @@ -9,6 +9,7 @@ "0.6.3", "0.6.4", "0.6.5", + "0.6.6", ] # ATM we allow only for a single target version which is current