ibridges.data_operations.upload

ibridges.data_operations.upload(session, local_path, irods_path, overwrite=False, ignore_err=False, resc_name='', copy_empty_folders=True, options=None, dry_run=False, metadata=None)

Upload a local directory or file to iRODS.

Parameters:
  • session (Session) – Session to upload the data to.

  • local_path (Union[str, Path]) – Absolute path to the directory to upload

  • irods_path (Union[str, IrodsPath]) – Absolute irods destination path

  • overwrite (bool) – If data object or collection already exists on iRODS, overwrite

  • ignore_err (bool) – If an error occurs during upload, and ignore_err is set to True, any errors encountered will be transformed into warnings and iBridges will continue to upload the remaining files. By default all errors will stop the process of uploading.

  • resc_name (str) – Name of the resource to which data is uploaded, by default the server will decide

  • copy_empty_folders (bool) – Create respective iRODS collection for empty folders. Default: True.

  • options (Optional[dict]) – More options for the upload

  • dry_run (bool) – Whether to do a dry run before uploading the files/folders.

  • metadata (Union[None, str, Path]) – If not None, it should point to a file that contains the metadata for the upload.

Return type:

Operations

Returns:

Operations object that can be used to execute the upload in case of a dry-run.

Raises:
  • ValueError: – If the local_path is not a valid filename of directory.

  • 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(session, Path("dir"), ipath)
>>> # Same, but now data objects that exist will be overwritten.
>>> upload(session, Path("dir"), ipath, overwrite=True)
>>> # Perform the upload in two steps with a dry-run
>>> ops = upload(session, 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