A hydra-based program running framework.
Project description
Hydra-Program
A hydra-based program running framework for building configurable and reproducible applications.
Overview
Hydra-Program provides a powerful framework for creating command-line applications with sophisticated configuration management. Built on top of Facebook's Hydra, it offers:
- Easy Configuration Management: Hierarchical configuration with composition support
- CLI Tools: Ready-to-use command-line utilities (
hprun,hpinit) - Template System: Quick project initialization with sensible defaults
- Flexible Architecture: Support for complex program structures and workflows
Quick Start
Installation
pip install hydra-program
Initialize a New Project
mkdir my-project && cd my-project
hpinit
This creates a config/ directory with template configurations.
Create Your Program
# my_program.py
class MyProgram:
def __init__(self, message: str = "Hello, World!", count: int = 1):
self.message = message
self.count = count
def run(self):
for i in range(self.count):
print(f"{i + 1}: {self.message}")
def create_program(message: str = "Hello, World!", count: int = 1):
return MyProgram(message, count)
Configure Your Program
Create config/program/my_program.yaml:
# @package _global_
_target_: my_program.create_program
message: "Hello from Hydra-Program!"
count: 3
Update config/hprun.yaml:
defaults:
- hydra: default
- path: default
- program: my_program
Run Your Program
# Run with default configuration
hprun
# Override configuration
hprun message="Custom message!" count=5
# Use different program configuration
hprun program=other_program
Documentation
Comprehensive documentation is available with:
- Getting Started Guide: Step-by-step tutorial
- Configuration Guide: Advanced configuration patterns
- Examples: Real-world use cases
- API Reference: Complete API documentation
Building Documentation
cd docs
pip install -r requirements.txt # or pip install -e ".[docs]"
sphinx-build -b html source build/html
Features
Configuration Management
- Composition: Build complex configurations from simple components
- Overrides: Command-line parameter overrides
- Environment Support: Different configurations for dev/staging/production
- Validation: Type-safe configuration with structured configs
- Interpolation: Variable substitution and environment variables
CLI Tools
hprun: Execute configured programs with Hydra integrationhpinit: Initialize project templates and configuration structure
Advanced Features
- Multirun Support: Parameter sweeps and hyperparameter optimization
- Plugin System: Extensible architecture for custom functionality
- Rich Logging: Beautiful console output with progress indicators
- Serialization: Automatic configuration persistence
Examples
Data Processing Pipeline
# data_processor.py
from dataclasses import dataclass
from typing import List, Optional
@dataclass
class ProcessingConfig:
input_file: str
output_file: str
columns: Optional[List[str]] = None
remove_duplicates: bool = True
class DataProcessor:
def __init__(self, config: ProcessingConfig):
self.config = config
def run(self):
# Your processing logic here
pass
# config/program/data_processing.yaml
_target_: data_processor.DataProcessor
config:
input_file: "${path.data_dir}/input.csv"
output_file: "${path.output_dir}/processed.csv"
columns: ["name", "value", "timestamp"]
Machine Learning Training
# Run with different models
hprun program=ml_training model=transformer
hprun program=ml_training model=lstm
# Hyperparameter sweep
hprun -m program=ml_training model.layers=6,8,12 optimizer.lr=0.001,0.01
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
git clone https://github.com/tanganke/hydra-program.git
cd hydra-program
pip install -e ".[dev]"
Running Tests
pytest
pytest --cov=hydra_program # With coverage
License
This project is licensed under the MIT License - see the LICENSE file for details.
Links
- Documentation: Available in docs/
- Repository: https://github.com/tanganke/hydra-program
- Issues: https://github.com/tanganke/hydra-program/issues
- PyPI: https://pypi.org/project/hydra-program/
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 hydra_program-0.1.1.tar.gz.
File metadata
- Download URL: hydra_program-0.1.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44fa95cff5e3ef5bbc7cb1d3ae4b2dc359fcc6d605ca9a474cd1ad9cc84498d9
|
|
| MD5 |
ada5938408855bf21156a5418171ea46
|
|
| BLAKE2b-256 |
38f675deb4c78ba2cce588bc04ff570b8c1cdd7b60d10777f7ee9eab9792d221
|
Provenance
The following attestation bundles were made for hydra_program-0.1.1.tar.gz:
Publisher:
publish.yml on tanganke/hydra-program
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hydra_program-0.1.1.tar.gz -
Subject digest:
44fa95cff5e3ef5bbc7cb1d3ae4b2dc359fcc6d605ca9a474cd1ad9cc84498d9 - Sigstore transparency entry: 456523990
- Sigstore integration time:
-
Permalink:
tanganke/hydra-program@1ff80413ef894077d47a948439dca86f40fb7347 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/tanganke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ff80413ef894077d47a948439dca86f40fb7347 -
Trigger Event:
release
-
Statement type:
File details
Details for the file hydra_program-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hydra_program-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1a49abb5f467ca9943f597be712cd87ab2a0c5fc9278c519fa1cf90a8507057
|
|
| MD5 |
79224335e2785a3762e457415a64f9b6
|
|
| BLAKE2b-256 |
330a14a1c7b06e72c5789832a75defa303717f3f1276a5e8afa1dbb5a46ed419
|
Provenance
The following attestation bundles were made for hydra_program-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on tanganke/hydra-program
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hydra_program-0.1.1-py3-none-any.whl -
Subject digest:
d1a49abb5f467ca9943f597be712cd87ab2a0c5fc9278c519fa1cf90a8507057 - Sigstore transparency entry: 456523995
- Sigstore integration time:
-
Permalink:
tanganke/hydra-program@1ff80413ef894077d47a948439dca86f40fb7347 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/tanganke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ff80413ef894077d47a948439dca86f40fb7347 -
Trigger Event:
release
-
Statement type: