pygobbler package¶
Submodules¶
pygobbler.allocate_upload_directory module¶
- pygobbler.allocate_upload_directory.allocate_upload_directory(staging)[source]¶
Allocate a subdirectory in the staging directory to prepare files for upload via
upload_directory()
.
pygobbler.approve_probation module¶
pygobbler.clone_version module¶
- pygobbler.clone_version.clone_version(project, asset, version, destination, registry)[source]¶
Clone the directory structure for a versioned asset into a separate location. This is typically used to prepare a new version for a lightweight upload.
More specifically, cloning involves creating a directory at
destination
that has the same structure as that of the specified project-asset-version. All files in the version are represented as symlinks fromdestination
to the corresponding file in theregistry
.The idea is that, whendestination
is used inupload_directory()
, the symlinks are converted into upload links. This allows users to create new versions very cheaply as duplicate files are not stored in the backend.Users can more-or-less do whatever they want inside the cloned
destination
, but the symlink targets should be read-only as they refer to immutable files in theregistry
. If a file indestination
needs to be modified, the symlink should be deleted and replaced with a new file.
pygobbler.create_project module¶
- pygobbler.create_project.create_project(project, staging, url, owners=None, uploaders=None)[source]¶
Create a new project in the registry.
- Parameters:
project (
str
) – Name of the project to create.staging (
str
) – Path to the staging directory.url (
str
) – URL for the Gobbler REST API.owners (
Optional
[List
]) – List of user IDs of the owners of this project. If not provided, the current user will be set as the sole owner.uploaders (
Optional
[List
]) – List specifying the authorized uploaders for this project. See theuploaders
field infetch_permissions()
return value for the expected format.
- Returns:
On success, the requested project is created in the registry.
pygobbler.fetch_directory module¶
- pygobbler.fetch_directory.fetch_directory(path, registry, url, cache=None, force_remote=False, overwrite=False, concurrent=1)[source]¶
Obtain the path to a directory in the registry. This may create a local copy of the subdirectory’s contents if the caller is not on the same filesystem as the registry.
- Parameters:
path (
str
) – Relative path to a subdirectory within the registry. This usually takes the form ofPROJECT/ASSET/VERSION/*
.registry (
str
) – Path to the registry.url (
str
) – URL to the Gobbler REST API. Only used for remote queries.cache (
Optional
[str
]) – Path to a cache directory. If None, an appropriate location is automatically chosen. Only used for remote access.force_remote (
bool
) – Whether to force remote access. This will download all files in thepath
via the REST API and cache them locally, even ifregistry
is present on the same filesystem.overwrite (
bool
) – Whether to overwrite existing files in the cache.concurrent (
int
) – Number of concurrent downloads.
- Return type:
- Returns:
Path to the subdirectory on the caller’s filesystem. This is either a path to the registry if it is accessible, or a path to a local cache of the registry’s contents otherwise.
pygobbler.fetch_file module¶
- pygobbler.fetch_file.fetch_file(path, registry, url, cache=None, force_remote=False, overwrite=False)[source]¶
Obtain the path to a file in the registry. This may create a local copy if the caller is not on the same filesystem as the registry.
- Parameters:
path (
str
) – Relative path to a file within the registry. This usually takes the form ofPROJECT/ASSET/VERSION/*
.registry (
str
) – Path to the registry.url (
str
) – URL to the Gobbler REST API. Only used for remote queries.cache (
Optional
[str
]) – Path to a cache directory. If None, an appropriate location is automatically chosen. Only used for remote access.force_remote (
bool
) – Whether to force remote access. This will download all files in thepath
via the REST API and cache them locally, even ifregistry
is present on the same filesystem.overwrite (
bool
) – Whether to overwrite existing files in the cache.concurrent – Number of concurrent downloads.
- Return type:
- Returns:
Path to the file on the caller’s filesystem. This is either a path to the file in the registry if it is accessible, or a path to a local cache of the registry’s contents otherwise.
pygobbler.fetch_latest module¶
- pygobbler.fetch_latest.fetch_latest(project, asset, registry, url, force_remote=False)[source]¶
Fetch the latest version of an asset of a project.
- Parameters:
project (
str
) – Name of a project.asset (
str
) – Name of an asset in theproject
.registry (
str
) – Path to the Gobbler registry.url (
str
) – URL of the REST API. Only used for remote queries.force_remote (
bool
) – Whether to force a remote query viaurl
, even if theregistry
is present on the current filesystem.
- Return type:
- Returns:
The name of the latest version of the
asset
, or None if no latest version exists.
pygobbler.fetch_manifest module¶
- pygobbler.fetch_manifest.fetch_manifest(project, asset, version, registry, url, cache=None, force_remote=False, overwrite=False)[source]¶
Fetch the manifest for a version of a project asset.
- Parameters:
project (
str
) – Name of a project.asset (
str
) – Name of an asset in theproject
.version (
str
) – Name of a version of theasset
.registry (
str
) – Path to the Gobbler registry.url (
str
) – URL of the REST API. Only used for remote queries.cache (
Optional
[str
]) – Path to a cache directory. If None, a default cache location is selected. Only used for remote queries.force_remote (
bool
) – Whether to force a remote query viaurl
, even if theregistry
is present on the current filesystem.overwrite (
bool
) – Whether to overwrite existing entries in the cache. Only used for remote queries.
- Return type:
- Returns:
Dictionary containing the manifest. Each key is a relative path to a file in this version of the project asset, and each value is a dictionary with the following fields:
size
, integer specifying the size of the file in bytes.md5sum
, string containing the file’s hex-encoded MD5 checksum.link
(optional): a list specifying the link destination for a file. This contains the stringsproject
,asset
,version
andpath
; if the link destination is also a link, anancestor
dictionary will be present containing the final location of the file after resolving all intermediate links.
pygobbler.fetch_permissions module¶
- pygobbler.fetch_permissions.fetch_permissions(project, registry, url, force_remote=False)[source]¶
Fetch permissions for a project.
- Parameters:
- Return type:
- Returns:
A dictionary containing the permissions for the
project
. This containsowners
, a list of strings with the user IDs of the owners of this project; anduploaders
, a list of dictionaries where each dictionary has the following fields:id
, string containing a user ID that is authorized to upload.asset
(optional), string containing the name of the asset that the uploader is allowed to upload to. If not present, there is no restriction on the uploaded asset name.version
(optional), string containing the name of the version that the uploader is allowed to upload to. If not present, there is no restriction on the uploaded version name.until
(optional), string containing the expiry date of this authorization in Internet Date/Time format. If not provided, the authorization does not expire.trusted
(optional), whether the uploader is trusted. If not provided, defaults to false.
The top-level dictionary may also contain global_write, a boolean indicating whether global writes are supported. If true, any user may create a new asset in this project, and each user can upload new versions to any asset they created under this mode.
pygobbler.fetch_summary module¶
- pygobbler.fetch_summary.fetch_summary(project, asset, version, registry, url, cache=None, force_remote=False, overwrite=False)[source]¶
Fetch the summary for a particular version of a project asset.
- Parameters:
project (
str
) – Name of a project.asset (
str
) – Name of an asset in theproject
.version (
str
) – Name of a version of theasset
.registry (
str
) – Path to the Gobbler registry.url (
str
) – URL of the REST API. Only used for remote queries.cache (
Optional
[str
]) – Path to a cache directory. If None, a default cache location is selected. Only used for remote queries.force_remote (
bool
) – Whether to force a remote query viaurl
, even if theregistry
is present on the current filesystem.overwrite (
bool
) – Whether to overwrite existing entries in the cache. Only used for remote queries.
- Returns:
uploader_user_id
, string containing the UID of the uploading user.upload_start_time
, string containing the upload start time in Internet Date/Time format.upload_finish_time
, string containing the upload finish time in Internet Date/Time format.on_probation
(optional), boolean indicating whether this version of the asset is a probational upload.
- Return type:
Dictionary containing summary information including
pygobbler.fetch_usage module¶
pygobbler.list_assets module¶
pygobbler.list_files module¶
- pygobbler.list_files.list_files(project, asset, version, registry, url, prefix=None, include_dotdot=True, force_remote=False)[source]¶
List the contents of a version of a project asset.
- Parameters:
project (
str
) – The name of the project.asset (
str
) – The name of the asset inproject
.version (
str
) – The name of the version of theasset
.registry (
str
) – Path to the registry.url (
str
) – URL to the Gobbler REST API. Only used for remote access.prefix (
Optional
[str
]) – Prefix for the path within this version’s subdirectory. If provided, files are only listed if they have a relative path (i.e., inside the version subdirectory) that starts with this prefix. If None, all files associated with this version are listed.include_dotdot (
bool
) – Whether to list files with path components that start with..
.force_remote (
bool
) – Whether to force remote access via the API, even ifregistry
is on the same filesystem as the caller.
- Return type:
- Returns:
List of strings containing the relative paths of files associated with the versioned asset. All paths will start with
prefix
if provided.
pygobbler.list_projects module¶
pygobbler.list_versions module¶
- pygobbler.list_versions.list_versions(project, asset, registry, url, force_remote=False)[source]¶
List all versions of a project asset.
- Parameters:
project (
str
) – The name of the project.asset (
str
) – The name of the asset inproject
.registry (
str
) – Path to the registry.url (
str
) – URL to the Gobbler REST API. Only used for remote access.force_remote (
bool
) – Whether to force remote access via the API, even ifregistry
is on the same filesystem as the caller.
- Return type:
- Returns:
List of strings containing the project names.
pygobbler.refresh_latest module¶
pygobbler.refresh_usage module¶
pygobbler.reject_probation module¶
pygobbler.remove_asset module¶
pygobbler.remove_project module¶
pygobbler.remove_version module¶
pygobbler.service_info module¶
pygobbler.set_permissions module¶
- pygobbler.set_permissions.set_permissions(project, registry, staging, url, owners=None, uploaders=None, global_write=None, append=True)[source]¶
Set the owner and uploader permissions for a project.
- Parameters:
project (
str
) – Name of the project.registry (
str
) – Path to the Gobbler registry.staging (
str
) – Path to the staging directory.url (
str
) – URL of the REST API.owners (
Optional
[List
]) – List of user IDs for owners of this project. If None, no change is made to the existing owners in the project permissions.uploaders (
Optional
[Dict
]) – List of dictionaries specifying the authorized uploaders for this project. See theuploaders
field in the return value offetch_permissions()
for the expected format. If None, no change is made to the existing uploaders.global_write (
Optional
[bool
]) – Whether to enable global writes for this project, see theglobal_write
field in the return value offetch_permissions()
for more details. If None, no change is made to the global write status.append (
bool
) – Whetherowners
anduploaders
should be appended to the existing owners and uploaders, respectively. If False, theowners
anduploaders
are used to replace the existing values in the project permissions.
pygobbler.start_gobbler module¶
- pygobbler.start_gobbler.start_gobbler(staging=None, registry=None, port=None, wait=1, version='0.3.7', overwrite=False)[source]¶
Start a test Gobbler service.
- Parameters:
registry (
Optional
[str
]) – Path to a registry directory. If None, a temporary directory is automatically created.staging (
Optional
[str
]) – Path to a registry directory. If None, a temporary directory is automatically created.port (
Optional
[int
]) – Port number for the Gobbler API to receive requests. If None, an open port is automatically chosen.wait (
float
) – Number of seconds to wait for the service to initialize before use.version (
str
) – Version of the service to run.overwrite (
bool
) – Whether to overwrite the existing Gobbler binary.
- Return type:
- Returns:
A tuple indicating whether a new test service was created (or an existing instance was re-used), the path to the staging directory, the path to the registry, and the chosen URL. If a service is already running, this function is a no-op and the configuration details of the existing service will be returned.
- pygobbler.start_gobbler.stop_gobbler()[source]¶
Stop any gobbler test service started by
start_gobbler()
. If no test service was running, this function is a no-op.
pygobbler.unpack_path module¶
pygobbler.upload_directory module¶
- pygobbler.upload_directory.upload_directory(project, asset, version, directory, staging, url, probation=False)[source]¶
Upload a directory as a new versioned asset of a project in the registry.
- Parameters:
project (
str
) – The name of an existing project.asset (
str
) – The name of a new or existing asset inproject
.version (
str
) – The name of a new version ofasset
.directory (
str
) – Path to a directory to be uploaded. For best performace, this should be a subdirectory ofstaging
, e.g., as created byallocate_upload_directory()
.staging (
str
) – Path to the staging directory.url (
str
) – URL for the Gobbler REST API.probation (
bool
) – Whether to upload a probational version.
pygobbler.version_path module¶
- pygobbler.version_path.version_path(project, asset, version, **kwargs)[source]¶
Obtain the path to a versioned asset in the registry.
- Parameters:
project – The name of the project.
asset – The name of the asset of the
project
.version – The name of the version of the
asset
to obtain.kwargs – Further arguments to
fetch_directory()
.
- Return type:
- Returns:
The path to the directory containing the desired version.