@@ -205,10 +205,33 @@ def create_distribution(
205205
206206 return f"{ url } |{ meta_string } "
207207
208- def create_distributions_from_metadata (metadata ):
208+ def create_distributions_from_metadata (metadata : List [Dict [str , Union [str , int ]]]) -> List [str ]:
209+ """
210+ Create distributions from metadata entries.
211+
212+ Parameters
213+ ----------
214+ metadata : List[Dict[str, Union[str, int]]]
215+ List of metadata entries, each containing:
216+ - filename: str - Name of the file
217+ - checksum: str - SHA-256 hex digest (64 characters)
218+ - size: int - File size in bytes (positive integer)
219+ - url: str - Download URL for the file
220+
221+ Returns
222+ -------
223+ List[str]
224+ List of distribution identifier strings for use with create_dataset
225+ """
209226 distributions = []
210227 counter = 0
211228 for entry in metadata :
229+ # Validate required keys
230+ required_keys = ["filename" , "checksum" , "size" , "url" ]
231+ missing_keys = [key for key in required_keys if key not in entry ]
232+ if missing_keys :
233+ raise ValueError (f"Metadata entry missing required keys: { missing_keys } " )
234+
212235 filename = entry ["filename" ]
213236 checksum = entry ["checksum" ]
214237 size = entry ["size" ]
@@ -443,7 +466,35 @@ def deploy(
443466 print (resp .text )
444467
445468
446- def deploy_from_metadata (metadata , version_id , title , abstract , description , license_url , apikey ):
469+ def deploy_from_metadata (
470+ metadata : List [Dict [str , Union [str , int ]]],
471+ version_id : str ,
472+ title : str ,
473+ abstract : str ,
474+ description : str ,
475+ license_url : str ,
476+ apikey : str
477+ ) -> None :
478+ """
479+ Deploy a dataset from metadata entries.
480+
481+ Parameters
482+ ----------
483+ metadata : List[Dict[str, Union[str, int]]]
484+ List of file metadata entries (see create_distributions_from_metadata)
485+ version_id : str
486+ Dataset version ID in the form $DATABUS_BASE/$ACCOUNT/$GROUP/$ARTIFACT/$VERSION
487+ title : str
488+ Dataset title
489+ abstract : str
490+ Short description of the dataset
491+ description : str
492+ Long description (Markdown supported)
493+ license_url : str
494+ License URI
495+ apikey : str
496+ API key for authentication
497+ """
447498 distributions = create_distributions_from_metadata (metadata )
448499
449500 dataset = create_dataset (
@@ -458,8 +509,10 @@ def deploy_from_metadata(metadata, version_id, title, abstract, description, lic
458509 print (f"Deploying dataset version: { version_id } " )
459510 deploy (dataset , apikey )
460511
461- metadata_string = ",\n " .join (entry ["url" ] for entry in metadata )
462- print (f"Successfully deployed\n { metadata_string } \n to databus { version_id } " )
512+ print (f"Successfully deployed to { version_id } " )
513+ print (f"Deployed { len (metadata )} file(s):" )
514+ for entry in metadata :
515+ print (f" - { entry ['filename' ]} " )
463516
464517
465518def __download_file__ (url , filename , vault_token_file = None , auth_url = None , client_id = None ) -> None :
0 commit comments