Skip to content

Commit

Permalink
Merge branch 'master' into allow-context-in-data
Browse files Browse the repository at this point in the history
Bring in up-to-date changes from the base branch
  • Loading branch information
candleindark committed Jan 20, 2025
2 parents fd3df90 + 6fd04fb commit 5ca9e5e
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-nonetwork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
DANDI_TESTS_NONETWORK: 1

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
flags: unittests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: tox -e py -- -s --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
flags: unittests
Expand Down
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# 0.11.0 (Tue Jan 07 2025)

#### 🚀 Enhancement

- Upgrade to datacite v4.5 serialization from inveniosoftware [#261](https://github.com/dandi/dandi-schema/pull/261) ([@yarikoptic](https://github.com/yarikoptic))
- Add "version" to datacite record and bundle datacite json serializations [#260](https://github.com/dandi/dandi-schema/pull/260) ([@yarikoptic](https://github.com/yarikoptic))
- Drop Python 3.8 support (remove typing_extensions from depends) [#262](https://github.com/dandi/dandi-schema/pull/262) ([@yarikoptic](https://github.com/yarikoptic))

#### 🐛 Bug Fix

- Use `title` in place of `examples` [#271](https://github.com/dandi/dandi-schema/pull/271) ([@waxlamp](https://github.com/waxlamp) [@satra](https://github.com/satra) [@pre-commit-ci[bot]](https://github.com/pre-commit-ci[bot]))
- RF: detect BIDS based on having dataset_description.json [#263](https://github.com/dandi/dandi-schema/pull/263) ([@yarikoptic](https://github.com/yarikoptic))
- Add support for detection and addition of ome/ngff "standard" into assets summary [#252](https://github.com/dandi/dandi-schema/pull/252) ([@yarikoptic](https://github.com/yarikoptic))

#### 🏠 Internal

- [gh-actions](deps): Bump codecov/codecov-action from 4 to 5 [#267](https://github.com/dandi/dandi-schema/pull/267) ([@dependabot[bot]](https://github.com/dependabot[bot]))
- [pre-commit.ci] pre-commit autoupdate (black 24.8.0 → 24.10.0; pre-commit-hooks: v4.6.0 → v5.0.0) [#253](https://github.com/dandi/dandi-schema/pull/253) ([@pre-commit-ci[bot]](https://github.com/pre-commit-ci[bot]))

#### 📝 Documentation

- doc: A comment on current identification of URI and missing space into a description string [#265](https://github.com/dandi/dandi-schema/pull/265) ([@yarikoptic](https://github.com/yarikoptic))

#### Authors: 5

- [@dependabot[bot]](https://github.com/dependabot[bot])
- [@pre-commit-ci[bot]](https://github.com/pre-commit-ci[bot])
- Roni Choudhury ([@waxlamp](https://github.com/waxlamp))
- Satrajit Ghosh ([@satra](https://github.com/satra))
- Yaroslav Halchenko ([@yarikoptic](https://github.com/yarikoptic))

---

# 0.10.4 (Thu Sep 05 2024)

#### 🐛 Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ out of the Pydantic models.
## Resources

* To learn how to interact with the DANDI archive,
see [the handbook](https://www.dandiarchive.org/handbook/).
see the [DANDI Docs](https://docs.dandiarchive.org).
* To file a feature request or bug report, go to https://github.com/dandi/helpdesk/issues/new/choose.
* For all other issues, contact the DANDI team: [email protected].
3 changes: 2 additions & 1 deletion dandischema/consts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DANDI_SCHEMA_VERSION = "0.6.8"
DANDI_SCHEMA_VERSION = "0.6.9"
ALLOWED_INPUT_SCHEMAS = [
"0.4.4",
"0.5.1",
Expand All @@ -11,6 +11,7 @@
"0.6.5",
"0.6.6",
"0.6.7",
"0.6.8",
]

# ATM we allow only for a single target version which is current
Expand Down
28 changes: 16 additions & 12 deletions dandischema/datacite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ def to_datacite(
if publish:
attributes["event"] = "publish"

attributes["identifiers"] = [
# TODO: the first element is ignored, not sure how to fix it...
{"identifier": f"https://doi.org/{meta.doi}", "identifierType": "DOI"},
attributes["alternateIdentifiers"] = [
{
"identifier": f"https://identifiers.org/{meta.id}",
"identifierType": "URL",
"alternateIdentifier": f"https://identifiers.org/{meta.id}",
"alternateIdentifierType": "URL",
},
{
"identifier": str(meta.url),
"identifierType": "URL",
"alternateIdentifier": str(meta.url),
"alternateIdentifierType": "URL",
},
]

Expand All @@ -98,7 +96,13 @@ def to_datacite(
attributes["descriptions"] = [
{"description": meta.description, "descriptionType": "Abstract"}
]
attributes["publisher"] = "DANDI Archive"
attributes["publisher"] = {
"name": "DANDI Archive",
"schemeUri": "https://scicrunch.org/resolver/",
"publisherIdentifier": "https://scicrunch.org/resolver/RRID:SCR_017571",
"publisherIdentifierScheme": "RRID",
"lang": "en",
}
attributes["publicationYear"] = str(meta.datePublished.year)
# not sure about it dandi-api had "resourceTypeGeneral": "NWB"
attributes["types"] = {
Expand All @@ -110,7 +114,7 @@ def to_datacite(
# assuming that all licenses are from SPDX?
attributes["rightsList"] = [
{
"schemeURI": "https://spdx.org/licenses/",
"schemeUri": "https://spdx.org/licenses/",
"rightsIdentifierScheme": "SPDX",
"rightsIdentifier": el.name,
}
Expand Down Expand Up @@ -147,7 +151,7 @@ def to_datacite(
contr_dict: Dict[str, Any] = {
"name": contr_el.name,
"contributorName": contr_el.name,
"schemeURI": "orcid.org",
"schemeUri": "orcid.org",
}
if isinstance(contr_el, Person):
contr_dict["nameType"] = "Personal"
Expand All @@ -163,7 +167,7 @@ def to_datacite(
contr_dict["affiliation"] = []
if getattr(contr_el, "identifier"):
orcid_dict = {
"nameIdentifier": contr_el.identifier,
"nameIdentifier": f"https://orcid.org/{contr_el.identifier}",
"nameIdentifierScheme": "ORCID",
"schemeUri": "https://orcid.org/",
}
Expand Down Expand Up @@ -252,7 +256,7 @@ def to_datacite(


@lru_cache()
def _get_datacite_schema(version_id: str = "datacite-4.3-17-gaa5db56") -> Any:
def _get_datacite_schema(version_id: str = "inveniosoftware-4.5-81-g160250d") -> Any:
"""Load datacite schema based on the version id provided."""
schema_folder = Path(__file__).parent / "schema"
return json.loads((schema_folder / f"{version_id}.json").read_text())
Expand Down
46 changes: 27 additions & 19 deletions dandischema/datacite/tests/test_datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,16 @@ def test_datacite(dandi_id: str, schema: Any) -> None:
1,
{"description": "testing", "descriptionType": "Abstract"},
),
"publisher": (None, "DANDI Archive"),
"publisher": (
None,
{
"name": "DANDI Archive",
"publisherIdentifier": "https://scicrunch.org/resolver/RRID:SCR_017571",
"publisherIdentifierScheme": "RRID",
"schemeUri": "https://scicrunch.org/resolver/",
"lang": "en",
},
),
"rightsList": (
1,
{"rightsIdentifierScheme": "SPDX", "rightsIdentifier": "CC_BY_40"},
Expand Down Expand Up @@ -302,7 +311,7 @@ def test_datacite(dandi_id: str, schema: Any) -> None:
"name": "A_last, A_first",
"nameIdentifiers": [
{
"nameIdentifier": "0000-0001-0000-0000",
"nameIdentifier": "https://orcid.org/0000-0001-0000-0000",
"nameIdentifierScheme": "ORCID",
"schemeUri": "https://orcid.org/",
}
Expand All @@ -316,7 +325,7 @@ def test_datacite(dandi_id: str, schema: Any) -> None:
"contributorType": "Other",
"nameIdentifiers": [
{
"nameIdentifier": "0000-0001-0000-0000",
"nameIdentifier": "https://orcid.org/0000-0001-0000-0000",
"nameIdentifierScheme": "ORCID",
"schemeUri": "https://orcid.org/",
}
Expand Down Expand Up @@ -423,7 +432,7 @@ def test_datacite_publish(metadata_basic: Dict[str, Any]) -> None:
"givenName": "A_first",
"name": "A_last, A_first",
"nameType": "Personal",
"schemeURI": "orcid.org",
"schemeUri": "orcid.org",
}
],
"creators": [
Expand All @@ -434,40 +443,39 @@ def test_datacite_publish(metadata_basic: Dict[str, Any]) -> None:
"givenName": "A_first",
"name": "A_last, A_first",
"nameType": "Personal",
"schemeURI": "orcid.org",
"schemeUri": "orcid.org",
}
],
"descriptions": [
{"description": "testing", "descriptionType": "Abstract"}
],
"doi": f"10.80507/dandi.{dandi_id_noprefix}/{version}",
"identifiers": [
"alternateIdentifiers": [
{
"identifier": (
f"https://doi.org/10.80507"
f"/dandi.{dandi_id_noprefix}/{version}"
),
"identifierType": "DOI",
},
{
"identifier": f"https://identifiers.org/{dandi_id}/{version}",
"identifierType": "URL",
"alternateIdentifier": f"https://identifiers.org/{dandi_id}/{version}",
"alternateIdentifierType": "URL",
},
{
"identifier": (
"alternateIdentifier": (
f"https://dandiarchive.org/dandiset"
f"/{dandi_id_noprefix}/{version}"
),
"identifierType": "URL",
"alternateIdentifierType": "URL",
},
],
"publicationYear": "1970",
"publisher": "DANDI Archive",
"publisher": {
"name": "DANDI Archive",
"publisherIdentifier": "https://scicrunch.org/resolver/RRID:SCR_017571",
"publisherIdentifierScheme": "RRID",
"schemeUri": "https://scicrunch.org/resolver/",
"lang": "en",
},
"rightsList": [
{
"rightsIdentifier": "CC_BY_40",
"rightsIdentifierScheme": "SPDX",
"schemeURI": "https://spdx.org/licenses/",
"schemeUri": "https://spdx.org/licenses/",
}
],
"schemaVersion": "http://datacite.org/schema/kernel-4",
Expand Down
5 changes: 3 additions & 2 deletions dandischema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ def __get_pydantic_json_schema__(
if value.get("title") is None or value["title"] == prop.title():
value["title"] = name2title(prop)
if re.match("\\^https?://", value.get("pattern", "")):
# triggers only for ROR in identifier
value["format"] = "uri"
if value.get("format", None) == "uri":
value["maxLength"] = 1000
Expand Down Expand Up @@ -671,7 +672,7 @@ class PropertyValue(DandiBaseModel):
) # Note: recursive (circular or not)
propertyID: Optional[Union[IdentifierType, AnyHttpUrl]] = Field(
None,
description="A commonly used identifier for"
description="A commonly used identifier for "
"the characteristic represented by the property. "
"For example, a known prefix like DOI or a full URL.",
json_schema_extra={"nskey": "schema"},
Expand Down Expand Up @@ -993,10 +994,10 @@ class Person(Contributor):
json_schema_extra={"nskey": "schema"},
)
name: str = Field(
title="Use Last, First. Example: Lovelace, Augusta Ada",
description="Use the format: familyname, given names ...",
pattern=NAME_PATTERN,
json_schema_extra={"nskey": "schema"},
examples=["Lovelace, Augusta Ada", "Smith, John", "Chan, Kong-sang"],
)
affiliation: Optional[List[Affiliation]] = Field(
None,
Expand Down

0 comments on commit 5ca9e5e

Please sign in to comment.