ibridges.data_operations.download
- ibridges.data_operations.download(session, irods_path, local_path, overwrite=False, ignore_err=False, resc_name='', copy_empty_folders=True, options=None, dry_run=False, metadata=None)
Download a collection or data object to the local filesystem.
- Parameters:
session (
Session) – Session to download the collection from.irods_path (
Union[str,IrodsPath]) – Absolute irods source path pointing to a collectionlocal_path (
Union[str,Path]) – Absolute path to the destination directoryoverwrite (
bool) – If an error occurs during download, and ignore_err is set to True, any errors encountered will be transformed into warnings and iBridges will continue to download the remaining files. By default all errors will stop the process of downloading.ignore_err (
bool) – Collections: If download of an item fails print error and continue with next item.resc_name (
str) – Name of the resource from which data is downloaded, by default the server will decide.copy_empty_folders (
bool) – Create respective local directory for empty collections.options (
Optional[dict]) – More options for the downloaddry_run (
bool) – Whether to do a dry run before uploading the files/folders.metadata (
Union[None,str,Path]) – If not None, the path to store the metadata to in JSON format. It is recommended to use the .json suffix.
- Return type:
- Returns:
Operations object that can be used to execute the download in case of a dry-run.
- Raises:
PermissionError: – If the iRODS server (for whatever reason) forbids downloading the file or (part of the) collection.
ValueError: – If the irods_path is not pointing to either a collection or a data object.
FileExistsError: – If the irods_path points to a data object and the local file already exists.
NotADirectoryError: – If the irods_path is a collection, while the destination is a file.
Examples
>>> # Below will create a directory "some_local_dir/some_collection" >>> download(session, "~/some_collection", "some_local_dir")
>>> # Below will create a file "some_local_dir/some_obj.txt" >>> download(session, IrodsPath(session, "some_obj.txt"), "some_local_dir")
>>> # Below will create a file "new_file.txt" in two steps. >>> ops = download(session, "~/some_obj.txt", "new_file.txt", dry_run=True) >>> ops.execute()