No project description provided
Project description
nshsnap
nshsnap is a Python library for creating and managing snapshots of Python projects and environments. It's particularly useful for scenarios where you need to preserve the exact state of your code and dependencies, such as when running machine learning training jobs on cluster systems like SLURM.
Table of Contents
Motivation
When running long-running jobs or experiments, especially in distributed environments, it's critical to maintain consistency in your codebase. Small changes in your project files can lead to crashes or inconsistent results in ongoing runs. nshsnap addresses this issue by allowing you to take a full snapshot of your main development package, preserving the code state at that moment.
This tool was originally created to solve issues encountered when running ML training jobs on SLURM. It enables you to:
- Capture the current state of your project
- Ensure reproducibility across multiple runs
- Isolate changes in your development environment from active jobs
Installation
You can install nshsnap using pip:
pip install nshsnap
Usage
Programmatic Usage
Here's a basic example of how to use nshsnap in your Python code:
from nshsnap import snapshot
# Create a snapshot with default settings
snapshot_info = snapshot()
# Or, create a snapshot with custom configuration
snapshot_info = snapshot(
modules=["my_project", "my_other_module"],
editable_modules=True
)
print(f"Snapshot created at: {snapshot_info.snapshot_dir}")
print(f"Modules included: {', '.join(snapshot_info.modules)}")
Command Line Usage
nshsnap also provides a command-line interface:
# Snapshot all editable packages in the current environment
nshsnap --editables
# Snapshot specific modules
nshsnap --modules my_project my_other_module
# Specify a custom snapshot directory
nshsnap --editables --dir /path/to/snapshot/directory
# Get help
nshsnap --help
Activating and Using Snapshots
After creating a snapshot, all you need to do is prepend the snapshot directory to your PYTHONPATH
to activate the snapshot environment:
export PYTHONPATH=/path/to/snapshot:$PYTHONPATH
You can also activate or execute commands within the snapshot environment using our helper scripts:
# Activate the snapshot environment
source /path/to/snapshot/.bin/activate
# Execute a command within the snapshot environment
/path/to/snapshot/.bin/execute python my_script.py
Features
- Snapshot editable packages and specified modules
- Preserve exact state of code and dependencies
- Easy activation and execution within snapshot environments
- Integration with version control systems (respects .gitignore)
- Metadata storage for snapshot information
Requirements
- Python 3.10+
- git
- rsync
Contributing
Contributions to nshsnap are welcome! Please feel free to submit a Pull Request.
License
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
File details
Details for the file nshsnap-0.4.1.tar.gz
.
File metadata
- Download URL: nshsnap-0.4.1.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-39-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f70c7b25ae7346de7ee78417d646b0af311ffcb6caf4dddeda5022d95067cc7 |
|
MD5 | cd39b05b24b825c8d08c68b089da7cb8 |
|
BLAKE2b-256 | b93a723455f6784da1e0831f5bd6d1e18d53f2d58406ebef127976e2f3dcb4e3 |
File details
Details for the file nshsnap-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: nshsnap-0.4.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-39-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b7900cedfc8fbde08485ac3304bb836d70a8ac712758706663b7e4b0dbb317a |
|
MD5 | 43ce3051c6db7f72ffe803969ef9576a |
|
BLAKE2b-256 | c9f5b37c460545ff36a7613c7e5d2666ab00148323d7d10d03c0b37f3ddefec0 |