Skip to content

Commit 0f5814f

Browse files
nheebpoikilotherm
authored andcommitted
Implementation of requested changes (mainly renaming)
1 parent 43bd1b5 commit 0f5814f

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/hermes/commands/deposit/dataverse.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
class DataverseDepositSettings(BaseModel):
2222
"""Settings required to deposit into Dataverse."""
2323
site_url: str = ""
24-
host_dataverse: str = ""
25-
auth_token: str = ""
26-
dataset_pid: str = None
24+
target_collection: str = ""
25+
api_token: str = ""
26+
target_pid: str = None
27+
publication_type: str = "software"
2728
files: list[Path] = []
2829

2930

@@ -34,10 +35,10 @@ class DataverseDepositPlugin(BaseDepositPlugin):
3435
def __init__(self, command, ctx) -> None:
3536
super().__init__(command, ctx)
3637
self.config = getattr(self.command.settings, self.platform_name)
37-
auth_token = self.config.auth_token
38-
if not auth_token:
38+
api_token = self.config.api_token
39+
if not api_token:
3940
raise DepositionUnauthorizedError("No valid auth token given for deposition platform")
40-
self.client = Dataverse(server_url=self.config.site_url, api_token=self.config.auth_token)
41+
self.client = Dataverse(server_url=self.config.site_url, api_token=api_token)
4142
self.ctx_path = ContextPath.parse(f"deposit.{self.platform_name}")
4243

4344
def map_metadata(self) -> None:
@@ -51,7 +52,7 @@ def map_metadata(self) -> None:
5152
json.dump(metadata, f, indent=2)
5253

5354
def is_initial_publication(self) -> bool:
54-
return self.config.dataset_pid is None
55+
return self.config.target_pid is None
5556

5657
def update_metadata_on_dataset(self, dataset: Dataset):
5758
"""
@@ -78,7 +79,7 @@ def update_metadata_on_dataset(self, dataset: Dataset):
7879
dataset.citation.date_of_deposit = date_published
7980
# TODO look for "version" or something similar in dataverse
8081
# if version := metadata.get("version"):
81-
# dataset.citation.version = version <- does not exist
82+
# dataset.citation.softwareVersion = version
8283
if keywords := metadata.get("keywords", []):
8384
if keywords is list:
8485
for keyword in keywords:
@@ -88,7 +89,7 @@ def update_metadata_on_dataset(self, dataset: Dataset):
8889
dataverse_license = License.fetch_by_name(deposition_license, server_url=self.client.server_url)
8990
dataset.citation.license = dataverse_license
9091
except Exception as e:
91-
_log.warning(f"Could not match license '{deposition_license}' to Dataverse vocabulary: {e}")
92+
_log.warning(f"Could not match license '{deposition_license}' to allowed licenses for deposition: {e}")
9293
dataset.citation.other_references = [f"Compiled by HERMES ({hermes_doi})"]
9394

9495
def create_initial_version(self) -> None:
@@ -102,7 +103,7 @@ def create_initial_version(self) -> None:
102103
raise RuntimeError("Please use `--initial` to make an initial deposition.")
103104
dataset = self.client.create_dataset()
104105
self.update_metadata_on_dataset(dataset)
105-
persistent_id = dataset.upload(dataverse_name=self.config.host_dataverse)
106+
persistent_id = dataset.upload(dataverse_name=self.config.target_collection)
106107
self.ctx.update(self.ctx_path["persistentId"], persistent_id)
107108

108109
def create_new_version(self) -> None:
@@ -151,7 +152,7 @@ def publish(self) -> None:
151152
persistent_id = self.ctx[self.ctx_path["persistentId"]]
152153
url = f"{self.config.site_url}/api/datasets/:persistentId/actions/:publish"
153154
params = {"type": "major"}
154-
headers = {"X-Dataverse-key": self.config.auth_token}
155+
headers = {"X-Dataverse-key": self.config.api_token}
155156
res = requests.post(url, headers=headers, params=params, data={"persistentId": persistent_id})
156157
if not res.ok:
157158
raise RuntimeError(f"Publish failed: {res.status_code}: {res.text}")

src/hermes/commands/init/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class DepositId(Enum):
4444
Zenodo = auto()
4545
ZenodoSandbox = auto()
4646
JuelichData = auto()
47+
JuelichDataBeta = auto()
4748
DemoDataverse = auto()
4849
Rodare = auto()
4950
RodareTest = auto()
@@ -74,7 +75,8 @@ def __init__(self, name: str = "", url: str = "", plugin_name: str = "", deposit
7475
DepositPlatform("Zenodo Sandbox", "https://sandbox.zenodo.org/", "invenio_rdm", DepositId.ZenodoSandbox),
7576
DepositPlatform("Zenodo", "https://zenodo.org/", "invenio_rdm", DepositId.Zenodo),
7677
DepositPlatform("Demo Dataverse", "https://demo.dataverse.org/", "dataverse", DepositId.DemoDataverse),
77-
DepositPlatform("Jülich Data", "https://data.fz-juelich.de/", "dataverse", DepositId.JuelichData),
78+
DepositPlatform("Jülich DATA", "https://data.fz-juelich.de/", "dataverse", DepositId.JuelichData),
79+
DepositPlatform("Jülich DATA Beta", "https://data-beta.fz-juelich.de/", "dataverse", DepositId.JuelichDataBeta),
7880
DepositPlatform("Rodare", "https://rodare.hzdr.de/", "rodare", DepositId.Rodare),
7981
DepositPlatform("Rodare Test", "https://rodare-test.hzdr.de/", "rodare", DepositId.RodareTest),
8082
]
@@ -704,10 +706,10 @@ def integrate_deposit_platform(self) -> None:
704706
# Invenio needs access_right = "open" (no idea what that does, might be outdated)
705707
if deposit_plugin.startswith("invenio"):
706708
self.hermes_toml_data["deposit"][deposit_plugin]["access_right"] = "open"
707-
# Dataverse needs a host_dataverse name as some sort of directory where the publication will appear
709+
# Dataverse needs a target_collection name as some sort of directory where the publication will appear
708710
elif deposit_plugin.startswith("dataverse"):
709-
host_dataverse = sc.answer("Enter the name of the dataverse where you want to publish: ")
710-
self.hermes_toml_data["deposit"][deposit_plugin]["host_dataverse"] = host_dataverse
711+
target_collection = sc.answer("Enter the name of the collection where you want to publish: ")
712+
self.hermes_toml_data["deposit"][deposit_plugin]["target_collection"] = target_collection
711713
# Rodare needs the robis_pub_id
712714
elif deposit_plugin.startswith("rodare"):
713715
robis_pub_id = sc.answer("Enter the corresponding Robis Publication ID: ")

0 commit comments

Comments
 (0)