Metadata-Version: 2.4
Name: quilt
Version: 3.0.0rc1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: 3
Summary: The quilt-rs engine for Python: dataspaces, as quilt3 uses them.
Home-Page: https://www.quiltdata.com
Author-email: quiltdata <support@quilt.bio>
License-Expression: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://quilt.bio/
Project-URL: Repository, https://github.com/quiltdata/quilt-rs

# quilt (Python)

The Python binding of [`quilt-rs`](../quilt-rs/), built with
[maturin](https://www.maturin.rs/) into platform wheels and published to PyPI
as `quilt` 3.0. quilt3 depends on it to work with dataspaces through the
engine, as [quilt-specs#297](https://github.com/quiltdata/quilt-specs/pull/297)
rules. It replaces the legacy Quilt 2 library on PyPI (2.9.15), so
`pip install -U quilt` on a Quilt 2 install gets this one.

```python
from pathlib import Path

import quilt

data = Path("~/data").expanduser()
quilt.install("quilt+s3://bucket#package=team/raw", dataspace=data)
quilt.create("quilt+s3://bucket#package=team/new", dataspace=data)
quilt.commit("team/raw", "first", dataspace=data)
quilt.publish("team/raw", data)
quilt.status(data)
quilt.history("team/raw")
quilt.list_registries()
quilt.browse("team/raw", dataspace=data)
quilt.resolve_hash("quilt+s3://bucket#package=team/raw", "1a2b3c4")
quilt.delete("team/raw")
```

Every call blocks until the engine is done, without holding the GIL, on a
Tokio runtime the module owns. A call that names no `dataspace` acts on the
one the `quilt` CLI would: `QUILT_DATASPACE`, else the nearest `data.toml` at
or above the working folder, else the default dataspace chosen for the
application folder, `home`, as `quilt home` chooses it, falling back on
`<Documents>/Quilt/dataspace` where none was chosen. Choosing the default
gives a `quilt.DefaultDataspaceWarning` once per process. `active_dataspace`
says which dataspace a call would use and why, and `set_default_dataspace`
chooses the default. `home` defaults to the folder the `quilt` CLI and
QuiltSync keep, which also holds the credentials. A call that names no
`domain` uses `QUILT_DOMAIN`, else `bio.quilt.dataspace` in the OS's local
data folder. A failure raises `quilt.QuiltError`.

`create` and `commit` check the commit against its bucket's current
workflows config and record it either way: the dict they return lists what
the check found under `warnings`, each with `kind` (`inconsistent`, so a push
there will be refused until it is fixed, or `unchecked`, where the config
could not be read or its validator is misconfigured), `bucket`, `reason` and
the `message` the CLI prints. A package in the local registry is not checked.

`browse` opens a package of a dataspace at the revision its lock holds, its
last local commit, else its base, and returns its `manifest` as JSON Lines
text with its `hash`. `resolve_hash` matches a short top hash among the
package's own installed manifests in its store. `delete` removes a package,
or with `top_hash` one revision of it, from every local Package Store and the
local registry, and returns what it removed from each; the dataspaces, the
buckets and the data objects are left.

`status` returns what `quilt status --json` reports of a dataspace, in the
same shape, with `dataspace_source`, the rule that chose it. `publish`
publishes one `sync` entry's last local commit to the registry its
declaration names, the local registry included, and bases the lock at it,
without running the sync tick: it never merges, and a package whose base is
behind `latest` raises `quilt.ConflictError`, a `QuiltError`, for `quilt sync`
or QuiltSync to merge. With no local commit it publishes nothing, and its
`outcome` says `nothing`. `history` lists a package's revisions newest first,
each with `hash`, `message`, `time`, `parent`, `local` and `registry`: with a
`registry` (`s3://<bucket>`, or `quilt+local://` for this machine's) as
`quilt log` lists them from the dataspace, and with none the revisions of
the name the Domain holds, the local registry's and the commits made here
to any bucket's package, asking no registry; there a bucket's revision whose
`local` cannot be told without asking the bucket says `None`.

`entries` lists the packages a dataspace's contract declares, each with its
`access`, `folder` and `paths`, so quilt3's build can tell a build onto an
existing entry from a new package. `set_package_metadata` replaces the
package metadata in a working folder's `metadata.toml`, which its next
commit publishes.

## Develop

```sh
cd quilt-py
uv venv && uv pip install maturin pytest
uv run maturin develop
uv run pytest tests
```

`cargo test -p quilt-py` tests the engine layer without Python.

