Skip to main content

No project description provided

Project description

paramflow

paramflow is a flexible and user-friendly parameter and configuration management library designed for machine learning workflows and applications requiring profiles and layered parameters. It enables seamless merging of parameters from multiple sources, auto-generates a command-line argument parser, and allows for easy parameter overrides.

Features

  • Layered configuration: Merge parameters from files, environment variables, and command-line arguments.
  • Immutable dictionary: Provides a read-only dictionary with attribute-style access.
  • Profile support: Manage multiple sets of parameters with profile-based layering.
  • Layered meta-parameters: paramflow configures itself using a layered approach.
  • Automatic type conversion: Converts types during merging based on target parameter types.
  • Command-line argument parsing: Automatically generates an argparse parser from parameter definitions.

Installation

pip install paramflow

Install with .env support:

pip install "paramflow[dotenv]"

Basic Usage

Example Configuration File (params.toml)

[default]
learning_rate = 0.001
batch_size = 64

Loading Parameters in Python (app.py)

import paramflow as pf

params = pf.load('params.toml')
print(params.learning_rate)  # 0.001

Generating Command-line Help

Running the script with --help displays both meta-parameters and parameters:

python app.py --help

Meta-Parameter Layering

Meta-parameters control how paramflow.load reads its own configuration. Layering order:

  1. paramflow.load arguments
  2. Environment variables (default prefix: P_)
  3. Command-line arguments (argparse)

Activating Profiles

Via command-line:

python print_params.py --profile dqn-adam

Via environment variable:

P_PROFILE=dqn-adam python print_params.py

Parameter Layering

Parameters are merged from multiple sources in the following order:

  1. Configuration files (.toml, .yaml, .ini, .json)
  2. .env file (if enabled)
  3. Environment variables (default prefix: P_)
  4. Command-line arguments (argparse)

Customizing Layering Order

You can specify the order explicitly:

params = pf.load('params.toml', 'env', '.env', 'args')

Overriding Parameters

Command-line arguments override other sources:

python print_params.py --profile dqn-adam --learning_rate 0.0002

Managing ML Hyperparameter Profiles

Example Configuration (params.toml)

[default]
learning_rate = 0.00025
batch_size = 32
optimizer_class = 'torch.optim.RMSprop'
optimizer_kwargs = { momentum = 0.95 }
random_seed = 13

[adam]
learning_rate = 1e-4
optimizer_class = 'torch.optim.Adam'
optimizer_kwargs = {}

Activating a Profile

python app.py --profile adam

This overrides:

  • learning_rate1e-4
  • optimizer_classtorch.optim.Adam
  • optimizer_kwargs{}

Managing Development Stages

Profiles can be used to manage configurations for different environments.

Example Configuration (params.toml)

[default]
debug = true
database_url = "mysql://localhost:3306/myapp"

[dev]
database_url = "mysql://dev:3306/myapp"

[prod]
debug = false
database_url = "mysql://prod:3306/myapp"

Activating a Profile

export P_PROFILE=dev
python app.py

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

paramflow-0.2.2.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

paramflow-0.2.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file paramflow-0.2.2.tar.gz.

File metadata

  • Download URL: paramflow-0.2.2.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for paramflow-0.2.2.tar.gz
Algorithm Hash digest
SHA256 902eb7aaab6915283fe9e93c060c6b558779c314981a1861e549ba0e2a47acef
MD5 cdc687cd8553ce77c88a71670a53cd37
BLAKE2b-256 2b9960d4c0479d66e6a810d86c8a47b3ca0b48f3f1a51a45df2dd2adfc02bc8d

See more details on using hashes here.

File details

Details for the file paramflow-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: paramflow-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for paramflow-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 11c6bdd0d96fbc306c28b629ad88a510cd20791d09c3c5661b90d0d9bde4f0dd
MD5 af30d32438b0d2f6f3a6bf60e2bd6f21
BLAKE2b-256 db25de47f0334bd4cf6fe659425a58e522256976a467eec10514e37551fb951d

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