data_collections_api.cli package

Submodules

data_collections_api.cli.data_collections_main module

CLI for PSDI data-collections-api project.

data_collections_api.cli.data_collections_main.get_arg_parser() ArgumentParser[source]

Build argument parser for PSDI data-collection-api.

Returns:
ArgumentParser

Configured parser for CLI.

data_collections_api.cli.data_collections_main.main()[source]

Run main entry-point for CLI.

data_collections_api.cli.record_upload module

Script for uploading a record to an Invenio repository.

data_collections_api.cli.record_upload.cli()[source]

Run job through CLI.

data_collections_api.cli.record_upload.create_files_dict(all_files: Iterable[Path | str]) dict[str, Path][source]

Save file paths into a dictionary to a format e.g.

Parameters:
all_filesIterable[Path | str]

Files to load into dict.

Returns:
dict[str, Path]

Dictionary of file names and file paths.

Examples

files_dict = create_files_dict(["my_dir/*.file", "my_dir/example/*.cif"])
# files_dict = {
#    "name1.file": "my_dir/name1.file",
#    "name2.file": "my_dir/name2.file",
#    "name1.cif": "my_dir/example/name1.cif",
# }
data_collections_api.cli.record_upload.get_arg_parser(parser: ArgumentParser | None = None) ArgumentParser[source]

Return an argument parser for uploads, or configure a subparser if passed.

Parameters:
parserArgumentParser, optional

Parser (or SubParser) to configure.

Returns:
ArgumentParser

Configured parser for uploading records.

data_collections_api.cli.record_upload.main(args: Namespace)[source]

Upload records to Invenio repository.

Parameters:
argsNamespace

Arguments to pass to run_record_upload().

data_collections_api.cli.record_upload.run_record_upload(api_url: str, api_key: str, metadata_path: Path, metadata_format: Literal['json', 'yaml', 'ruamel', 'pyyaml'], files: Iterable[Path | str], community: str) None[source]

Run the uploading of metadata and associated files to an Invenio repository.

Parameters:
api_urlstr

URL of repository.

api_keystr

Repository API key.

metadata_pathPath

Path to metadata file.

metadata_formatFormats

Format of metadata file (json or yaml).

fileslist[Path | str]

Files to upload.

communitystr

Community to which files will be uploaded.

Module contents

Module containing CLI infrastructure for data-collections-API.