In-memory representation of a package
Provides a generator of the dicts that make up the serialized package.
Returns the top hash of the package.
Note that physical keys are not hashed because the package has the same semantics regardless of where the bytes come from.
Returns
A string that represents the top hash of the package
String representation of the Package.
Installs a named package to the local registry and downloads its files.
Arguments
quilt+s3:// package URI to install.path or its children.A package URI cannot be combined with registry, top_hash, or path.
Its optional path uses the same selective-install behavior as path.
Find a hash that starts with a given prefix.
Arguments
Load a package into memory from a registry without making a local copy of the manifest.
Arguments
quilt+s3:// package URI to load.A package URI cannot be combined with registry or top_hash. If
the URI selects a path, return that entry or subpackage instead of the
full package.
Checks whether the package contains a specified logical_key.
Returns
True or False
Filters the package based on prefix, and returns either a new Package or a PackageEntry.
Arguments
Returns
PackageEntry if prefix matches a logical_key exactly otherwise Package
Copy all descendants to dest. Descendants are written under their logical
names relative to self.
Arguments
Returns
A new Package object with entries from self, but with physical keys
pointing to files in dest.
Returns logical keys in the package.
Generator that traverses all entries in the package tree and returns tuples of (key, entry), with keys in alphabetical order.
Loads a package from a readable file-like object.
Arguments
Returns
A new Package object
Raises
file not found json decode error invalid package exception
Adds all files from path to the package.
Recursively enumerates every file in path, and adds them to
the package according to their relative location to path.
Arguments
Returns
self
Raises
PackageException: When path doesn’t exist.ValueError: When update_policy is invalid.Gets object from logical_key and returns its physical path. Equivalent to self[logical_key].get().
Arguments
Returns
Physical path as a string.
Raises
KeyError: when logical_key is not present in the packageValueError: if the logical_key points to a Package rather than PackageEntry.Returns the README PackageEntry
The README is the entry with the logical key ‘README.md’ (case-sensitive). Will raise a QuiltException if no such entry exists.
Sets user metadata on this Package.
Serializes this package to a registry.
Arguments
None to skip workflow validation.
If not specified, the default workflow will be used.Returns
The top hash as a string.
Serializes this package to a writable file-like object.
Arguments
Returns
None
Raises
fail to create file fail to finish write
Returns self with the object at logical_key set to entry.
Arguments
quilt3.formats.FormatRegistry.all_supported_formats()Returns
self
Returns self with logical_key removed.
Returns
self
Raises
KeyError: when logical_key is not present to be deletedCreates a new package, or a new revision of an existing package in a package registry in Amazon S3.
By default, any files not currently in the destination bucket are copied to the destination S3 bucket at a path matching logical key structure. Files in the destination bucket are not copied even if they are not located in in the location matching the logical key. After objects are copied, a new package manifest is package manifest is created that points to the objects in their new locations.
The optional parameter selector_fn allows callers to choose which
files are copied to the destination bucket, and which retain their
existing physical key. When using selector functions, it is important to
always copy local files to S3, otherwise the resulting package will be
inaccessible to users accessing it from Amazon S3.
The Package class includes two additional built-in selector functions:
Package.selector_fn_copy_all copies all files to the destination path
regardless of their current location.Package.selector_fn_copy_local copies only local files to the
destination path. Any PackageEntry’s with physical keys pointing to
objects in other buckets will retain their existing physical keys in
the resulting package.If we have a package with entries:
pkg["entry_1"].physical_key = s3://bucket1/folder1/entry_1pkg["entry_2"].physical_key = s3://bucket2/folder2/entry_2And, we call pkg.push("user/pkg_name", registry="s3://bucket2"), the
file referenced by entry_1 will be copied, while the file referenced by
entry_2 will not. The resulting package will have the following entries:
pkg["entry_1"].physical_key = s3://bucket2/user/pkg_name/entry_1pkg["entry_2"].physical_key = s3://bucket2/folder1/entry_2Quilt3 Versions 6.3.1 and earlier copied all files to the destination
path by default. To match this behavior in later versions, callers
should use selector_fn=Package.selector_fn_copy_all.
Using the same initial package and push, but adding
selector_fn=Package.selector_fn_copy_all will result in both files
being copied to the destination path, producing the following package:
pkg["entry_1"].physical_key = s3://bucket2/user/pkg_name/entry_1pkg["entry_2"].physical_key = s3://bucket2/user/pkg_name/entry_2Note that push is careful to not push data unnecessarily. To illustrate,
imagine you have a PackageEntry:
pkg["entry_1"].physical_key = "/tmp/package_entry_1.json"
If that entry would be pushed to s3://bucket/prefix/entry_1.json, but
s3://bucket/prefix/entry_1.json already contains the exact same bytes
as ‘/tmp/package_entry_1.json’, quilt3 will not push the bytes to S3,
no matter what selector_fn('entry_1', pkg["entry_1"]) returns.
By default, push will not overwrite an existing package if its top hash does not match
the parent hash of the package being pushed. Use force=True to skip the check.
A successful push records the revision it published on the package it was called on, in
addition to the package it returns. Either object can therefore push again – as the next
revision at the same destination, or as the same revision to another registry holding the
parent – without an intervening browse() and without force=True.
Arguments
None to skip workflow validation.
If not specified, the default workflow will be used.For details see: https://docs.quilt.bio/advanced-usage/workflows
Returns
A new package that points to the copied objects.
Set the “latest” version to the given hash.
Arguments
Returns three lists – added, modified, deleted.
Added: present in other_pkg but not in self. Modified: present in both, but different. Deleted: present in self, but not other_pkg.
Arguments
Returns
added, modified, deleted (all lists of logical keys)
Performs a user-specified operation on each entry in the package.
Arguments
Returns: list The list of results generated by the map.
Applies a user-specified operation to each entry in the package, removing results that evaluate to False from the output.
Arguments
Returns
A new package with entries that evaluated to False removed
Check if the contents of the given directory matches the package manifest.
Arguments
Returns
True if the package matches the directory; False otherwise.
Represents an entry at a logical key inside a package.
__init__
Creates an entry.
Arguments
s3:// or file://)Returns
a PackageEntry
Returns dict representation of entry.
Sets the user_meta for this PackageEntry.
Returns self with the physical key set to path.
Arguments
Returns
self
Returns the physical key of this PackageEntry.
Returns a locally cached physical key, if available.
Returns the bytes of the object this entry corresponds to. If ‘use_cache_if_available’=True, will first try to retrieve the bytes from cache.
Returns a JSON file as a dict. Assumes that the file is encoded using utf-8.
If ‘use_cache_if_available’=True, will first try to retrieve the object from cache.
Return the object as a string. Assumes that the file is encoded using utf-8.
If ‘use_cache_if_available’=True, will first try to retrieve the object from cache.
Returns the object this entry corresponds to.
Arguments
Returns
The deserialized object from the logical_key
Raises
physical key failure hash verification fail when deserialization metadata is not present
Gets objects from entry and saves them to dest.
Arguments
Returns
None
Shorthand for self.deserialize()