quartzbio.resource.object module

QuartzBio Object API resource

class quartzbio.resource.object.Object(id=None, **params)

Bases: CreateableAPIResource, ListableAPIResource, DeletableAPIResource, SearchableAPIResource, UpdateableAPIResource, DownloadableAPIResource

An object is a resource in a Vault. It has three possible types, though more may be added later: folder, file, and QuartzBio Dataset.

LIST_FIELDS = (('id', 'ID'), ('object_type', 'Type'), ('full_path', 'Full Path'), ('description', 'Description'))
PATH_RE = re.compile('^[^\\/]*(?P<path>(\\/[^\\/]*)+)$')
RESOURCE_VERSION = 2
archive(storage_class=None, follow=False)

Archive this dataset

classmethod create_folder(vault, full_path, tags=None, **kwargs)

Create a folder if not exists.

Parameters:
  • vault (Vault) – A Vault object.

  • full_path (str) – Full path including vault name.

  • tags (list[str]) – List of tags to put on folder.

  • client – QuartzBio client configuration to use.

Returns:

New folder object

Return type:

Object

Raises:

QuartzBioError – if a file or dataset object already exists at the given full_path.

create_shortcut(shortcut_full_path, **kwargs)

Create a shortcut to the current object at shortcut_full_path

Parameters:
  • shortcut_full_path (str) – Full path including vault name.

  • tags (list[str]) – List of tags to put on shortcut.

Returns:

New shortcut object

Return type:

Object

Raises:

QuartzBioError – if a object already exists at the given shortcut_full_path.

property data_url
property dataset

Returns the dataset object

datasets(**params)
delete_version(version_id)

Marks the specified version as deleted. Only file objects can have versions.

disable_global_beacon()

Disable Global Beacon for this object (datasets only).

enable_global_beacon()

Enable Global Beacon for this object (datasets only).

files(**params)
folders(**params)
classmethod get_by_full_path(full_path, **params)
classmethod get_by_path(path, **params)
get_global_beacon_status(raise_on_disabled=False)

Retrieves the Global Beacon status for this object (datasets only).

classmethod get_or_create_by_full_path(full_path, **kwargs)
get_target(return_none_target=True)
has_tag(tag)

Return True if object contains tag

property is_dataset
property is_file
property is_folder
property is_shortcut
list_versions(include_deleted=True)

Returns all the versions for this object. Only file objects can have versions.

ls(**params)
objects(**params)
property parent

Returns the parent object

query(**params)

Return the Query or QueryFile object depending on object type that represents query results against an object.

classmethod refresh_presigned_urls(upload_id, key, total_size, part_numbers, **kwargs)

Refresh presigned URLs for multipart upload

Parameters:
  • upload_id (str) – The upload ID from the multipart upload

  • key (str) – The upload key/identifier

  • total_size (int) – Total size of the file being uploaded

  • part_numbers (list[int]) – List of part numbers to refresh URLs for

  • **kwargs – Additional parameters including client

Returns:

List of presigned URL objects with part information

Return type:

list

restore(storage_class=None, follow=False, **kwargs)

Restore this dataset

restore_version(version_id)

Sets the current version to the specified version. This is done by creating a new version with the same content as the specified version. Only file objects can have versions.

tag(tags, remove=False, dry_run=False, apply_save=True)

Add or remove tags on an object

undelete_version(version_id)

Marks the specified version as not deleted. Only file objects can have versions.

untag(tags, dry_run=False, apply_save=True)

Remove tags on an object

classmethod upload_file(local_path, remote_path, vault_full_path, **kwargs)

Upload a file to a QuartzBio vault.

Automatically uses multipart upload for files larger than the multipart_threshold.

Parameters:
  • local_path (str) – Path to the local file to upload

  • remote_path (str) – Remote path within the vault

  • vault_full_path (str) – Full path of the target vault

  • **kwargs – Additional options: multipart_threshold (int): File size threshold for multipart upload (default: 64MB) multipart_chunksize (int): Size of each upload part (default: 64MB) num_processes (int): Number of parallel workers for multipart upload (default: 1) max_retries (int): Maximum retries per part for multipart upload (default: 3) archive_folder (str): Archive existing files to this folder before upload follow_shortcuts (bool): Follow shortcuts when uploading description (str): Description for the uploaded file tags (list): Tags to apply to the uploaded file client: QuartzBio client instance to use

Returns:

The uploaded file object

Return type:

Object

Raises:
classmethod validate_full_path(full_path, **kwargs)

Helper method to parse a full or partial path and return a full path as well as a dict containing path parts.

Uses the following rules when processing the path:

  • If no domain, uses the current user’s account domain

  • If no vault, uses the current user’s personal vault.

  • If no path, uses ‘/’ (vault root)

Returns a tuple containing:

  • The validated full_path

  • A dictionary with the components:
    • domain: the domain of the vault

    • vault: the name of the vault, without domain

    • vault_full_path: domain:vault

    • path: the object path within the vault

    • parent_path: the parent path to the object

    • parent_full_path: the parent full path to the object

    • filename: the object’s filename (if any)

    • full_path: the validated full path

The following components may be overridden using kwargs:

  • vault

  • path

Object paths (also known as “paths”) must begin with a forward slash.

The following path formats are supported:

domain:vault:/path -> object “path” in the root of “domain:vault” domain:vault/path -> object “path” in the root of “domain:vault” vault:/path -> object “path” in the root of “vault” vault/path -> object “path” in the root of “vault” ~/path -> object “path” in the root of personal vault vault/ -> root of “vault” ~/ -> root of your personal vault

The following two formats are not supported:

path -> invalid/ambiguous path (exception) vault:path -> invalid/ambiguous path (exception) vault:path/path -> unsupported, interpreted as domain:vault/path

property vault

Returns the vault object

class quartzbio.resource.object.UploadProgressTracker(total_parts, total_size)

Bases: object

Simple progress tracking for multipart uploads.

get_average_speed()

Get average upload speed in bytes/second

get_completion_percentage()

Get completion percentage

get_elapsed_time()

Get total elapsed time

notify_error()

Notify that an error message will be printed - move to new line

update_progress(part_size, part_duration=None)

Update progress with new part completion - overwrites same line