Skip to content

Releases: vfdev-5/py_config_runner

Configuration can be used with MP

24 Mar 14:54
Compare
Choose a tag to compare

Configuration can be now used with multiprocessing:

import multiprocessing as mp


def worker_config_checker(config):
    import numpy as np

    assert "a" in config
    assert config.a == 123

    assert "b" in config
    np.testing.assert_allclose(config.b, np.array([1, 2, 3]))

    assert "out" in config
    assert config.out == 12

if __name__ == "__main__":
    config = ConfigObject(config_filepath)
    ctx = mp.get_context("spawn")
    p = ctx.Process(target=worker_config_checker, args=(config,))
    p.start()
    p.join()

Deep Learning DDP example with Ignite :

Mutable configuration improvements

22 Mar 15:14
7462b88
Compare
Choose a tag to compare

Configuration can be updated from the script before loading it and mutation can change types.

Limitations: mutation can not a local object or class instance.

Example

old_value = {"encoder": "E1", "decoder": "D1"} 
# old_value = "unet"
# old_value = [1, 2, 3]
# old_value = 5

new_value = "unet"
# new_value = [1, 2, 3]
# new_value = {"encoder": "E1", "decoder": "D1"}
# new_value = 5

# Create a configuration file:
filepath = os.path.join(dirname, "custom_module.py")
s = f"""
a = {old_value}
"""

with open(filepath, "w") as h:
   h.write(s)

# Load configuration:
config = ConfigObject(filepath, mutations={"a": new_value})
assert config.a == new_value

What's Changed

Full Changelog: v0.3.0...v0.3.1

Mutable configuration

03 Jan 20:36
6b531aa
Compare
Choose a tag to compare

Configuration can be updated from the script before loading it.

Let's assume that configuration python file has learning_rate = 0.01 which is used to configure an optimizer:

# baseline.py configuration file

learning_rate = 0.01
optimizer = SGD(parameters, lr=learning_rate)

And we would like to override learning_rate from the script using above configuration file and has also optimizer updated accordingly:

# Script file using baseline.py configuration

config = ConfigObject("/path/to/baseline.py", mutations={"learning_rate": 0.05})
print(config)
print(config.optimizer)
assert config.lr == 0.05
assert config.optimizer.lr == 0.05

What's Changed

Full Changelog: v0.2.1...v0.3.0

Minor internal update

15 Feb 15:22
Compare
Choose a tag to compare

ConfigObject as Python API without using CLI

15 Feb 02:22
Compare
Choose a tag to compare
  • Expose ConfigObject as Python API without using CLI
  • Another way to validate configuration (uses pydantic)

See example:

Lazy config loading

12 Jun 11:34
2d64af8
Compare
Choose a tag to compare
  • Lazy configuration loading
    • removed --manual-setup option
py_config_runner scripts/training.py configs/train/baseline.py

Bug fixes

13 Sep 13:56
3e1d8a6
Compare
Choose a tag to compare

Post release with bug fix of #1

Multiple executors + new options

25 Aug 21:22
Compare
Choose a tag to compare
  1. Execute configuration as
  • cmd : py_config_runner scripts/training.py configs/train/baseline.py
  • module : python -u -m py_config_runner.__main__ scripts/training.py configs/train/baseline.py
  • with specific launcher : python -m special_launcher py_config_runner_script scripts/training.py configs/train/baseline.py
  1. Added option to load configuration manually in running script

py_config_runner scripts/training.py configs/train/baseline.py --manual_config_load

  1. Documentation improvements

First tag

04 Aug 11:17
Compare
Choose a tag to compare
First tag Pre-release
Pre-release

It is the first release of python configuration runner.
Added

  • Documentation on ReadTheDocs