Skip to main content

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.

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:

  1. Capture the current state of your project
  2. Ensure reproducibility across multiple runs
  3. 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, you can activate it or execute commands within its environment:

# 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

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nshsnap-0.3.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

nshsnap-0.3.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file nshsnap-0.3.0.tar.gz.

File metadata

  • Download URL: nshsnap-0.3.0.tar.gz
  • Upload date:
  • Size: 10.7 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

Hashes for nshsnap-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0986d21f28d3f5cf197a6ae30bf737850ad5b9d74eaf13f88fe4627bea94bb40
MD5 e66a37882da80784020b78630550de0d
BLAKE2b-256 93020fb306450fcbdbe2d3d80f055b46c0abccf86aae65a68bfe33db561576a4

See more details on using hashes here.

File details

Details for the file nshsnap-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nshsnap-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 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

Hashes for nshsnap-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b639edad1dccaaca9b5e4ae160feaf5c7f4245e9566ca7c792a88de8a06969c
MD5 fbfa6291ed74cacc8b9d274e47910d49
BLAKE2b-256 a9eadc6f827f528b92473bb95afacb011f35d5d6550b85dab6942632f1ce8e65

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page