Skip to main content

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:

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 integration
  • hpinit: 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

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

hydra_program-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hydra_program-0.1.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

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

Hashes for hydra_program-0.1.1.tar.gz
Algorithm Hash digest
SHA256 44fa95cff5e3ef5bbc7cb1d3ae4b2dc359fcc6d605ca9a474cd1ad9cc84498d9
MD5 ada5938408855bf21156a5418171ea46
BLAKE2b-256 38f675deb4c78ba2cce588bc04ff570b8c1cdd7b60d10777f7ee9eab9792d221

See more details on using hashes here.

Provenance

The following attestation bundles were made for hydra_program-0.1.1.tar.gz:

Publisher: publish.yml on tanganke/hydra-program

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for hydra_program-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1a49abb5f467ca9943f597be712cd87ab2a0c5fc9278c519fa1cf90a8507057
MD5 79224335e2785a3762e457415a64f9b6
BLAKE2b-256 330a14a1c7b06e72c5789832a75defa303717f3f1276a5e8afa1dbb5a46ed419

See more details on using hashes here.

Provenance

The following attestation bundles were made for hydra_program-0.1.1-py3-none-any.whl:

Publisher: publish.yml on tanganke/hydra-program

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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