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

Metadata

Release files for ghostconfig 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ghostconfig 0.5.0
File Size Uploaded Provenance Actions
ghostconfig-0.5.0.tar.gz 191.2 kB Without provenance Details for ghostconfig-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ghostconfig 0.5.0
File Interpreter ABI Platform Actions
ghostconfig-0.5.0-py3-none-any.whl Python 3 none any Details for ghostconfig-0.5.0-py3-none-any.whl

Total release size: 200.9 kB

Release files / ghostconfig-0.5.0.tar.gz

Download URL ghostconfig-0.5.0.tar.gz
Size 191.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bb7640059e3a08f43cb3ca8b9f43f15a21611936e949dee425c9ed591586860e
BLAKE2b-256 checksum
How to use checksums
4130e224bfd8c9cecc8249cd757e1c773c09e5b55a193b36db24117a2488e5e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ghostconfig-0.5.0-py3-none-any.whl

Download URL ghostconfig-0.5.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe49bd3085d652d8325d283629ff38d3a3d6c7bf170995016b5da6823e5b0736
BLAKE2b-256 checksum
How to use checksums
a9265a35f11e507e62e79aec35da24a74462fec4988377976d8bd908f6d2f766
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for ghostconfig 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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