2121class 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 } " )
0 commit comments