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 follows experiments from the terminal, with filters and the progress experiments report themselves.
  • Safeguards for submissions, also by AI agents: dry runs, limits and confirmation of large submissions.

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 while they run, here filtered to some of them:

$ 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

License

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

Metadata

Release files for shephex 0.5.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.5.0
File Size Uploaded Provenance Actions
shephex-0.5.0.tar.gz 111.6 kB Without provenance Details for shephex-0.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 214.5 kB

Release files / shephex-0.5.0.tar.gz

Download URL shephex-0.5.0.tar.gz
Size 111.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ee8996fc7412cfaa30b75fdae55554ba979f64bebc33b6e9791150f2e1dc98b8
BLAKE2b-256 checksum
How to use checksums
6e4572f4819a5834b109832defbc0c414be8ca8caf9bebbf29248227a4e4a766
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.5.0-py3-none-any.whl

Download URL shephex-0.5.0-py3-none-any.whl
Size 102.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca80adb8264c17de4fb8656a8187769340092ea5a8445d7c758e9cf2eb288149
BLAKE2b-256 checksum
How to use checksums
375651ac7c1f0cc91ac82206d2f09006761ed7f79fc3507ed9877e9ae0a0bd13
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.5.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