Metadata-Version: 2.4
Name: jayrun
Version: 0.4.1
Summary: Artifact-centric execution for iterative graphs, shared resources, and placement-aware workloads
Author: Masoud Yavari
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/jayrun-project/jayrun
Project-URL: Documentation, https://jayrun.readthedocs.io/
Project-URL: Repository, https://github.com/jayrun-project/jayrun
Project-URL: Issues, https://github.com/jayrun-project/jayrun/issues
Keywords: artifacts,dag,execution,orchestration,resources,scheduling,workflow
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: packaging>=25
Provides-Extra: yaml
Requires-Dist: PyYAML>=6.0; extra == "yaml"
Provides-Extra: plotting
Dynamic: license-file

# Jayrun

**An artifact-centric Python framework for resource-aware, concurrent and iterative computation.**

Define each step with a synchronous or asynchronous Python method. Jayrun passes artifact values between steps and manages the lifetimes of intermediate results and shared resources.

[![PyPI version](https://img.shields.io/pypi/v/jayrun.svg)](https://pypi.org/project/jayrun/)
[![Read the Docs](https://readthedocs.org/projects/jayrun/badge/?version=latest)](https://jayrun.readthedocs.io/en/latest/)
[![Python 3.11 or later](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/)
[![CI](https://github.com/jayrun-project/jayrun/actions/workflows/ci.yml/badge.svg)](https://github.com/jayrun-project/jayrun/actions/workflows/ci.yml)
[![Apache 2.0 license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/jayrun-project/jayrun/blob/main/LICENSE)

[Quick start](#quick-start) · [Documentation](https://jayrun.readthedocs.io/en/latest/) · [Tutorials](#tutorials) · [API reference](https://jayrun.readthedocs.io/en/latest/reference/imports.html) · [0.4.1 release notes](https://github.com/jayrun-project/jayrun/blob/main/CHANGELOG.md#041---2026-11-29)

## What Jayrun does

- **Reuse expensive resources.** Share models, calibration data and clients across compatible runs, with managed acquisition and teardown.
- **Release intermediate data automatically.** Let Jayrun release consumed artifact values when execution no longer needs them. Retention policies and application references determine what stays alive.
- **Inspect and control execution.** Visualize graphs before running them, follow live work in the dashboard, and inspect captured results, timings and records afterward.

Declare a graph once, then submit it with different inputs and configuration. Graphs can include branches, conditional routes and iteration. They can also act as observers or controllers for other work—the dashboard itself is built as a graph.

See [the overview](https://jayrun.readthedocs.io/en/latest/start/overview.html) for applications and [data and lifetimes](https://jayrun.readthedocs.io/en/latest/start/data-and-lifetimes.html) for how artifacts, configuration and resources fit together.

## Quick start

Install Jayrun with Python 3.11 or later.

```bash
python -m pip install jayrun
```

Save the following as `first_graph.py`. The `Scale` operator multiplies an input artifact by a configurable factor.

```python
from jayrun import (
    Artifact, ArtifactContext,
    ArtifactField, ArtifactFlow,
    BaseOperator, ConfigContext,
    ConfigField, Engine, GraphDefinition,
)
from jayrun.context import ContextState


class Scale(BaseOperator):
    def __init__(self, *, source, outputs):
        super().__init__()
        self.source = ArtifactField()
        self.factor = ConfigField(value_type=int)
        self.outputs = (ArtifactField(),)

    def execute(self):
        value = self.source.value
        result = value * self.factor.value
        self.context.record("scaled", result)
        return result


source = Artifact(name="source")
result = Artifact(name="result")
scale = Scale(
    source=source, outputs=(result,)
)
flow = ArtifactFlow(
    scale, artifact=source
)
graph = GraphDefinition(
    flow, entry_flows=flow
)
graph.confirm()

with Engine() as engine:
    run = engine.submit(
        graph,
        ArtifactContext({source: 7}),
        ConfigContext({scale.factor: 3}),
    )
    run.wait(timeout=10)
    if run.state is not ContextState.FINISHED:
        failure = run.report.data.failure
        raise RuntimeError(str(failure))
    print(run.artifact(result).value)
```

Run the program. With input `7` and factor `3`, it prints `21`.

```console
$ python first_graph.py
21
```

Each submission returns a `ContextRun`. Once it finalizes, check its outcome before reading the result. The [first graph walkthrough](https://jayrun.readthedocs.io/en/latest/start/first-graph.html) explains field binding, reads the recorded value and visualizes the run.

To reuse the same inputs, create a `Submission(graph, artifacts=inputs, configs=overrides)` before opening the Engine. Call `submission.inspect()` to see which configuration values came from defaults, then pass `**submission.arguments()` to each `engine.submit()` call. Each call gets fresh builders and shares the underlying artifact payloads. [Submission reference](https://jayrun.readthedocs.io/en/latest/reference/engine.html#jayrun.Submission)

The core runtime requires `packaging`. Install `jayrun[yaml]` for YAML configuration. Individual applications can add libraries such as PyTorch.

## Inspect your graphs and runs

The quick start sends `source` through `Scale` to produce `result`. To save the completed run as interactive HTML, add `run.plot.save("run.html")` after the example’s `print` line. Open the file to inspect the executed step, timing and recorded values.

[![Completed graph showing the source artifact flowing through Scale to the result artifact](https://raw.githubusercontent.com/jayrun-project/jayrun/main/docs/_static/screenshots/first-run.png)](https://jayrun.readthedocs.io/en/latest/_static/first_run.html)

[Explore the completed Scale run](https://jayrun.readthedocs.io/en/latest/_static/first_run.html).

To inspect a declaration before running it, use `graph.plot.save("graph.html")`. [Explore the interactive split-and-join example](https://jayrun.readthedocs.io/en/latest/guides/visualization/graphs.html).

To follow running contexts and recent completions, submit the dashboard graph from `jayrun.dashboard` with `Controller()` authority.

[![Jayrun dashboard listing running and paused contexts with graph versions, progress and iteration counts](https://raw.githubusercontent.com/jayrun-project/jayrun/main/docs/_static/screenshots/dashboard.png)](https://jayrun.readthedocs.io/en/latest/guides/visualization/dashboard.html)

[Explore the dashboard](https://jayrun.readthedocs.io/en/latest/guides/visualization/dashboard.html) or [build a monitoring graph with a Controller](https://jayrun.readthedocs.io/en/latest/guides/runtime/controller.html). The [visualization and reporting guide](https://jayrun.readthedocs.io/en/latest/guides/evidence/plots.html) also covers declarations, registries and completed runs.

For indefinite runs, `ContextSettings(max_iterations=None, execution_history_limit=8)` keeps detailed step reports for the latest eight reported iterations. Counts and timings cover the whole run. Use the context's optional `RecordPolicy` to tune values written through `self.context.record()`. [Capacity and retention](https://jayrun.readthedocs.io/en/latest/guides/runs/capacity.html).

To keep diagnostic history beyond an Engine session, pass `Database("execution.sqlite")` from `jayrun.persistence` to `Engine(database=...)`. The Engine owns the database lifecycle. After computation finishes, call `engine.database.flush()` to check that pending history was stored successfully. The [Persistence and Database guide](https://jayrun.readthedocs.io/en/latest/guides/evidence/persistence.html) shows how to write history and read it after the Engine closes. Stored history is separate from application checkpoints and arbitrary artifact storage.

## Framework comparison

“App” means application-managed. “via” identifies an integration. Hosted services are labeled explicitly. [Reviewed versions, sources and qualifications](https://github.com/jayrun-project/jayrun/blob/main/docs/framework-comparison.md)

### Computational architecture

| Framework | Authoring model | Execution model | Composition | Iteration / dynamic work | Data lifetime | Live resources | Validation / preparation |
| --- | --- | --- | --- | --- | --- | --- | --- |
| **Jayrun** | Artifact-centric&nbsp;graphs | In-process threads&nbsp;and&nbsp;async&nbsp;tasks | Flow&nbsp;attachment, splits&nbsp;and&nbsp;joins | Step repeats, graph iteration, feedback, Controller&nbsp;submissions | Consumed&nbsp;slots&nbsp;released, operators can republish values | Reuse by type, effective&nbsp;config and parallel-safety mode | Graph validation, declared&nbsp;artifact&nbsp;contracts, reusable `Submission` |
| [Apache Airflow](https://github.com/apache/airflow) | DAGs / operators | Task processes or pods | Task groups, TaskFlow calls | Task mapping, bounded group loops | XComs until retry or cleanup | External resource setup and teardown | DAG structure and cycle checks |
| [Dagster](https://github.com/dagster-io/dagster) | Assets / ops | Single or multiple processes | Asset dependencies, op graphs | Dynamic map and collect | Retention by I/O manager | Per-process setup and teardown | Definitions and run-config checks |
| [Dask&nbsp;Distributed](https://github.com/dask/distributed) | Task graphs / futures | Worker processes and thread pools | Collections, task keys and futures | Dynamic submission, task mapping | While clients or dependents need keys | Worker plugin lifecycle, actors | Optional graph-layer dependency checks |
| [Joblib](https://github.com/joblib/joblib) | Delayed calls | Process or thread pools | Caller chains parallel calls | Caller generates calls | Caller-held results | Application-managed | No workflow graph to validate |
| [Kedro](https://github.com/kedro-org/kedro) | Nodes / named datasets | Sequential, threads or processes | Namespaced pipelines | App loops inside nodes | Release eligible values after last use | Application-managed via hooks | Cycle and duplicate-output checks |
| [Luigi](https://github.com/spotify/luigi) | Tasks / targets | Inline or child processes | Required tasks, wrapper tasks | Yield required tasks | Target-defined retention | Application-managed | Dependency checks during traversal |
| [Metaflow](https://github.com/Netflix/metaflow) | Step-based flows | Step task processes | Branches and joins | Foreach, single-step recursion | Task artifacts outlive runs | Application-managed per task | Pre-run flow graph linting |
| [Parsl](https://github.com/Parsl/parsl) | Python / shell apps | Thread pool or worker processes | App and file futures | Dynamic submissions, join apps | Future-held results, app-managed files | Application-managed on workers | Executor configuration checks |
| [pipefunc](https://github.com/pipefunc/pipefunc) | Named function pipelines | Direct calls or map executors | Nested functions, joined pipelines | Map or reduce array axes | Caller-held or retained for resume | Application-managed | Map axes, defaults, optional type checks |
| [Prefect](https://github.com/PrefectHQ/prefect) | Flows / tasks | Thread or process task runners | Nested flows, task futures | Python control flow, task mapping | Run-scoped or persisted results | Application-managed | Flow parameter validation |
| [Ray Core](https://github.com/ray-project/ray) | Remote tasks / actors | Task and actor processes | Object references, actor handles | Nested task submission | Distributed reference counting | Managed actor lifetimes | Compiled actor graphs (beta) |

### Operational capabilities

| Framework | Capacity / GPU scheduling | Remote execution | Cluster management | Live dashboard | Run controls | Persistence / recovery | Schedules / triggers |
| --- | --- | --- | --- | --- | --- | --- | --- |
| **Jayrun** | Thread and task limits, declared&nbsp;device&nbsp;leases | Context&nbsp;ownership&nbsp;transfer via app transport | App-provisioned&nbsp;engines | Optional dashboard&nbsp;graph, launched by app | Pause,&nbsp;resume,&nbsp;stop,&nbsp;abort | Optional SQLite history, iteration-boundary&nbsp;snapshots | App-defined&nbsp;triggers in Controller or host code |
| [Apache Airflow](https://github.com/apache/airflow) | Pool slots, pod GPU requests | via Celery / Kubernetes providers | External workers or Kubernetes cluster | Airflow web UI | Fail an active DAG run | Task history, task retries | Timetables, asset events |
| [Dagster](https://github.com/dagster-io/dagster) | Run limits, concurrency pools | via Kubernetes / Celery | External or hosted Dagster+ Serverless | Dagster webserver | Terminate active runs | Run history, reload prior outputs | Schedules, sensors, asset automation |
| [Dask&nbsp;Distributed](https://github.com/dask/distributed) | Named worker resources (e.g. GPU) | Tasks and actors on remote workers | Cluster managers, adaptive scaling | Scheduler dashboard (Bokeh) | Cancel futures, restart workers | Recompute from surviving inputs | App or external scheduler |
| [Joblib](https://github.com/joblib/joblib) | Worker count, resources via Dask | via Dask backend | via Dask cluster manager | via Dask dashboard | Close result generator (backend abort) | Optional function-result cache | App or external scheduler |
| [Kedro](https://github.com/kedro-org/kedro) | Runner limits, app-selected GPU | via Airflow deployment | Deployment provisions workers | Not bundled | Deployment-managed | Rerun from persisted datasets | via Airflow schedules |
| [Luigi](https://github.com/spotify/luigi) | Worker slots, named resources | Networked workers, Spark integration | Externally provisioned workers | Central scheduler visualizer | App-handled task messages | Recheck completed output targets | External scheduler |
| [Metaflow](https://github.com/Netflix/metaflow) | Backend CPU / GPU requests | via AWS Batch / Kubernetes | External compute backend | Separately deployed Metaflow UI | Terminate via Argo or Batch | Resume using completed task artifacts | Backend schedules, Argo events |
| [Parsl](https://github.com/Parsl/parsl) | Worker slots, accelerator pinning | Executor workers on remote nodes | Provider block allocation and scaling | Optional parsl-visualize | No per-app cancellation | Checkpoints for memoized app results | App or external scheduler |
| [pipefunc](https://github.com/pipefunc/pipefunc) | Per-function executor resource requests | via Slurm executor | External batch scheduler | Not bundled | Cancel async map | Resume saved map elements | App or external scheduler |
| [Prefect](https://github.com/PrefectHQ/prefect) | Runner limits, concurrency slots | Work-pool deployments, task workers | External or hosted Prefect Managed | Prefect server UI | Cooperative pause, resume, cancel | Run history, persisted result reuse | Schedules, event automations |
| [Ray Core](https://github.com/ray-project/ray) | Logical CPUs / fractional GPUs | Cluster tasks and actors | Cluster launcher and autoscaler | Optional Ray Dashboard | Cancel tasks, kill actors | Rebuild eligible outputs, restart actors | via KubeRay RayCronJob |

## GPU training benchmark

The study trains two MNIST models on one GPU, sequentially and concurrently, with native Python/PyTorch as the baseline for the 12 frameworks. It includes the implementations, numerical checks, timing and memory measurements, and individual GPU traces. [Benchmark and reproduction instructions](https://github.com/jayrun-project/jayrun/blob/main/comparison/README.md)

## Tutorials

Each tutorial includes a walkthrough, Python source and a notebook. All seven have a small offline CPU example.

- [Build and validate](https://jayrun.readthedocs.io/en/latest/tutorials/build-and-validate-graph.html) — properties, diagnostics and corrected execution.
  [Python](https://github.com/jayrun-project/jayrun/blob/main/tutorials/build_graph.py) · [Notebook](https://github.com/jayrun-project/jayrun/blob/main/tutorials/01_build_graph.ipynb)
- [Image service](https://jayrun.readthedocs.io/en/latest/tutorials/denoise-images-with-fastapi.html) — async service, shared client and routing.
  [Python](https://github.com/jayrun-project/jayrun/blob/main/tutorials/denoise_images.py) · [Notebook](https://github.com/jayrun-project/jayrun/blob/main/tutorials/02_denoise_images.ipynb)
- [Shared model inference](https://jayrun.readthedocs.io/en/latest/tutorials/mnist-inference-and-training.html#share-a-read-only-model-for-inference) — read-only model reuse and placement.
  [Python](https://github.com/jayrun-project/jayrun/blob/main/tutorials/mnist_inference.py) · [Notebook](https://github.com/jayrun-project/jayrun/blob/main/tutorials/03_mnist_inference.ipynb)
- [Supervised training](https://jayrun.readthedocs.io/en/latest/tutorials/mnist-inference-and-training.html#supervise-replace-and-promote) — iteration, mutable state and scoped supervision.
  [Python](https://github.com/jayrun-project/jayrun/blob/main/tutorials/mnist_training.py) · [Notebook](https://github.com/jayrun-project/jayrun/blob/main/tutorials/04_mnist_training.ipynb)
- [Document service](https://jayrun.readthedocs.io/en/latest/tutorials/document-ingestion.html) — long-running jobs and transactional publication.
  [Python](https://github.com/jayrun-project/jayrun/blob/main/tutorials/document_ingestion.py) · [Notebook](https://github.com/jayrun-project/jayrun/blob/main/tutorials/05_document_ingestion.ipynb)
- [Adapter checkpointing](https://jayrun.readthedocs.io/en/latest/tutorials/checkpointed-adapter-finetuning.html) — model/optimizer/RNG checkpoints.
  [Python](https://github.com/jayrun-project/jayrun/blob/main/tutorials/adapter_finetuning.py) · [Notebook](https://github.com/jayrun-project/jayrun/blob/main/tutorials/06_adapter_finetuning.ipynb)
- [Scientific campaign](https://jayrun.readthedocs.io/en/latest/tutorials/adaptive-scientific-calibration.html) — adaptive control and reproducibility.
  [Python](https://github.com/jayrun-project/jayrun/blob/main/tutorials/heat_calibration.py) · [Notebook](https://github.com/jayrun-project/jayrun/blob/main/tutorials/07_heat_calibration.ipynb)

The tutorial sources and notebooks live in the [GitHub tutorials directory](https://github.com/jayrun-project/jayrun/tree/main/tutorials); they are not included in `pip install jayrun`. Start with the [tutorial setup guide](https://jayrun.readthedocs.io/en/latest/tutorials/index.html) to get the repository, install lesson dependencies and choose a CPU or optional GPU/model workload. For a specific task, follow the guides on [graph construction](https://jayrun.readthedocs.io/en/latest/guides/workflow/index.html), [resources](https://jayrun.readthedocs.io/en/latest/guides/graphs/resources.html), [component interfaces](https://jayrun.readthedocs.io/en/latest/guides/components/index.html) or [application integration](https://jayrun.readthedocs.io/en/latest/guides/integration/index.html).

## Community

Have a question or a workflow to share? Join [GitHub Discussions](https://github.com/jayrun-project/jayrun/discussions). Report bugs and request features through [GitHub Issues](https://github.com/jayrun-project/jayrun/issues); for bugs, include a small reproducible example and your Python and Jayrun versions.

You can also help by reporting confusing examples, suggesting documentation improvements or sharing how you use Jayrun. The [documentation sources](https://github.com/jayrun-project/jayrun/blob/main/docs/index.md) are included in this repository.

## Scope and project status

Jayrun manages graph execution and ownership. Applications supply network transport, authentication, external side effects and checkpoint contents. Placement accounts for declared capacity rather than allocating devices, and cleanup releases framework references rather than guaranteeing an immediate drop in process memory. See [supported behavior and limitations](https://jayrun.readthedocs.io/en/latest/reference/limits.html).

Jayrun provides a tested foundation for graph execution, with ongoing improvements to reliability, usability and documentation. Use imports from `jayrun` and its [documented public modules](https://jayrun.readthedocs.io/en/latest/reference/imports.html); `jayrun.core` and `jayrun.engine` are implementation details.

## License

[Apache License 2.0](https://github.com/jayrun-project/jayrun/blob/main/LICENSE). Copyright 2026 Masoud Yavari.
