Skip to main content

Ghost Config

Installation

pip install ghostconfig

Usage

Each example below is a self-contained script demonstrating one aspect of GhostConfig. The output shown was produced by running the script directly.

Config file: training.yaml

All examples load from this shared config file:

experiment_name: cifar10_baseline

model:
  layers:
  - channels: 64
    blocks: 3
  - channels: 128
    blocks: 6

Example 01

Standard usage of GhostConfig.

from ghostconfig import GhostConfig

config = GhostConfig.create("training.yaml")

print(f"Experiment name: {config.get('experiment_name', '')}")

# Get a sub-config for the model
model_config = config["model"]

# Iterate over the layers in the model
for block in model_config["layers"]:
    channels = block.get("channels", 128)
    blocks = block.get("blocks", 3)
    print(f"Channels: {channels}, Blocks: {blocks}")

# Check that all required keys are present
config.check()

Output

Experiment name: cifar10_baseline
Channels: 64, Blocks: 3
Channels: 128, Blocks: 6

Example 02

No missing errors are raised until check() is called.

from ghostconfig import GhostConfig

config = GhostConfig.create("training.yaml")

# Get a sub-config for the model
model_config = config["model"]

# Iterate over the layers in the model
for block in model_config["layers"]:
    block_type = block.get("type", "conv")
    print(f"Block type: {block_type}")

# Check that all required keys are present
config.check()

Output

Block type: conv
Block type: conv
Missing keys:
  - model.layers.0.type
  - model.layers.1.type

Unused keys:
  - experiment_name

Since this started from a yaml (training.yaml), you should add:

model:
  layers:
  - type: conv
  - type: conv

No missing errors are raised until check() is called.

from ghostconfig import GhostConfig

config = GhostConfig.create("training.yaml")

# Get a sub-config for the model
model_config = config["model"]

# Iterate over the layers in the model
for block in model_config["layers"]:
    block_type = block.get("type", "conv")
    print(f"Block type: {block_type}")

# Check that all required keys are present
config.check()

Output

Block type: conv
Block type: conv
The following parameters were used but missing from the config:
  - model.layers.0.type
  - model.layers.1.type

Since this started from a yaml (training.yaml), you should add:

model:
  layers:
  - type: conv
  - type: conv

The following keys were present in the config but never accessed:
  - experiment_name

Development

Setup

pip install -e ".[dev]"

Or install with test dependencies:

pip install pytest
pip install -e .

Running Tests

pytest

To run with verbose output:

pytest -v

Linting and Type Checking

ruff check && mypy ghostconfig/ && pytest

Building and Publishing to PyPI

Prerequisites

pip install build twine

Build the distribution

rm dist/*
python -m build

This creates a dist/ directory containing a .whl and .tar.gz file.

Upload to PyPI

twine upload dist/*

You will be prompted for your PyPI credentials. It is recommended to use an API token instead of your password.

To avoid entering credentials each time, create a ~/.pypirc file:

[pypi]
  username = __token__
  password = pypi-your-api-token-here

Download files

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

Source Distribution

ghostconfig-0.5.0.tar.gz (191.2 kB view details)

Uploaded Source

Built Distribution

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

ghostconfig-0.5.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file ghostconfig-0.5.0.tar.gz.

File metadata

  • Download URL: ghostconfig-0.5.0.tar.gz
  • Upload date:
  • Size: 191.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ghostconfig-0.5.0.tar.gz
Algorithm Hash digest
SHA256 bb7640059e3a08f43cb3ca8b9f43f15a21611936e949dee425c9ed591586860e
MD5 6dad0438b4670bd4f2df2ab5df995c49
BLAKE2b-256 4130e224bfd8c9cecc8249cd757e1c773c09e5b55a193b36db24117a2488e5e6

See more details on using hashes here.

File details

Details for the file ghostconfig-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ghostconfig-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ghostconfig-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe49bd3085d652d8325d283629ff38d3a3d6c7bf170995016b5da6823e5b0736
MD5 42c53678269d632d15ef2520f7db11ad
BLAKE2b-256 a9265a35f11e507e62e79aec35da24a74462fec4988377976d8bd908f6d2f766

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page