nipoppy.zenodo_api.ZenodoAPI¶
- class nipoppy.zenodo_api.ZenodoAPI(sandbox=False, password_file=None, logger=None, timeout=10.0)¶
Client to interact with Zenodo API.
Zenodo uses the InvenioRDM API, which is documented at: https://inveniordm.docs.cern.ch/reference/rest_api_index/
This class manages a persistent
httpx.Clientsession for all HTTP communication. It supports use as a context manager (withstatement) for automatic resource cleanup, and exposes an explicitclose()method for manual cleanup.- Parameters:
sandbox (bool)
password_file (Optional[pathlib.Path])
logger (Optional[logging.Logger])
timeout (float)
- close()¶
Close the underlying HTTP client and release connections.
- Return type:
None
- download_record_files(record_id, output_dir)¶
Download the files of a Zenodo record in the output_dir directory.
- Parameters:
record_id (str) – Record ID in Zenodo.
output_dir (Path) – Output directory to save the files.
- Raises:
ChecksumError – Checksum mismatch between the downloaded file and the expected checksum.
- get_latest_version_id(record_id)¶
Get the ID of the latest version of a Zenodo record.
- search_records(query, sort='mostdownloaded', community_id=None, keywords=None, size=10)¶
Search for records in Zenodo.
- set_authorization(access_token)¶
Set the headers for the ZenodoAPI instance.
- Parameters:
access_token (str)
- upload_record(input_dir, metadata, record_id=None, default_preview_filename=None)¶
Upload a pipeline to Zenodo.
- Parameters:
input_dir (pathlib.Path)
metadata (dict)
record_id (Optional[str])
default_preview_filename (Optional[str])
- Return type:
- api_endpoint = 'https://sandbox.zenodo.org/api'¶
- client¶
- property logger: logging.Logger¶
Get the logger for the ZenodoAPI instance.
- Return type:
- password_file = None¶
- sandbox = False¶
- timeout = 10.0¶