Metadata-Version: 2.5
Name: artifactum
Version: 0.4.0
Summary: A registry and lineage tracker for the files data teams produce
Project-URL: Homepage, https://atfm.io
Project-URL: Repository, https://github.com/atfm-io/artifactum
Project-URL: Issues, https://github.com/atfm-io/artifactum/issues
Author-email: Chris Cole <chris.c.1221@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: artifacts,data lineage,data versioning,provenance,reproducibility
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: jsonargparse>=4.35
Requires-Dist: pyperclip>=1.8
Requires-Dist: rich>=13.0
Requires-Dist: textual>=0.70
Requires-Dist: tomli-w>=1.0
Requires-Dist: tomli>=1.1; python_version < '3.11'
Provides-Extra: dev
Requires-Dist: pre-commit>=3.5; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Provides-Extra: gcs
Requires-Dist: google-cloud-storage>=2.0; extra == 'gcs'
Description-Content-Type: text/markdown

# Artifactum · `atfm`

[![PyPI](https://img.shields.io/pypi/v/artifactum)](https://pypi.org/project/artifactum/)
[![Python](https://img.shields.io/python/required-version-toml?tomlFilePath=https://raw.githubusercontent.com/atfm-io/artifactum/main/pyproject.toml&label=python)](https://pypi.org/project/artifactum/)
[![Downloads](https://img.shields.io/pypi/dm/artifactum)](https://pypistats.org/packages/artifactum)
[![Tests](https://github.com/atfm-io/artifactum/actions/workflows/tests.yml/badge.svg)](https://github.com/atfm-io/artifactum/actions/workflows/tests.yml)
[![Coverage](https://codecov.io/gh/atfm-io/artifactum/graph/badge.svg)](https://codecov.io/gh/atfm-io/artifactum)
[![License: MIT](https://img.shields.io/pypi/l/artifactum)](https://github.com/atfm-io/artifactum/blob/main/LICENSE)

[atfm.io](https://atfm.io) · `pip install artifactum` · `import artifactum as atfm` · the `atfm` command

A registry and lineage tracker for the files data teams produce: datasets, models, results and figures.

Every file you publish gets a permanent ID, and Artifactum records where it came from: the artifacts your
code read, the git commit and code that ran, and who published it. Files stay in storage your team
controls, a shared directory or a Google Cloud Storage bucket; Artifactum stores only metadata.

## Install

```bash
pip install artifactum
atfm init
```

The package is `artifactum`. `pip install atfm` works too: [atfm](https://pypi.org/project/atfm/) is a
placeholder we publish so nobody else can take the name, and it only installs `artifactum`.

`init` asks for your API token (from Settings at [atfm.io](https://atfm.io)) and where to store files. Or
give them and skip the questions:

```bash
atfm init --token atfm_... --storage ~/atfm-files
```

## Storage

Artifactum never holds your files. Each one is copied to your team's storage when it's published and
fetched from there when someone reads it, then cached locally.

| Storage | Location to give `init` | Install |
| --- | --- | --- |
| A shared directory (lab server, cluster, network drive) | `/groups/lab/atfm` | `pip install artifactum` |
| Google Cloud Storage | `gs://my-team-bucket/atfm` | `pip install 'artifactum[gcs]'` |

A shared directory needs no cloud account: everyone on the team just needs to reach it **at the same
path**, since the registry records where each file is. Files are stored by content, under
`<location>/<hash[:2]>/<hash>/<filename>`, and never overwritten.

For Google Cloud Storage, each person signs in once with `gcloud auth application-default login` and needs
read and write access to the bucket.

To try Artifactum on your own, a folder like `~/atfm-files` is enough.

### Moving your storage

`atfm storage move` copies files to a new location, checks each copy against its hash, and only then
points their records there. IDs and lineage don't change, and the old copies are left in place for you to
delete. If a move stops part way, nothing is repointed: fix the problem and run it again.

When you bring in your team, move what you've published to shared storage:

```bash
atfm storage move /groups/lab/atfm      # or gs://my-team-bucket/atfm
```

That moves only your own files. To move a whole team, a **team admin** moves everything the team has
published (from a machine that can reach both locations), which also makes it the team's storage, and then
each teammate points their own setup at it. Their files are already there, so nothing is copied twice:

```bash
atfm storage move gs://my-team-bucket/atfm --team   # the admin, once
atfm storage move gs://my-team-bucket/atfm          # then each teammate
```

## Use

```python
import artifactum as atfm
import pandas as pd

events = pd.read_parquet(atfm.artifact("C4LN9E2A"))  # fetched and cached locally
features = build_features(events)
features.to_parquet("features.parquet")

atfm.publish(
    "features.parquet",
    description="Feature matrix, nulls dropped",
    tags=["features"],
)
# C4LN9E2A is recorded as the parent automatically, along with the git commit and code.
```

Each publish prints what happened on stderr: `artifactum: Published features.parquet as F3TR8QX1`, or, when
identical content is already in the registry, that it was found and nothing was uploaded.

To track versions of something, give it a name. Artifacts published under the same name are versions of
each other, and anything built from an older version is flagged as stale. Without a name there are no
versions, even if two files share a file name.

```python
atfm.publish("model.pkl", name="churn-model")
```

From the shell (bash, R, Nextflow, Snakemake, ...):

```bash
eval "$(atfm run start 'align reads')"      # lineage is recorded across the commands below
bwa mem "$(atfm get GRCH38RF)" "$(atfm get FQ7R1A2B)" > aligned.sam
atfm publish aligned.bam -d "Reads aligned with BWA-MEM" --code align.sh
eval "$(atfm run end)"
```

`atfm get` prints a local path and `atfm publish` prints the new ID, so both compose with other
commands. Use `--parent ID` to set parents explicitly.

Add `--json` to `get`, `publish`, `describe`, `log` or `run status` to get one JSON object on stdout
instead, for tools that parse rather than split strings. Messages and errors stay on stderr, and a
failure exits non-zero.

```bash
$ atfm get C4LN9E2A --json
{"id": "C4LN9E2A", "path": "/home/me/.artifactum/cache/3f9a..."}
$ atfm publish model.rds -p C4LN9E2A --json
{"id": "M0DL3V3X", "file": "/home/me/project/model.rds", "parents": ["C4LN9E2A"], "run_id": null}
```

From R, call the command and read its JSON with `jsonlite`:

```r
atfm <- function(...) {
  out <- system2("atfm", c(..., "--json"), stdout = TRUE)
  if (!is.null(attr(out, "status"))) stop("atfm failed")
  jsonlite::fromJSON(paste(out, collapse = ""))
}

counts <- read.csv(atfm("get", "C4LN9E2A")$path)
saveRDS(fit, "model.rds")
atfm("publish", "model.rds", "-p", "C4LN9E2A", "-d", shQuote("GLM on cleaned counts"))$id
```

There's no R package yet. If you'd like one, email hello@atfm.io.

Browsing from the terminal:

```bash
atfm log K9PWQM7T      # upstream lineage
atfm browse            # interactive browser (preview: recent artifacts, no search yet)
```

## License

MIT. See [LICENSE](https://github.com/atfm-io/artifactum/blob/main/LICENSE).
