ibridges.data_operations.upload
- ibridges.data_operations.upload(local_path, irods_path, overwrite=False, on_error='fail', resc_name='', copy_empty_folders=True, options=None, dry_run=False, metadata=None, progress_bar=True)
Upload a local directory or file to iRODS.
- Parameters:
local_path (
Union[str,Path]) – Absolute path to the directory to uploadirods_path (
IrodsPath) – Absolute irods destination pathoverwrite (
bool) – If data object or collection already exists on iRODS, overwriteon_error (
str) – When a transfer of a file fails, by default the whole transfer will stop and print the error message(fail). By setting ‘on-error’ to ‘warn’, those errors will be turned into warnings and the transfer continues with the next file. Setting ‘on-error’ to ‘skip’ will omit any message and simply proceed.resc_name (
str) – Name of the resource to which data is uploaded, by default the server will decidecopy_empty_folders (
bool) – Create respective iRODS collection for empty folders. Default: True.options (
Optional[dict]) – Python-irodsclient options found inirods.keywords. The following keywords will be ignored since they are set by iBridges: FORCE_FLAG_KW, RESC_NAME_KW, NUM_THREADS_KW, REG_CHKSUM_KW, VERIFY_CHKSUM_KW.dry_run (
bool) – Whether to do a dry run before uploading the files/folders.metadata (
Union[None,str,Path,dict]) – If not None, it should point to a file that contains the metadata for the upload.progress_bar (
bool) – Whether to display a progress bar.
- Return type:
- Returns:
Operations object that can be used to execute the upload in case of a dry-run.
- Raises:
FileNotFoundError: – If the local_path is not a valid filename of directory.
DataObjectExistsError: – If the data object to be uploaded already exists without using overwrite==True.
PermissionError: – If the iRODS server does not allow the collection or data object to be created.
Examples
>>> ipath = IrodsPath(session, "~/some_col") >>> # Below will create a collection with "~/some_col/dir". >>> upload(Path("dir"), ipath)
>>> # Same, but now data objects that exist will be overwritten. >>> upload(Path("dir"), ipath, overwrite=True)
>>> # Perform the upload in two steps with a dry-run >>> ops = upload(Path("some_file.txt"), ipath, dry_run=True) # Does not upload >>> ops.print_summary() # Check if this is what you want here. >>> ops.execute() # Performs the upload