{ "info": { "author": "vfdev-5", "author_email": "vfdev.5@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Python Configuration Runner\n\n[![CircleCI](https://circleci.com/gh/vfdev-5/py_config_runner/tree/master.svg?style=svg)](https://circleci.com/gh/vfdev-5/py_config_runner/tree/master)\n[![codecov](https://codecov.io/gh/vfdev-5/py_config_runner/branch/master/graph/badge.svg)](https://codecov.io/gh/vfdev-5/py_config_runner)\n[![Documentation Status](https://readthedocs.org/projects/py-config-runner/badge/?version=latest)](https://py-config-runner.readthedocs.io/en/latest/?badge=latest)\n\nCommand line executable to run a script with python configuration file.\n\n**Why a python file as configuration?**\n\n- Configuration of any complexity\n- No need to serialize the configuration\n- No neeed other meta-languages for the configuration\n\n\n## Usage\n\n```bash\ncd /path/to/my/project\npy_config_runner scripts/training.py configs/train/baseline.py\n```\n\nor\n\n```bash\ncd /path/to/my/project\npython -u -m py_config_runner.__main__ scripts/training.py configs/train/baseline.py\n```\n\nor if your specific launcher requires only python script files (e.g. `torch.distributed.launch`):\n\n```bash\ncd /path/to/my/project\npython -m special_launcher `py_config_runner_script` scripts/training.py configs/train/baseline.py\n```\n\n\nThe only condition on the script file is it should contain `run(config, **kwargs)` callable method. Additionally, \nargument kwargs contains `logger` (e.g. `kwargs['logger']`) and `local_rank` (e.g. `kwargs['logger']`) \nfor distributed computations.\n\n\nNo restrictions are applied on the configuration file. It is user's responsibility to provide the script file that can \nconsume given configuration file. Provided configuration file is loaded as python module and exposed into the script as \nthe module named `config`.\n\n### Example for Machine/Deep Learning\n\nFor example, below configuration file defines a model, datasets, criterion, optimizer etc and the training script runs the training:\n\n```python\n# config.py\nfrom torch import nn\nfrom torch.optim import SGD\n\nfrom torchvision.transforms import Compose, ToTensor, Normalize, RandomHorizontalFlip\n\nfrom mymodule.dataflow import get_mnist_data_loaders\nfrom another_module.models import CoolNet\n\n\ntrain_transform=Compose([RandomHorizontalFlip(), ToTensor(), Normalize((0.1307,), (0.3081,))])\nval_transform=Compose([ToTensor(), Normalize((0.1307,), (0.3081,))])\n\ntrain_batch_size = 64\nval_batch_size = 128\n\ntrain_loader, val_loader = get_mnist_data_loaders(train_transform, train_batch_size, val_transform, val_batch_size)\n\nmodel = CoolNet()\n\noptimizer = SGD(model.parameters(), lr=0.01)\ncriterion = nn.CrossEntropyLoss()\n\nnum_epochs = 20\n\nval_interval = 5\n``` \n\n```python\n# training.py\nfrom mymodule.utils import prepare_batch\nfrom mymodule.metrics import compute_running_accuracy\n\n\ndef run(config, logger=None, **kwargs):\n logger.info(\"Start my script\")\n\n model = config.model\n model.to('cuda')\n\n criterion = config.criterion\n criterion = criterion.to('cuda')\n\n optimizer = config.optimizer\n\n for e in range(config.num_epochs):\n logger.info(\"Epoch {} / {}\".format(e + 1, config.num_epochs))\n for batch in config.train_loader:\n x, y = prepare_batch(batch, 'cuda') \n optimizer.zero_grad()\n y_pred = model(x) \n loss = criterion(y_pred, y)\n loss.backward()\n optimizer.step()\n\n if e % config.val_metrics == 0:\n running_acc = 0\n for batch in config.val_loader:\n x, y = prepare_batch(batch, 'cuda') \n y_pred = model(x) \n\n running_acc = compute_running_accuracy(running_acc, y_pred, y)\n\n logger.info(\"Validation: metrics={}\".format(running_acc))\n``` \n\n## Installation\n\n```bash\npip install py-config-runner\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/vfdev-5/py_config_runner", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "py-config-runner", "package_url": "https://pypi.org/project/py-config-runner/", "platform": "", "project_url": "https://pypi.org/project/py-config-runner/", "project_urls": { "Homepage": "https://github.com/vfdev-5/py_config_runner" }, "release_url": "https://pypi.org/project/py-config-runner/0.1.2.post1/", "requires_dist": [ "click", "pathlib2 ; python_version < \"3\"", "pytest ; extra == 'tests'", "pytest-cov ; extra == 'tests'" ], "requires_python": "", "summary": "Command line executable to run a script with Python configuration file", "version": "0.1.2.post1" }, "last_serial": 5825779, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "f140c88a44f4ac2dc450533b11e3bd31", "sha256": "d9e66fe50c605ebadfe9997d82b2944ad9f0fdc30da86532457f7cd60c1f22e1" }, "downloads": -1, "filename": "py_config_runner-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f140c88a44f4ac2dc450533b11e3bd31", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7828, "upload_time": "2019-08-04T10:12:27", "url": "https://files.pythonhosted.org/packages/3b/fc/c24136b106122010cd7d92bd5fd8201af98ff4d2495cf3169f0779ee416b/py_config_runner-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "13814c214c6df6fb0e5042db7538818e", "sha256": "6cddb480796efe822d288b2470e5d4ef116a206dd87ded0ae6b689703cbf2887" }, "downloads": -1, "filename": "py_config_runner-0.1.0.tar.gz", "has_sig": false, "md5_digest": "13814c214c6df6fb0e5042db7538818e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6317, "upload_time": "2019-08-04T10:12:28", "url": "https://files.pythonhosted.org/packages/a0/b2/3cdba60d763e80facb77fb0e16b618f43aeccfdfca5a0da354c327c49082/py_config_runner-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "fa0919b9901ec5e99fd29a73066e15f3", "sha256": "4bd538ffde3ccfe8647e2a3c4084bc35dd2f92fa8c2735ba2382c2ad7d639f08" }, "downloads": -1, "filename": "py_config_runner-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fa0919b9901ec5e99fd29a73066e15f3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7861, "upload_time": "2019-08-04T11:23:26", "url": "https://files.pythonhosted.org/packages/60/23/22aed73984cdf83499d60631bc5aa3ad136f5bccea0d5403ec424e0513ce/py_config_runner-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e89d0df6f64df56d247e82385597a496", "sha256": "5588dca55b0b3cba1a53eb7e7685a26d10584b9bd00bce29f654a805f9ffb759" }, "downloads": -1, "filename": "py_config_runner-0.1.1.tar.gz", "has_sig": false, "md5_digest": "e89d0df6f64df56d247e82385597a496", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6355, "upload_time": "2019-08-04T11:23:27", "url": "https://files.pythonhosted.org/packages/5b/e9/508209aac9ffa01423e2b38af76268ba1e5f822cd85f027d82619271487c/py_config_runner-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "24ab23fec2706aa6cf1f4c516bd3c1d4", "sha256": "2aea1c58d116d53857af9e22f768281df170c2b5d65ee60be3f6757da255906e" }, "downloads": -1, "filename": "py_config_runner-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "24ab23fec2706aa6cf1f4c516bd3c1d4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8307, "upload_time": "2019-08-25T21:50:34", "url": "https://files.pythonhosted.org/packages/3e/bc/968adb454c47486a5f35ae6678eac6c7365cc6418616d78ff28482257cae/py_config_runner-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e72d8f91aefb4f902497d5d36a6c2991", "sha256": "0027b58ee2ab289107edfd55828843b496e7d280f7432f6aa5ff0742c673e2f7" }, "downloads": -1, "filename": "py_config_runner-0.1.2.tar.gz", "has_sig": false, "md5_digest": "e72d8f91aefb4f902497d5d36a6c2991", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6900, "upload_time": "2019-08-25T21:50:35", "url": "https://files.pythonhosted.org/packages/2e/1d/831087409bbb6cd2db89fce1d6d73dc5c53b0eddff3a28239f32443a2fc1/py_config_runner-0.1.2.tar.gz" } ], "0.1.2.post1": [ { "comment_text": "", "digests": { "md5": "bd2f5018a8e33b82bdf859813a328f83", "sha256": "a4ab9cdb1e83a7e8a4a8f9dc9073685e294e210c4368d07b91335f3fb3a66076" }, "downloads": -1, "filename": "py_config_runner-0.1.2.post1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bd2f5018a8e33b82bdf859813a328f83", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8562, "upload_time": "2019-09-13T13:57:32", "url": "https://files.pythonhosted.org/packages/9a/bd/9a868736f15729e0c73922fc7a0d6970b133851b97867d955e6f7189c9b7/py_config_runner-0.1.2.post1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6da3b5be3ac9dbb890bc38a84c7e5281", "sha256": "e1ef3cfc9fb252e5f5a0169827bd8aaf4fbe685f3598763febe4eb31158c138b" }, "downloads": -1, "filename": "py_config_runner-0.1.2.post1.tar.gz", "has_sig": false, "md5_digest": "6da3b5be3ac9dbb890bc38a84c7e5281", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7024, "upload_time": "2019-09-13T13:57:34", "url": "https://files.pythonhosted.org/packages/8e/b5/2c168fe11332fc7704ebc22b9bd1c052212ea5c026b6415268dd8edaebcf/py_config_runner-0.1.2.post1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bd2f5018a8e33b82bdf859813a328f83", "sha256": "a4ab9cdb1e83a7e8a4a8f9dc9073685e294e210c4368d07b91335f3fb3a66076" }, "downloads": -1, "filename": "py_config_runner-0.1.2.post1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bd2f5018a8e33b82bdf859813a328f83", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8562, "upload_time": "2019-09-13T13:57:32", "url": "https://files.pythonhosted.org/packages/9a/bd/9a868736f15729e0c73922fc7a0d6970b133851b97867d955e6f7189c9b7/py_config_runner-0.1.2.post1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6da3b5be3ac9dbb890bc38a84c7e5281", "sha256": "e1ef3cfc9fb252e5f5a0169827bd8aaf4fbe685f3598763febe4eb31158c138b" }, "downloads": -1, "filename": "py_config_runner-0.1.2.post1.tar.gz", "has_sig": false, "md5_digest": "6da3b5be3ac9dbb890bc38a84c7e5281", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7024, "upload_time": "2019-09-13T13:57:34", "url": "https://files.pythonhosted.org/packages/8e/b5/2c168fe11332fc7704ebc22b9bd1c052212ea5c026b6415268dd8edaebcf/py_config_runner-0.1.2.post1.tar.gz" } ] }