Metadata-Version: 2.5
Name: ginkgo-workflow
Version: 0.4.0
Summary: A dynamic, reproducible workflow orchestrator for scientific and data workflows
Project-URL: Homepage, https://sanjaynagi.github.io/ginkgo/
Project-URL: Documentation, https://sanjaynagi.github.io/ginkgo/docs/
Project-URL: Repository, https://github.com/sanjaynagi/ginkgo
Project-URL: Issues, https://github.com/sanjaynagi/ginkgo/issues
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: blake3>=1.0.0
Requires-Dist: numpy>=2.0
Requires-Dist: ortools>=9.11
Requires-Dist: pandas>=2.0
Requires-Dist: pyarrow<24,>=23.0.1
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.9
Provides-Extra: all
Requires-Dist: ginkgo-aws==0.4.0; extra == 'all'
Requires-Dist: ginkgo-gcp==0.4.0; extra == 'all'
Requires-Dist: ginkgo-k8s==0.4.0; extra == 'all'
Requires-Dist: ginkgo-notebook==0.4.0; extra == 'all'
Requires-Dist: ginkgo-oci==0.4.0; extra == 'all'
Requires-Dist: ginkgo-pixi==0.4.0; extra == 'all'
Requires-Dist: ginkgo-report==0.4.0; extra == 'all'
Requires-Dist: ginkgo-slack==0.4.0; extra == 'all'
Provides-Extra: aws
Requires-Dist: ginkgo-aws==0.4.0; extra == 'aws'
Provides-Extra: gcp
Requires-Dist: ginkgo-gcp==0.4.0; extra == 'gcp'
Provides-Extra: k8s
Requires-Dist: ginkgo-k8s==0.4.0; extra == 'k8s'
Provides-Extra: notebook
Requires-Dist: ginkgo-notebook==0.4.0; extra == 'notebook'
Provides-Extra: oci
Requires-Dist: ginkgo-oci==0.4.0; extra == 'oci'
Provides-Extra: pixi
Requires-Dist: ginkgo-pixi==0.4.0; extra == 'pixi'
Provides-Extra: report
Requires-Dist: ginkgo-report==0.4.0; extra == 'report'
Provides-Extra: slack
Requires-Dist: ginkgo-slack==0.4.0; extra == 'slack'
Description-Content-Type: text/markdown

<p align="center"><img src="https://raw.githubusercontent.com/sanjaynagi/ginkgo/main/docs/ginkgo-logo.png" alt="Ginkgo" width="360"></p>

<p align="center"><a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License"></a> <a href="pyproject.toml"><img src="https://img.shields.io/badge/python-3.11%2B-blue.svg" alt="Python"></a> <a href="https://github.com/sanjaynagi/ginkgo/actions/workflows/tests.yml"><img src="https://github.com/sanjaynagi/ginkgo/actions/workflows/tests.yml/badge.svg?branch=main&event=push" alt="Tests"></a> <a href="https://github.com/sanjaynagi/ginkgo/actions/workflows/quality.yml"><img src="https://github.com/sanjaynagi/ginkgo/actions/workflows/quality.yml/badge.svg?branch=main&event=push" alt="Quality"></a> <a href="https://sanjaynagi.github.io/ginkgo/"><img src="https://img.shields.io/badge/docs-sanjaynagi.github.io%2Fginkgo-0e7c7e.svg" alt="Documentation"></a></p>

Ginkgo is a scientific workflow orchestrator built for the 21st century.

- `@flow` and `@task()` — define workflows in plain Python, no DSL to learn
- An intuitive, aesthetic API built specifically for data science and bioinformatics
- natively dynamic workflows — expand workflows during runtime from resolved tasks
- content-addressed caching — never recompute what hasn't changed
- isolated environments — pixi or containers, per task
- agent-friendly — built from the ground up for workflows to be built and operated by AI agents
- cloud-native I/O — stream inputs directly from S3, GCS, or Azure and stage outputs back, without local copies
- deep observability — provenance and CLI tooling

## See it in action

A bacterial GWAS, from 60 assemblies to resistance-associated unitigs: dynamic
task graphs, pixi environments, caching, provenance, measured resource usage, and
resuming after a failure. The workflow is in
[`examples/bacterial_gwas`](https://github.com/sanjaynagi/ginkgo/tree/main/examples/bacterial_gwas).

<p align="center"><a href="https://sanjaynagi.github.io/ginkgo/#watch"><img src="https://raw.githubusercontent.com/sanjaynagi/ginkgo/main/docs/site/public/_static/walkthrough-poster.jpg" alt="Watch the walkthrough: a bacterial GWAS run with Ginkgo"></a></p>

## Documentation

📖 **[sanjaynagi.github.io/ginkgo](https://sanjaynagi.github.io/ginkgo/)**

It covers installation, quickstart, core concepts, environments, notebook tasks,
caching, CLI usage, and a canonical example workflow.

## Installation

### Quick install (curl)

Install the `ginkgo` CLI in one line. Requires [uv](https://docs.astral.sh/uv/getting-started/installation/)
to be installed:

```bash
curl -LsSf https://raw.githubusercontent.com/sanjaynagi/ginkgo/main/install.sh | sh
```

This installs the `ginkgo-workflow` package from PyPI into an isolated
environment via `uv tool install`. Re-run the same command to upgrade. The
package is `ginkgo-workflow`; the command and the import are both `ginkgo`:

```bash
pip install ginkgo-workflow
```

### Plugins

The installer gives you core plus `ginkgo-pixi`, which runs tasks' bare
`env="name"` Pixi environments. Other optional integrations ship as separate
plugins in this repository, each one an extra of `ginkgo-workflow`:

- `ginkgo-aws`: the `s3://` object store and the mountpoint-s3 FUSE driver
- `ginkgo-gcp`: the `gs://` object store, the gcsfuse FUSE driver and the GCP
  Batch executor
- `ginkgo-oci`: the `oci://` object store and the rclone FUSE driver
- `ginkgo-pixi`: Pixi environments for tasks' `env="name"`, and `ginkgo env`
- `ginkgo-k8s`: the Kubernetes executor
- `ginkgo-notebook`: `@task("notebook")`, which runs marimo notebooks
- `ginkgo-report`: the `ginkgo report` command, for HTML run reports
- `ginkgo-slack`: Slack run notifications

To install ginkgo with every first-party plugin:

```bash
uv tool install --force "ginkgo-workflow[all]"
```

Or name only the plugins you want:

```bash
uv tool install --force "ginkgo-workflow[pixi,k8s]"
```

`ginkgo plugins` lists what is installed. A `remote_file()` or
`remote_folder()` URI needs the plugin for its scheme; without it, ginkgo names
the plugin to install.

### Pixi

For local development:

```bash
pixi install
pixi run test
pixi run typecheck
```

The default environment installs every first-party plugin editable, and
`pixi run test` runs core's tests and the plugins' (`tests/` and `plugins/`).
To check that core works with no plugin installed, as CI does:

```bash
pixi run -e core test-core
```

After `pixi install`, build the [uncoded](https://github.com/alimanfoo/uncoded)
symbol index used by AI coding tools (regenerated automatically by the
pre-commit hook, but useful to seed up front):

```bash
pixi run uncoded sync
```

If your workflows use Pixi-backed task environments, `pixi` must also be
available on `PATH` when you run them.

Run the CLI with either:

```bash
pixi run python -m ginkgo.cli --help
```

or:

```bash
ginkgo --help
```

### Editable install

If you prefer a plain Python environment:

```bash
pip install -e .
```

## Minimal Example

A population-genetics workflow that filters a VCF, computes per-population
allele frequencies, and renders a summary marimo notebook (the notebook task
needs the `ginkgo-notebook` plugin).

```python
from pathlib import Path

import numpy as np

from ginkgo import file, flow, shell, task
from ginkgo_notebook import notebook

POPULATIONS = ["YRI", "CEU", "CHB"]
NOTEBOOKS_DIR = Path(__file__).resolve().parent / "notebooks"


# shell task — runs bcftools in a subprocess
@task("shell", env="genomics_tools")
def filter_snps(vcf_path: file, min_maf: float) -> file:
    """Filter to biallelic SNPs above a minor-allele-frequency threshold."""
    output = "results/filtered.vcf.gz"
    return shell(
        cmd=(
            f"bcftools view -m2 -M2 -v snps -i 'MAF>={min_maf}' "
            f"{vcf_path} -Oz -o {output} && bcftools index {output}"
        ),
        output=output,
    )


# python task — uses scikit-allel, fanned out per population via .map()
@task()
def allele_frequencies(vcf_path: file, population: str) -> file:
    """Compute per-SNP alt-allele frequencies for one population."""
    import allel

    callset = allel.read_vcf(str(vcf_path), fields=["calldata/GT"])
    ac = allel.GenotypeArray(callset["calldata/GT"]).count_alleles()
    freqs = ac.to_frequencies()[:, 1]  # alt allele frequency

    output = f"results/af_{population}.npy"
    np.save(output, freqs)
    return file(output)


# notebook task — runs a marimo notebook and renders it to HTML
@task("notebook")
def population_structure(af_files: list[file], populations: list[str]) -> file:
    """Render an HTML population-genetics summary notebook."""
    return notebook(NOTEBOOKS_DIR / "population_structure.py")


# flow
@flow
def main():
    filtered = filter_snps(vcf_path="data/chr22.vcf.gz", min_maf=0.05)
    af_results = allele_frequencies(vcf_path=filtered).map(population=POPULATIONS)
    return population_structure(af_files=af_results, populations=POPULATIONS)
```

Run it with:

```bash
ginkgo run flow.py
```

All three tasks above share one file, and a task's cache identity covers the
whole module it is defined in — so editing any one of them invalidates the
cached results of all three. That is what makes an edit to module-level state
such as `POPULATIONS` invalidate the tasks that read it. Once a step is
expensive enough that you mind re-running it, give it its own module; see the
[caching guide](https://sanjaynagi.github.io/ginkgo/guide/caching-and-provenance/).

## Canonical Example

The docs and examples are centered on
[`examples/bioinfo`](https://github.com/sanjaynagi/ginkgo/tree/main/examples/bioinfo), which demonstrates:

- Pixi-backed shell tasks
- a container-backed shell task
- `.map()` fan-out across samples
- a local Python aggregation task that returns a DataFrame

Run it with:

```bash
cd examples/bioinfo
ginkgo run
```

## Core CLI Commands

To confirm a workflow is wired correctly, run `ginkgo run --dry-run`: it previews
the plan for the entrypoint you actually run without executing any task body.
Validation workflows a project keeps under `tests/workflows/` are workflows too,
so they run by path: `ginkgo run tests/workflows/smoke.py`. See the
[CLI guide](https://sanjaynagi.github.io/ginkgo/guide/cli/).

- `ginkgo run`
- `ginkgo doctor`
- `ginkgo debug`
- `ginkgo init`
- `ginkgo inspect workflow`
- `ginkgo runs` (`runs ls`, `runs show`)
- `ginkgo history`
- `ginkgo query`
- `ginkgo export` (`export events`, `export manifest`)
- `ginkgo report` (from the `ginkgo-report` plugin)
- `ginkgo why`
- `ginkgo secrets` (`secrets list`, `secrets validate`)
- `ginkgo cache ls`
- `ginkgo cache clear`
- `ginkgo cache prune`
- `ginkgo cache explain`
- `ginkgo env ls` (from the `ginkgo-pixi` plugin)
- `ginkgo db` (`db path`, `db check`, `db prune`, `db vacuum`)

For full details on every command, see the [CLI reference](https://sanjaynagi.github.io/ginkgo/guide/cli/).

## Repository Layout

```text
ginkgo/
├── core/
├── runtime/
├── envs/
└── cli/
```

- `core/` contains the user-facing DSL
- `runtime/` contains evaluation, scheduling, caching, provenance, and value transport
- `envs/` contains execution backends
- `cli/` contains the `ginkgo` command-line interface

---

Ginkgo is licensed under the Apache License, Version 2.0. See
[`LICENSE`](LICENSE).
