Skip to content

Commit d1979c1

Browse files
authored
Merge pull request #232 from dandi/add_resource_type
Add ResourceType enum and associate with Resource model
2 parents e6cc5a0 + 2f8e27f commit d1979c1

File tree

3 files changed

+141
-2
lines changed

3 files changed

+141
-2
lines changed

dandischema/consts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DANDI_SCHEMA_VERSION = "0.6.6"
1+
DANDI_SCHEMA_VERSION = "0.6.7"
22
ALLOWED_INPUT_SCHEMAS = [
33
"0.4.4",
44
"0.5.1",
@@ -9,6 +9,7 @@
99
"0.6.3",
1010
"0.6.4",
1111
"0.6.5",
12+
"0.6.6",
1213
]
1314

1415
# ATM we allow only for a single target version which is current

dandischema/models.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,130 @@ class RoleType(Enum):
336336
Other = "dcite:Other"
337337

338338

339+
class ResourceType(Enum):
340+
"""An enumeration of resource types"""
341+
342+
#: Audiovisual: A series of visual representations imparting an impression of motion
343+
# when shown in succession. May or may not include sound.
344+
Audiovisual = "dcite:Audiovisual"
345+
346+
#: Book: A medium for recording information in the form of writing or images,
347+
# typically composed of many pages bound together and protected by a cover.
348+
Book = "dcite:Book"
349+
350+
#: BookChapter: One of the main divisions of a book.
351+
BookChapter = "dcite:BookChapter"
352+
353+
#: Collection: An aggregation of resources, which may encompass collections of one
354+
# resourceType as well as those of mixed types. A collection is described as a
355+
# group; its parts may also be separately described.
356+
Collection = "dcite:Collection"
357+
358+
#: ComputationalNotebook: A virtual notebook environment used for literate
359+
# programming.
360+
ComputationalNotebook = "dcite:ComputationalNotebook"
361+
362+
#: ConferencePaper: Article that is written with the goal of being accepted to a
363+
# conference.
364+
ConferencePaper = "dcite:ConferencePaper"
365+
366+
#: ConferenceProceeding: Collection of academic papers published in the context of
367+
# an academic conference.
368+
ConferenceProceeding = "dcite:ConferenceProceeding"
369+
370+
#: DataPaper: A factual and objective publication with a focused intent to identify
371+
# and describe specific data, sets of data, or data collections to facilitate
372+
# discoverability.
373+
DataPaper = "dcite:DataPaper"
374+
375+
#: Dataset: Data encoded in a defined structure.
376+
Dataset = "dcite:Dataset"
377+
378+
#: Dissertation: A written essay, treatise, or thesis, especially one written by a
379+
# candidate for the degree of Doctor of Philosophy.
380+
Dissertation = "dcite:Dissertation"
381+
382+
#: Event: A non-persistent, time-based occurrence.
383+
Event = "dcite:Event"
384+
385+
#: Image: A visual representation other than text.
386+
Image = "dcite:Image"
387+
388+
#: Instrument: A device, tool or apparatus used to obtain, measure and/or analyze
389+
# data.
390+
Instrument = "dcite:Instrument"
391+
392+
#: InteractiveResource: A resource requiring interaction from the user to be
393+
# understood, executed, or experienced.
394+
InteractiveResource = "dcite:InteractiveResource"
395+
396+
#: Journal: A scholarly publication consisting of articles that is published
397+
# regularly throughout the year.
398+
Journal = "dcite:Journal"
399+
400+
#: JournalArticle: A written composition on a topic of interest, which forms a
401+
# separate part of a journal.
402+
JournalArticle = "dcite:JournalArticle"
403+
404+
#: Model: An abstract, conceptual, graphical, mathematical or visualization model
405+
# that represents empirical objects, phenomena, or physical processes.
406+
Model = "dcite:Model"
407+
408+
#: OutputManagementPlan: A formal document that outlines how research outputs are to
409+
# be handled both during a research project and after the project is completed.
410+
OutputManagementPlan = "dcite:OutputManagementPlan"
411+
412+
#: PeerReview: Evaluation of scientific, academic, or professional work by others
413+
# working in the same field.
414+
PeerReview = "dcite:PeerReview"
415+
416+
#: PhysicalObject: A physical object or substance.
417+
PhysicalObject = "dcite:PhysicalObject"
418+
419+
#: Preprint: A version of a scholarly or scientific paper that precedes formal peer
420+
# review and publication in a peer-reviewed scholarly or scientific journal.
421+
Preprint = "dcite:Preprint"
422+
423+
#: Report: A document that presents information in an organized format for a
424+
# specific audience and purpose.
425+
Report = "dcite:Report"
426+
427+
#: Service: An organized system of apparatus, appliances, staff, etc., for supplying
428+
# some function(s) required by end users.
429+
Service = "dcite:Service"
430+
431+
#: Software: A computer program other than a computational notebook, in either
432+
# source code (text) or compiled form. Use this type for general software components
433+
# supporting scholarly research. Use the “ComputationalNotebook” value for virtual
434+
# notebooks.
435+
Software = "dcite:Software"
436+
437+
#: Sound: A resource primarily intended to be heard.
438+
Sound = "dcite:Sound"
439+
440+
#: Standard: Something established by authority, custom, or general consent as a
441+
# model, example, or point of reference.
442+
Standard = "dcite:Standard"
443+
444+
#: StudyRegistration: A detailed, time-stamped description of a research plan, often
445+
# openly shared in a registry or published in a journal before the study is
446+
# conducted to lend accountability and transparency in the hypothesis generating and
447+
# testing process.
448+
StudyRegistration = "dcite:StudyRegistration"
449+
450+
#: Text: A resource consisting primarily of words for reading that is not covered by
451+
# any other textual resource type in this list.
452+
Text = "dcite:Text"
453+
454+
#: Workflow: A structured series of steps which can be executed to produce a final
455+
# outcome, allowing users a means to specify and enact their work in a more
456+
# reproducible manner.
457+
Workflow = "dcite:Workflow"
458+
459+
#: Other: A resource that does not fit into any of the other categories.
460+
Other = "dcite:Other"
461+
462+
339463
class AgeReferenceType(Enum):
340464
"""An enumeration of age reference"""
341465

@@ -888,6 +1012,13 @@ class Resource(DandiBaseModel):
8881012
"This relation should satisfy: dandiset <relation> resource.",
8891013
json_schema_extra={"nskey": "dandi"},
8901014
)
1015+
resourceType: Optional[ResourceType] = Field(
1016+
default=None,
1017+
title="Resource type",
1018+
description="The type of resource.",
1019+
json_schema_extra={"nskey": "dandi"},
1020+
)
1021+
8911022
schemaKey: Literal["Resource"] = Field(
8921023
"Resource", validate_default=True, json_schema_extra={"readOnly": True}
8931024
)

dandischema/tests/test_datacite.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111

1212
from .utils import skipif_no_network
1313
from ..datacite import _get_datacite_schema, to_datacite
14-
from ..models import LicenseType, PublishedDandiset, RelationType, RoleType
14+
from ..models import (
15+
LicenseType,
16+
PublishedDandiset,
17+
RelationType,
18+
ResourceType,
19+
RoleType,
20+
)
1521

1622

1723
def datacite_post(datacite: dict, doi: str) -> None:
@@ -337,6 +343,7 @@ def test_datacite(dandi_id: str, schema: Any) -> None:
337343
{
338344
"identifier": "doi:10.123/123",
339345
"relation": RelationType("dcite:IsDocumentedBy"),
346+
"resourceType": ResourceType("dcite:JournalArticle"),
340347
},
341348
],
342349
},

0 commit comments

Comments
 (0)