Skip to content

Commit

Permalink
Update datacite to v4
Browse files Browse the repository at this point in the history
Updated the datacite serializer to 4.1
Updated `datacite` package version from `1.0.1` to `1.2.0` and `IDUtils` package version from `0.2.3` to `1.4.2`.
  • Loading branch information
zubeydecivelek authored and zzacharo committed Nov 12, 2024
1 parent 575aab8 commit 4d8052a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions cds/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,9 @@ def _parse_env_bool(var_name, default=None):
serializer="cds.modules.records.serializers:drupal_v1",
),
"dcite": dict(
title="Datacite XML v3.1",
title="Datacite XML v4.1",
mimetype="application/x-datacite+xml",
serializer="cds.modules.records.serializers:datacite_v31",
serializer="cds.modules.records.serializers:datacite_v41",
),
}

Expand Down Expand Up @@ -630,7 +630,7 @@ def _parse_env_bool(var_name, default=None):
"cds.modules.records.serializers" ":drupal_v1_response"
),
"application/x-datacite+xml": (
"cds.modules.records.serializers.datacite_v31_response"
"cds.modules.records.serializers.datacite_v41_response"
),
},
record_serializers_aliases={
Expand Down
4 changes: 2 additions & 2 deletions cds/modules/deposit/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from invenio_records_files.api import Record

from ...modules.records.minters import is_local_doi
from ...modules.records.serializers import datacite_v31
from ...modules.records.serializers import datacite_v41
from .api import Project


Expand Down Expand Up @@ -76,7 +76,7 @@ def datacite_register(self, pid_value, record_uuid, max_retries=5, countdown=5):
lang = record.get("language")
if lang and lang in ["zh_CN", "zh_TW"]:
record["language"] = "zh"
doc = datacite_v31.serialize(dcp.pid, record)
doc = datacite_v41.serialize(dcp.pid, record)

if dcp.pid.status == PIDStatus.REGISTERED:
dcp.update(url, doc)
Expand Down
8 changes: 4 additions & 4 deletions cds/modules/records/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
search_responsify,
)

from .datacite import CDSDataCite31Serializer
from .datacite import CDSDataCite41Serializer
from .drupal import DrupalSerializer
from .json import CDSJSONSerializer as JSONSerializer
from .schemas.datacite import DataCiteSchemaV1
Expand All @@ -51,7 +51,7 @@
drupal_v1 = DrupalSerializer(RecordSchemaJSONV1)

#: DataCite serializer
datacite_v31 = CDSDataCite31Serializer(DataCiteSchemaV1, replace_refs=True)
datacite_v41 = CDSDataCite41Serializer(DataCiteSchemaV1, replace_refs=True)

#: CDSDeposit serializer
cdsdeposit_json_v1 = JSONSerializer(RecordSchemaJSONV1, replace_refs=True)
Expand All @@ -71,8 +71,8 @@
#: Drupal record serializer for individual records.
drupal_v1_response = record_responsify(drupal_v1, "application/json")

#: DataCite v3.1 record serializer for individual records.
datacite_v31_response = record_responsify(datacite_v31, "application/x-datacite+xml")
#: DataCite v4.1 record serializer for individual records.
datacite_v41_response = record_responsify(datacite_v41, "application/x-datacite+xml")

#: CDSDeposit record serializer for individual records.
cdsdeposit_json_v1_response = record_responsify(cdsdeposit_json_v1, "application/json")
Expand Down
4 changes: 2 additions & 2 deletions cds/modules/records/serializers/datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

"""VTT serializer for records."""

from invenio_records_rest.serializers.datacite import DataCite31Serializer
from invenio_records_rest.serializers.datacite import DataCite41Serializer


class CDSDataCite31Serializer(DataCite31Serializer):
class CDSDataCite41Serializer(DataCite41Serializer):
"""Drupal serializer for records."""

def dump(self, obj, context=None):
Expand Down
4 changes: 2 additions & 2 deletions requirements.packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ click-repl==0.3.0
commonmark==0.9.1
counter-robots==2018.6
cryptography==42.0.8
datacite==1.0.1
datacite==1.2.0
dcxml==0.1.1
decorator==5.1.1
defusedxml==0.7.1
Expand Down Expand Up @@ -70,7 +70,7 @@ future==1.0.0
github3.py==4.0.1
greenlet==3.0.3
idna==3.7
IDUtils==0.2.3
IDUtils==1.4.2
importlib_metadata==8.0.0
importlib_resources==6.4.0
infinity==1.5
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ install_requires =
# extras
arrow>=0.7.0,<1.0.0
CairoSVG>=1.0.20,<2.0.0
datacite==1.0.1
datacite==1.2.0
dcxml==0.1.1
dictdiffer==0.9.0
idutils==0.2.3
idutils==1.4.2
invenio-sequencegenerator==1.0.0a3
requests-toolbelt>=1.0.0,<2.0.0
python-ldap>=3.4.0,<3.5.0
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_schema_datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

from invenio_records.api import Record

from cds.modules.records.serializers import datacite_v31
from cds.modules.records.serializers import datacite_v41


def test_video_metadata_tranform(app, video_record_metadata, recid_pid):
"""Test video metadata transformation."""
video_record_metadata["doi"] = "10.1234/foo"
obj = datacite_v31.transform_record(recid_pid, Record(video_record_metadata))
obj = datacite_v41.transform_record(recid_pid, Record(video_record_metadata))

expected = {
"creators": [
Expand Down Expand Up @@ -61,5 +61,5 @@ def test_video_metadata_tranform(app, video_record_metadata, recid_pid):
}
assert expected == obj

result = datacite_v31.serialize(pid=recid_pid, record=Record(video_record_metadata))
result = datacite_v41.serialize(pid=recid_pid, record=Record(video_record_metadata))
assert "<?xml version" in result

0 comments on commit 4d8052a

Please sign in to comment.