Skip to main content

phistory

phistory makes Python scripts remember how they were run, and provides a small YAML parameter loader for scripts that do not use argparse.

It supports Python 3.10+.


Quickstart

# myscript.py
import phistory  # must be first
import argparse

p = argparse.ArgumentParser()
p.add_argument("--foo")
p.add_argument("bar")
args = p.parse_args()
print(args)

Run

python myscript.py --foo 123 hello
python myscript.py --foo 999 world
python myscript.py --history
# outputs:
# myscript.py --foo 123 hello
# myscript.py --foo 999 world

What it does

  • Saves each execution’s CLI (script name + args) to ~/.python-history/<script>.history.
  • When run with --history, prints previous runs (copy/paste friendly) and exits.
  • Only writes history when your script calls argparse.parse_args or parse_known_args.
  • The --history flag itself is never recorded.

History directory: ~/.python-history/

Use --history date to include timestamps, --history unique to show only the first occurrence of each command, or both options together.

phistory intentionally monkey-patches argparse.ArgumentParser when it is imported. Import it before importing or configuring argparse in a script that should record history.


YAML args (no argparse required)

Skip argparse entirely and just load parameters from YAML.

from phistory import yaml_args

args = yaml_args.load()  # looks for "<script>.params.yaml" in the current directory
print(args.outpath)      # access fields as attributes

Behavior

  • Default file: <script_stem>.params.yaml (e.g. runner.params.yaml)
  • You can also provide the path explicitly or as a single argument:
    python runner.py configs/myexp.yaml
    
  • Validate required keys:
    args = yaml_args.load(required=["experiment-name", "outpath", "description"])
    

Helper functions

from phistory import derive_params_filename, load_yaml_params

Installation

pip install phistory

License

MIT. See LICENSE.

Metadata

Release files for phistory 0.2.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 phistory 0.2.0
File Size Uploaded
phistory-0.2.0.tar.gz 10.6 kB Details

Built distribution (wheel)

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

Total release size: 19.5 kB

Release files / phistory-0.2.0.tar.gz

Download URL phistory-0.2.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1b2fae93c43a3a8b84e11c8c1e2bdb6bcff1a773f5c089b45dcd3221954a9b22
BLAKE2b-256 checksum
How to use checksums
de0388000787c68a99774b67a1ba3702928d5edfecc54d68b7722240c33fb142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release files / phistory-0.2.0-py3-none-any.whl

Download URL phistory-0.2.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f44ae7c2d93b63f4694a5e644351d524cdb47fbd683a0af821bee00a55249e6a
BLAKE2b-256 checksum
How to use checksums
c0367410b48a6eea97c45a34e0d80c7fe404aeba642445a5e810c79a0230aa1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.2

2 release files

0.2.1

2 release files

This release

0.2.0 This release

2 release files

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