Metadata-Version: 2.4
Name: ghostconfig
Version: 0.1.0
Summary: A config system that is lazily validated as parameters are used
Project-URL: Homepage, https://github.com/ChainBreak/ghostconfig
License: MIT License
        
        Copyright (c) 2026 Thomas Rowntree
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Requires-Dist: omegaconf
Provides-Extra: dev
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

# ghostconfig

A config system that is lazily validated as parameters are used.

## Installation

```bash
pip install ghostconfig
```

## Usage

### Creating a config

```python
import ghostconfig

# From a YAML file (OmegaConf interpolations supported)
config = ghostconfig.GhostConfig("path/to/config.yaml")

# From a JSON file
config = ghostconfig.GhostConfig("path/to/config.json")

# From a plain Python dict
config = ghostconfig.GhostConfig({"num_epochs": 10, "learning_rate": 0.001})
```

### Reading values

`get(key)` with no default returns a `GhostConfig` sub-config (real or ghost).
`get(key, default)` returns the leaf value (type inferred from the default).

```python
# Given config.yaml:
# model:
#   layers: 4
#   block: resnet
# dataset:
#   path: my/data/
#   augmentations: [crop]

model_config = config.get("model")    # GhostConfig
layers = model_config.get("layers", 1)  # 4

# Accessing a key that doesn't exist in the YAML is fine at this point —
# a "ghost" GhostConfig is returned and the access is recorded.
training_config = config.get("training")
learning_rate = training_config.get("learning_rate", 0.001)  # returns 0.001
```

### Validating at setup time

Call `check()` once all parameters have been read. It raises `MissingConfigError`
with a suggestion showing exactly what to add to your config file.

```python
config.check()
# MissingConfigError:
# The following parameters were used but missing from the config.
# Since this started from a yaml (path/to/config.yaml), you should add:
#
# training:
#   learning_rate: 0.001
```

If multiple keys are missing they are merged into a single suggestion block.
The format matches the source: YAML for `.yaml` files, JSON for `.json` files,
and a Python dict literal for dict-based configs.

## Development

### Setup

```bash
pip install -e ".[dev]"
```

Or install with test dependencies:

```bash
pip install pytest
pip install -e .
```

### Running Tests

```bash
pytest
```

To run with verbose output:

```bash
pytest -v
```

## Building and Publishing to PyPI

### Prerequisites

```bash
pip install build twine
```

### Build the distribution

```bash
python -m build
```

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

### Upload to PyPI

First, upload to [TestPyPI](https://test.pypi.org/) to verify everything looks correct:

```bash
twine upload --repository testpypi dist/*
```

When ready, upload to the real PyPI:

```bash
twine upload dist/*
```

You will be prompted for your PyPI credentials. It is recommended to use an [API token](https://pypi.org/manage/account/token/) instead of your password.

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

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