Skip to main content

A Config System designed for experimental purposes

Project description

YAECS (Yet Another Experiment Config System)

License

GitHub last commit (branch) PyPI version

Documentation Status


Documentation: here

This package is a Config System which allows easy manipulation of config files for safe, clear and repeatable experiments. In a few words, it is:

  • built for Machine Learning with its constraints in mind, but also usable out-of-the-box for other kinds of projects ;
  • built with scalability in mind and can adapt just as easily to large projects investigating hundreds of well-organised parameters across many experiments ;
  • designed to encourage good coding practices for research purposes, and if used rigorously will ensure a number of highly desirable properties such that maintenance-less forward-compatibility of old configs, easy reproducibility of any experiment, and extreme clarity of former experiments for your future self or collaborators.

LINK TO DOCUMENTATION

Installation

The package can be installed from pipy:

pip install yaecs

Getting started

Getting started with using YAECS requires a single thing : creating a Configuration object containing your parameters. There are many ways to create this config object, but let us focus on the easiest one.

from yaecs import make_config

dictionary = {
    "batch_size": 32,
    "experiment_name": "overfit",
    "learning_rate": 0.001
}
config = make_config(dictionary)

And there you go, you have a config. You can query it using usual dictionary or object attribute getters such as :

print(config.batch_size)  # 32
print(config["experiment_name"])  # overfit
print(config.get("learning_rate", None))  # 0.001

At this point you might think that this is nothing more than a more fancy dictionary... and you'd be right, that's actually a very good way to think about your config. In fact, because it mostly behaves like a dictionary, it is much easier to integrate into existing code or libraries which expect dictionaries.

Of course, in many situations, it is much more than a simple dictionary, as we demonstrate thoughout our documentation. In this first introduction, we will cover two more things : loading a config from a yaml file, and some basic command line interaction. If you want more, we encourage you to keep reading our other tutorials in which we give practical tips and best practices for the management of your config over the course of a project.

The main purpose of using a config system is to manage your parameters more easily by getting them out of your code. So let's do just that :)

We will create a file called config.yaml in the root of our project, next to our main.py :

batch_size: 32
experiment_name: overfit
learning_rate: 0.001

Then, in your main.py, all you need to do is use the path to the file instead of the dictionary :

from yaecs import make_config

config = make_config("config.yaml")

print(config.batch_size)
print(config["experiment_name"])
print(config.get("learning_rate", None))

Now, if you run your script, you should see the same prints as before.

$ python main.py
[CONFIG] Building config from default : config
32
overfit
0.001

One way the YAECS config system provides to manage parameters is to edit them from the command line, which is performed automatically when you create your config. See for yourself :

$ python main.py --batch_size 16
[CONFIG] Building config from default : config
[CONFIG] Merging from command line : {'batch_size': 16}
16
overfit
0.001
$ python main.py --experiment_name=production --batch_size=16
[CONFIG] Building config from default : config
[CONFIG] Merging from command line : {'experiment_name': 'production', 'batch_size': 16}
16
production
0.001

The YAECS command line parser, one of YAECS' many ways of preparing your experiment's config, is very flexible and fast when you want to change only a handful of parameters.

This is as far as we go for this short introduction. If you're already used to config systems and managing config files, this might be enough to get you started. However, if you've always just used hardcoded values in your code, and maybe argparse, you might not really know where to start. We advise you to look at our tutorial (in DOCUMENTATION_WIP.md), which will walk you through config management using YAECS from early set-up to advanced usage.

Happy experimenting !

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

yaecs-7.1.2.tar.gz (319.6 kB view details)

Uploaded Source

Built Distribution

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

yaecs-7.1.2-py3-none-any.whl (112.7 kB view details)

Uploaded Python 3

File details

Details for the file yaecs-7.1.2.tar.gz.

File metadata

  • Download URL: yaecs-7.1.2.tar.gz
  • Upload date:
  • Size: 319.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for yaecs-7.1.2.tar.gz
Algorithm Hash digest
SHA256 6304c654f62d9f302a0172d0556294e7c343b09a4da59132c73c5942355ee411
MD5 67ea3ac338f79f3aab7e271a72f5b62d
BLAKE2b-256 2229c3e7aa720123a3dcee58493e003c29d496aa7a149bb7aaa1eb5a2efb2161

See more details on using hashes here.

File details

Details for the file yaecs-7.1.2-py3-none-any.whl.

File metadata

  • Download URL: yaecs-7.1.2-py3-none-any.whl
  • Upload date:
  • Size: 112.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for yaecs-7.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 96e036f00bdf6a16c6906349dc6a805a6e3fc9b1abea265874866c08fac6c574
MD5 d3033245f5392be868bae980951d6f8b
BLAKE2b-256 0cdb3c1c65039f1732c3ab80a03fdbbac5fabc01d295a8346a053e0a14a8d440

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