Skip to main content

Shephex

PyPI Python versions License: GPL-3.0-or-later Docs Coverage

Shephex creates, runs and manages computational experiments in Python. Decorate a function, create experiments with the parameters you want, and Shephex gives every experiment a directory of its own and runs them locally or as Slurm array jobs, on the cluster you are logged in to or a remote one over ssh.

Documentation · Getting started · Examples · Changelog

Features

  • Every experiment gets its own directory with its parameters, status and result.
  • Runs experiments locally, or as Slurm array jobs on the cluster you are logged in to or a remote one over ssh.
  • Executes experiments in Singularity/Apptainer containers or virtual environments on the cluster.
  • hex report shows experiments in the terminal, with filters and the progress experiments report themselves, and follows them with --watch.
  • Safeguards for submissions, also by AI agents: dry runs, limits and confirmation of large submissions.
  • Skills for Claude Code: one for submitting safely and one that guides you through setting up remote execution.

Installation

pip install shephex

On a cluster, Shephex can also be installed as a standalone tool with uv tool install shephex, and experiments run in a container or environment of their own, see Installation.

Example

The example submits 30 experiments of a random walk, every combination of steps, bias and seed, to a Slurm cluster as a single array job.

import shephex


@shephex.hexperiment()
def random_walk(steps: int, bias: float, seed: int) -> float:
    import numpy as np  # Only needed where the experiments run.

    rng = np.random.default_rng(seed)
    moves = rng.choice([-1, 1], size=steps, p=[1 - bias, bias])
    return float(moves.sum())


if __name__ == '__main__':
    experiments = [
        random_walk(steps=steps, bias=bias, seed=seed)
        for steps in [100, 1_000, 10_000]
        for bias in [0.5, 0.6]
        for seed in range(5)
    ]

    executor = shephex.SlurmExecutor(partition='q48', ntasks=1, time='00:10:00')
    executor.execute(experiments)

hex report shows the status and parameters of the experiments, here filtered to some of them, and hex report --watch follows them while they run:

$ hex report experiments -f bias 0.6 float -f steps 10000 int
                        experiments
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┳━━━━━━┳━━━━━━┓
┃       Identifier       ┃  Status   ┃ steps ┃ bias ┃ seed ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━╇━━━━━━╇━━━━━━┩
│ DMRnu7L7G3HTsFfWKXxyPT │ Completed │ 10000 │ 0.6  │  0   │
│ V2JQcRFgS22A3R9UroFMHf │ Completed │ 10000 │ 0.6  │  1   │
│ DYEGgrCFMkwaTgQYDuS4Yz │ Completed │ 10000 │ 0.6  │  2   │
│ Cf5z7hR3pA3jyrmapDmqCa │ Completed │ 10000 │ 0.6  │  3   │
│ KKJ7o35KtrrrZ95ywL29kn │ Completed │ 10000 │ 0.6  │  4   │
└────────────────────────┴───────────┴───────┴──────┴──────┘
5 completed / 5 shown of 30

Learn more

  • Getting started: experiments, results, Slurm, containers, environments and remote clusters, one step at a time.
  • Examples: complete, tested scripts, e.g. parameter sweeps, external programs and remote clusters.
  • Using Shephex with AI agents: how Shephex keeps agents' submissions in check, and its skills for Claude Code.
  • API reference.

License

Shephex is licensed under the GNU General Public License v3.0 or later, see LICENSE.

Metadata

Release files for shephex 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shephex 0.6.0
File Size Uploaded Provenance Actions
shephex-0.6.0.tar.gz 121.4 kB Without provenance Details for shephex-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shephex 0.6.0
File Interpreter ABI Platform Actions
shephex-0.6.0-py3-none-any.whl Python 3 none any Details for shephex-0.6.0-py3-none-any.whl

Total release size: 231.2 kB

Release files / shephex-0.6.0.tar.gz

Download URL shephex-0.6.0.tar.gz
Size 121.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e22931eb15f71d0a33ebb6d50a6686ba17e19c595fef554ed7c70ed22fdba63f
BLAKE2b-256 checksum
How to use checksums
8c60429cdcb9e9069561b16607d73639e2b8f919f09d246564f3ba1f5a4ee04f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / shephex-0.6.0-py3-none-any.whl

Download URL shephex-0.6.0-py3-none-any.whl
Size 109.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5da388588483beec9b5bc245840f551b6d81a8a44a04a690bfdd3ce668a70f6
BLAKE2b-256 checksum
How to use checksums
4e934b480aa3b24c5f162a4d596f67bf95cabdac202de138217ead9e9b8831f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.11.18

Security for shephex 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page