Skip to main content

A flexible configuration system for Python projects

Project description

Hypster Logo

chat with our AI docs

CI codecov PyPI version Python versions DeepWiki License: MIT CodSpeed

Hypster is a lightweight configuration framework for managing and optimizing AI & ML workflows

Key Features

  • 🐍 Pythonic API: Intuitive & minimal syntax that feels natural to Python developers
  • 🪆 Hierarchical, Conditional Configurations: Support for nested and swappable configurations
  • 📐 Type Safety: Built-in type hints and validation
  • 🧪 Hyperparameter Optimization Built-In: Native, first-class optuna support
  • 🧩 Rules As Config: Define replayable WHEN/THEN rule lists with built-in notebook controls

Installation

uv add hypster
# optional notebook visualization UI
uv add 'hypster[viz]'
# optional HPO backend
uv add 'hypster[optuna]'

See the installation guide for pip, optional extras, and development setup.

Quick Start

Define a configuration function and instantiate it with overrides:

from hypster import HP, explore, instantiate
from my_app.llms import LLMClient


def llm_config(hp: HP) -> LLMClient:
    model_name = hp.select(["gpt-5.5", "gpt-5.5-mini"], name="model_name")
    temperature = hp.float(0.7, name="temperature", min=0.0, max=1.0)
    max_tokens = hp.int(256, name="max_tokens", min=1, max=4096)

    return LLMClient(
        model_name=model_name,
        temperature=temperature,
        max_tokens=max_tokens,
    )

explore(llm_config)
# llm_config
# ├── model_name: select = "gpt-5.5"  (options: ["gpt-5.5", "gpt-5.5-mini"])
# ├── temperature: float = 0.7  (0.0-1.0)
# └── max_tokens: int = 256  (1-4096)

llm = instantiate(
    llm_config,
    values={"model_name": "gpt-5.5", "temperature": 0.2},
)

response = llm.invoke("How's your day going?")

Use explore(..., values=...) to inspect a specific conditional branch before you instantiate it, or explore(..., return_schema=True) to get a JSON-serializable schema object.

AI-readable docs

GitBook publishes an agent-friendly docs index at llms.txt and a full Markdown export at llms-full.txt.

HPO with Optuna

import optuna
from hypster import HP, instantiate
from hypster.hpo.optuna import suggest_values
from hypster.hpo.types import HpoFloat, HpoInt
from sklearn.base import ClassifierMixin
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression


def logistic_config(hp: HP) -> LogisticRegression:
    C = hp.float(1.0, name="C", min=1e-4, max=10.0, hpo_spec=HpoFloat(scale="log"))
    return LogisticRegression(C=C, max_iter=1000)


def forest_config(hp: HP) -> RandomForestClassifier:
    n_estimators = hp.int(
        200,
        name="n_estimators",
        min=50,
        max=1000,
        hpo_spec=HpoInt(step=50),
    )
    return RandomForestClassifier(n_estimators=n_estimators, random_state=42)


model_options = {"logistic": logistic_config, "forest": forest_config}


def model_cfg(hp: HP) -> ClassifierMixin:
    model_config = hp.select(model_options, name="model_family", default="forest", options_only=True)
    return hp.nest(model_config, name="model")


def objective(trial: optuna.Trial) -> float:
    values = suggest_values(trial, model_cfg)
    model = instantiate(model_cfg, values=values)
    return train_and_score(model)

study = optuna.create_study(direction="maximize")
study.optimize(objective, n_trials=30)

Inspiration

Hypster draws inspiration from Meta's hydra and hydra-zen framework. The API design is influenced by Optuna's "define-by-run" API.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

hypster-0.7.0.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

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

hypster-0.7.0-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file hypster-0.7.0.tar.gz.

File metadata

  • Download URL: hypster-0.7.0.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hypster-0.7.0.tar.gz
Algorithm Hash digest
SHA256 4558ae346ad0387c2a6a8539a43c8b654e5f3b2320646d3a555583179a191a8e
MD5 20b83d8846d488489e4ffcac20373c66
BLAKE2b-256 718ef7f68b276a00ca69f53aed94799361ca2916670c9dce31778a93cd790dc1

See more details on using hashes here.

File details

Details for the file hypster-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: hypster-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hypster-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5627e60f711dc3f9f67d6a4c98c653ff5ffe860951b90fcdc47cc7223f8dc93b
MD5 e7f7b179b273ba4b0163bf60bb2a8967
BLAKE2b-256 5f74fd9be6f6f08a68ceba09e7f24133b05797503237d2c19410623f03c7cb0e

See more details on using hashes here.

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