Lightweight timestamped session-directory manager for data-processing scripts
Project description
session-manager
Lightweight timestamped session-directory manager for data-processing scripts.
Each time your script runs it gets its own uniquely named folder — no overwritten results, no manual date-stamping. Works on Windows and Linux (pathlib.Path throughout).
Install
# from PyPI (after first release)
pip install session-manager
# directly from GitHub (always latest)
pip install git+https://github.com/lukaszplk/session-manager.git
Use cases
1. Save outputs from a data-processing script
Every run produces a fresh folder. Re-run as many times as you like — nothing gets overwritten.
from session_manager import SessionManager
sm = SessionManager("results", name="rna_seq")
# creates: results/rna_seq_2026-05-26_22-08-00/
df.to_csv(sm.file("counts.csv"))
fig.savefig(sm.file("volcano.png"))
plots = sm.subdir("plots") # creates subdir, returns Path
fig2.savefig(plots / "pca.png")
fig3.savefig(sm / "overview.png") # shorthand
Resulting folder:
results/
└── rna_seq_2026-05-26_22-08-00/
├── counts.csv
├── volcano.png
└── plots/
└── pca.png
2. Pipeline chaining — script B always picks up script A's latest output
No hardcoded paths, no manual coordination between scripts.
# script_a.py (preprocessing — run multiple times during development)
from session_manager import SessionManager
sm = SessionManager("results", name="preprocess")
df_clean.to_csv(sm.file("clean.csv"))
model_params = {"lr": 0.01, "epochs": 50}
json.dump(model_params, open(sm.file("params.json"), "w"))
# script_b.py (training — always reads A's latest output)
from session_manager import SessionManager
sm = SessionManager("results", name="preprocess", create=False)
latest = sm.latest()
logger.info("Reading from: %s", latest)
df = pd.read_csv(latest / "clean.csv")
params = json.load(open(latest / "params.json"))
3. Logger injection — all output in one place
Pass your application logger so the library's events (folder created, scan results, errors) flow through your handlers, formatters, and custom levels.
import logging
from session_manager import SessionManager
logger = logging.getLogger("my_pipeline")
sm = SessionManager("results", name="rna_seq", logger=logger)
# → logger.debug("Session created: results/rna_seq_2026-...")
# library logs and your script logs end up in the same file
logger.info("Processing %d samples", len(df))
4. Scratch / temp work
For intermediate results that don't need to persist, use the system temp directory — no path to decide, works the same on Windows and Linux.
from session_manager import SessionManager
sm = SessionManager.in_temp(name="scratch")
# → /tmp/scratch_2026-05-26_22-08-00/ (Linux/macOS)
# → %TEMP%\scratch_2026-05-26_22-08-00\ (Windows)
large_intermediate_df.to_parquet(sm.file("intermediate.parquet"))
5. Experiment tracking
Keep every hyperparameter sweep run isolated and comparable.
for lr in [0.001, 0.01, 0.1]:
sm = SessionManager("experiments", name=f"lr_{lr}")
model.fit(X_train, y_train, lr=lr)
metrics = evaluate(model, X_test, y_test)
json.dump(metrics, open(sm.file("metrics.json"), "w"))
model.save(sm.file("model.pt"))
Resulting folder:
experiments/
├── lr_0.001_2026-05-26_22-10-00/
│ ├── metrics.json
│ └── model.pt
├── lr_0.01_2026-05-26_22-10-05/
│ ├── metrics.json
│ └── model.pt
└── lr_0.1_2026-05-26_22-10-10/
├── metrics.json
└── model.pt
Options
All optional, all keyword-only:
sm = SessionManager(
"results",
name="run",
separator="--", # default "_"
timestamp_format="%Y%m%dT%H%M%S", # default "%Y-%m-%d_%H-%M-%S"
create=False, # default True
logger=logger, # default None (silent)
)
API
SessionManager(base_dir, name="session", *, separator, timestamp_format, create, logger)
| Argument | Default | Description |
|---|---|---|
base_dir |
required | Parent directory for sessions |
name |
"session" |
Folder name prefix |
separator |
"_" |
Between name and timestamp |
timestamp_format |
"%Y-%m-%d_%H-%M-%S" |
strftime format |
create |
True |
False = no folder created (use with latest()) |
logger |
None |
logging.Logger for internal events |
| Method / property | Returns | Description |
|---|---|---|
session_dir |
Path |
Session root (raises if create=False) |
file(*parts) |
Path |
Path inside session dir (not created) |
subdir(*parts) |
Path |
Subdirectory (created) |
sm / "name" |
Path |
Shorthand for session_dir / name |
latest(base_dir=None) |
Path |
Latest matching session folder |
SessionManager.in_temp(name, ...) |
SessionManager |
Constructor using system temp dir |
Development
git clone https://github.com/lukaszplk/session-manager.git
cd session-manager
pip install -e ".[dev]"
pytest
Work on a feature branch, open a PR against master — CI runs automatically on the PR.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file session_manager-1.0.0.tar.gz.
File metadata
- Download URL: session_manager-1.0.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4f5c4141b2303a70761bad4ad6dfec6b8938c034fdce2e02dc8a6922189006a
|
|
| MD5 |
d5235f682b82b88877edb01f9e344062
|
|
| BLAKE2b-256 |
fef7704528c0c5c894cf0bd104a1b5f354bf5bc38d3642ff3e297f47979b7939
|
Provenance
The following attestation bundles were made for session_manager-1.0.0.tar.gz:
Publisher:
release.yml on lukaszplk/session-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
session_manager-1.0.0.tar.gz -
Subject digest:
a4f5c4141b2303a70761bad4ad6dfec6b8938c034fdce2e02dc8a6922189006a - Sigstore transparency entry: 1635420465
- Sigstore integration time:
-
Permalink:
lukaszplk/session-manager@6cffb3d504b5de5706cca6d0549df135b5b52830 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/lukaszplk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6cffb3d504b5de5706cca6d0549df135b5b52830 -
Trigger Event:
push
-
Statement type:
File details
Details for the file session_manager-1.0.0-py3-none-any.whl.
File metadata
- Download URL: session_manager-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aa2b062a010bf3e02453e501445492202cf93772d24e09835a35e53724ab37c
|
|
| MD5 |
63d51b9cad928d127f50f301421ed961
|
|
| BLAKE2b-256 |
d36912e55c05d73bf64f5eeeb7e40ff0c77ed87351949e036a109768eb464dc9
|
Provenance
The following attestation bundles were made for session_manager-1.0.0-py3-none-any.whl:
Publisher:
release.yml on lukaszplk/session-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
session_manager-1.0.0-py3-none-any.whl -
Subject digest:
8aa2b062a010bf3e02453e501445492202cf93772d24e09835a35e53724ab37c - Sigstore transparency entry: 1635420466
- Sigstore integration time:
-
Permalink:
lukaszplk/session-manager@6cffb3d504b5de5706cca6d0549df135b5b52830 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/lukaszplk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6cffb3d504b5de5706cca6d0549df135b5b52830 -
Trigger Event:
push
-
Statement type: