Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ repos:
# Ruff version.
rev: v0.15.12
hooks:
# Run the formatter.
- id: ruff-format
# Run the linter.
- id: ruff-check
args: [ --fix ]
# Run the formatter.
- id: ruff-format

32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# Config-Foundry
# dirconf

[![PyPI version](https://img.shields.io/pypi/v/config-foundry)](https://pypi.org/project/config-foundry/)
[![Python versions](https://img.shields.io/pypi/pyversions/config-foundry)](https://pypi.org/project/config-foundry/)
[![License](https://img.shields.io/pypi/l/config-foundry)](https://github.com/jmarshrossney/config-foundry/blob/main/LICENSE)
[![CI](https://github.com/jmarshrossney/config-foundry/actions/workflows/ci.yml/badge.svg)](https://github.com/jmarshrossney/config-foundry/actions/workflows/ci.yml)
[![Docs](https://github.com/jmarshrossney/config-foundry/actions/workflows/docs.yml/badge.svg)](https://jmarshrossney.github.io/config-foundry)
[![PyPI version](https://img.shields.io/pypi/v/dirconf)](https://pypi.org/project/dirconf/)
[![Python versions](https://img.shields.io/pypi/pyversions/dirconf)](https://pypi.org/project/dirconf/)
[![License](https://img.shields.io/pypi/l/dirconf)](https://github.com/jmarshrossney/dirconf/blob/main/LICENSE)
[![CI](https://github.com/jmarshrossney/dirconf/actions/workflows/ci.yml/badge.svg)](https://github.com/jmarshrossney/dirconf/actions/workflows/ci.yml)
[![Docs](https://github.com/jmarshrossney/dirconf/actions/workflows/docs.yml/badge.svg)](https://jmarshrossney.github.io/dirconf)

`config-foundry` is a Python tool for declaratively specifying what a valid configuration directory looks like.
`dirconf` is a Python tool for declaratively specifying what a valid configuration directory looks like.

I wrote this because I sometimes have to work with quite old scientific models that require various configuration files and data inputs in various formats to be present in various locations.
I was (and remain) concerned about how easy it can be to misconfigure certain models without realising, and how common workflows compromise reproducibility.

`config-foundry` helps by
`dirconf` helps by

1. Allowing the user to describe the structure of a directory representing a valid configuration, and validate real directories against this description.

2. Facilitating the generation of new configurations and metadata programmatically, in Python, as opposed to copying and editing files by hand or writing shell scripts.

3. Providing a consistent mechanism through which complex, distributed configurations in legacy formats can be validated using excellent tools such as [JSON Schema](https://json-schema.org/) and [Pydantic](https://docs.pydantic.dev/).

Configurations are specified using Python [dataclasses](https://docs.python.org/3/library/dataclasses.html); `config-foundry` has no dependencies beyond the standard library.
Configurations are specified using Python [dataclasses](https://docs.python.org/3/library/dataclasses.html); `dirconf` has no dependencies beyond the standard library.

For full user documentation and examples please visit **[https://jmarshrossney.github.io/config-foundry/](https://jmarshrossney.github.io/config-foundry/)**.
For full user documentation and examples please visit **[https://jmarshrossney.github.io/dirconf/](https://jmarshrossney.github.io/dirconf/)**.

## Installation

```sh
pip install config-foundry
pip install dirconf
```

or with `uv`:

```sh
uv add config-foundry
uv add dirconf
```

or the equivalent command for other package managers (poetry etc).
Expand All @@ -46,11 +46,3 @@ Please open a Pull Request against the `main` branch.

See [`CONTRIBUTING.md`](CONTRIBUTING.md) for full details.

## Why `config-foundry`?

A foundry casts objects from moulds.
Similarly, `config-foundry` lets you declare a *mould* — in the form of a dataclass — that describes the shape of a valid configuration directory.
That mould can then be used to capture configurations from the filesystem or cast new ones from data in Python.

This project was originally called `metaconf` ("configuration of configurations"), but the name was taken on PyPI..

10 changes: 5 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# API Reference

::: config_foundry.config
::: dirconf.config

---

::: config_foundry.filter
::: dirconf.filter

---

::: config_foundry.handler
::: dirconf.handler

---

::: config_foundry.node
::: dirconf.node

---

::: config_foundry.utils
::: dirconf.utils

43 changes: 22 additions & 21 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Home

`config-foundry` is a simple tool for the meta-configuration of collections of configuration files, leaning heavily on Python [dataclasses](https://docs.python.org/3/library/dataclasses.html).
`dirconf` is a simple tool for the meta-configuration of collections of configuration files, leaning heavily on Python [dataclasses](https://docs.python.org/3/library/dataclasses.html).

I wrote this because I sometimes work with quite old scientific models requiring various configuration files and data inputs in various formats to be present in various locations. I was (and remain) concerned about how easy it can be to misconfigure certain models without realising, and how common workflows compromise reproducibility.

`config-foundry` helps by
`dirconf` helps by

1. Allowing the user to describe the structure of a directory representing a valid configuration, and validate real directories against this description.

Expand All @@ -15,49 +15,50 @@ I wrote this because I sometimes work with quite old scientific models requiring

## Installation

`config-foundry` is a Python package and thus can be installed using `pip`, or tools such as `uv` and `poetry` that wrap around `pip`.
`dirconf` is a Python package and thus can be installed using `pip`, or tools such as `uv` and `poetry` that wrap around `pip`.


=== "pip"
=== "uv (recommended)"

```sh
pip install git+https://github.com/jmarshrossney/config-foundry.git
uv add dirconf
```

=== "uv"
=== "pip"

```sh
uv add git+https://github.com/jmarshrossney/config-foundry.git
pip install dirconf
```

!!! Note
Currently `config-foundry` is not in PyPI and must be installed directly from Github.

Currently Python versions equal to or above 3.11 are supported.
Currently Python versions equal to or above 3.12 are supported.
It has no dependencies other than the Standard Library.


## Overview of usage

There are two essential steps for adapting `config-foundry` to a specific use-case.
There are two essential steps for adapting `dirconf` to a specific use-case.

1. **Define handlers** satisfying the `Handler` protocol for each of the paths (files and directories) present in your configuration.
2. **Define the structure of a valid configuration** in terms of its paths and their respective handlers, by subclassing the `ConfigSchema` class. This is most easily done using the `make_config_schema` function.
2. **Define the structure of a valid configuration** in terms of its paths and their respective handlers, by subclassing the `DirConfig` class. This is most easily done using the `make_dirconfig` function.

The custom `ConfigSchema` subclass can then be used to
The custom `DirConfig` subclass can then be used to

1. **Read** a configuration from the filesystem into a Python `dict` (`ConfigSchema.read`).
2. **Write** a configuration `dict` to the filesystem (`ConfigSchema.write`)
1. **Read** a configuration from the filesystem into a Python `dict`.
2. **Write** a configuration `dict` to the filesystem.

These steps are most easily understood through examples. To start with, take a look at the [Usage](101.md) section. More realistic examples can be found in the right navigation bar.
These steps are most easily understood through examples.
To start with, take a look at the [Usage](101.md) section.
More realistic examples can be found under the 'examples' heading.

All of the examples (including 'Usage') are based on marimo notebooks. You can open them directly in marimo using the button in the sidebar, or inspect the generated markdown on this page.
All of the examples (including 'Usage') are based on self-contained [marimo](https://marimo.io/) notebooks, which can be browsed and downloaded [here](https://github.com/jmarshrossney/dirconf/tree/main/examples/)


## Philosophy

`config-foundry` contains ~700 lines of code (including docstrings) and has no dependencies beyond the Standard Library.
`dirconf` contains ~700 lines of code (including docstrings) and has no dependencies beyond the Standard Library.

This is by design. I have no intention of developing `config-foundry` into a more sophisticated tool than it already is. The aim is that is works seamlessly alongside other tools and packages for parsing and validation, without ever getting in the way or creating conflicts.
This is by design.
I have no intention of developing `dirconf` into a more sophisticated tool than it already is.
The aim is that is works seamlessly alongside other tools and packages for parsing and validation, without ever getting in the way or creating conflicts.

With that out of the way, please feel free to raise an [issue](https://github.com/jmarshrossney/config-foundry/issues) or make a [pull request](https://github.com/jmarshrossney/config-foundry/pulls) to suggest a change or feature.
With that out of the way, please feel free to raise an [issue](https://github.com/jmarshrossney/dirconf/issues) or make a [pull request](https://github.com/jmarshrossney/dirconf/pulls) to suggest a change or feature.
Loading