cliconfig


Namecliconfig JSON
Version 1.4.4 PyPI version JSON
download
home_page
SummaryMerge your config files and set parameters from the command line in a simple way.
upload_time2024-01-12 13:44:36
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords cli config cliconfig python yaml merge
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # CLI Config

## *Build your experiment configurations for complex projects with robustness, flexibility and simplicity*

<p align="center">
  <img
  src="https://raw.githubusercontent.com/valentingol/cliconfig/main/docs/_static/logo_extend_black.png"
  alt="CLI-Config-logo" width="100%" height="100%"
  />
</p>

*CLI Config* is a lightweight library that provides routines to merge nested configs
and set parameters from command line. It contains many routines to create and manipulate
the config as flatten or nested python dictionaries. It also provides processing functions
that can change the whole configuration before and after each config manipulation.

The package was initially designed for machine learning experiments where the
number of parameters is huge and a lot of them have to be set by the user between
each experiment. If your project matches this description, this package is for you!

[![Release](https://img.shields.io/github/v/tag/valentingol/cliconfig?label=Pypi&logo=pypi&logoColor=yellow)](https://pypi.org/project/cliconfig/)
![PythonVersion](https://img.shields.io/badge/Python-3.7%20%7E%203.11-informational)
[![License](https://img.shields.io/github/license/valentingol/cliconfig?color=999)](https://stringfixer.com/fr/MIT_license)

[![Ruff_logo](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)
[![Black_logo](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

[![Ruff](https://github.com/valentingol/cliconfig/actions/workflows/ruff.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/ruff.yaml)
[![Flake8](https://github.com/valentingol/cliconfig/actions/workflows/flake.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/flake.yaml)
[![Pydocstyle](https://github.com/valentingol/cliconfig/actions/workflows/pydocstyle.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/pydocstyle.yaml)
[![MyPy](https://github.com/valentingol/cliconfig/actions/workflows/mypy.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/mypy.yaml)
[![PyLint](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/valentingol/ab12676c87f0eaa715bef0f8ad31a604/raw/cliconfig_pylint.json)](https://github.com/valentingol/cliconfig/actions/workflows/pylint.yaml)

[![Tests](https://github.com/valentingol/cliconfig/actions/workflows/tests.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/tests.yaml)
[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/valentingol/098e9c7c53be88779ee52ef2f2bc8803/raw/cliconfig_tests.json)](https://github.com/valentingol/cliconfig/actions/workflows/tests.yaml)
[![Documentation Status](https://github.com/valentingol/cliconfig/actions/workflows/pdoc.yaml/badge.svg)](https://valentingol.github.io/cliconfig)

Official badge :
[![Config](https://custom-icon-badges.demolab.com/badge/cliconfig-black?logo=cliconfig)](https://github.com/valentingol/cliconfig)

## Documentation :memo:

Here you can find the [documentation](https://valentingol.github.io/cliconfig) (built with pdoc3).

The old documentation with readthedocs (1.3.6, not up to date) is also available
[here](cliconfig.readthedocs.io).

## Pypi :package:

Here you can find the [Pypi page](https://pypi.org/project/cliconfig/).

## Installation :inbox_tray:

In a new virtual environment, simply install the package with:

```bash
pip install cliconfig
```

This package is OS independent and supported on Linux, macOS and Windows.

## Minimal example :rocket:

See the [*Quick Start*](https://valentingol.github.io/cliconfig/cliconfig.html#quick-start)
section of the documentation for a quick overview.

First of all, make default config yaml file(s) in your project (configs are merged from left to right).
Then you can create a config object from these files in python:

```python
# main.py
from cliconfig import make_config
config = make_config('default1.yaml', 'default2.yaml')
```

Now launch your script with eventually additional config file(s) and parameters by command line.
The additional configs are merged on the default one's then the parameters are set.

```bash
python main.py --config first.yaml,second.yaml --param1=1 --subconfig.param2='foo'
```

**By default, these additional configs cannot add new parameters to the default config
(for security and retro-compatibility reasons).**

See the [*Edge cases*](https://valentingol.github.io/cliconfig/cliconfig.html#edge-cases)
section of the documentation for some edge cases due to implementation.

## Tags :label:

You can add tags `@<tag_name>` at the end of parameters names to activate some features.
See the [*Quick start*](https://valentingol.github.io/cliconfig/cliconfig.html#quick-start)
section of the documentation for a quick overview.

The default tags include:

* `@merge_add`, `@merge_before`, and `@merge_after`: merge other yaml files
  indicating the path
* `@copy`: copy another parameter
* `@def`: safely evaluate an expression to define the parameter value (a lot of
  operations and functions are available)
* `@type:<my type>`: try to convert and check the type
* `@select`: target a sub-config and delete the sub-config in the parent config
* `@delete`: delete the key from the config
* `@new`: allow adding parameters that are not present in default config
* `@dict`: create a dict object that is not a sub-config (see the
* [*Edge cases*](https://valentingol.github.io/cliconfig/cliconfig.html#edge-cases) section)

It is also easy to create your own features and possibilities are endless. The way to do
it are explained in the
[*Processing*](https://valentingol.github.io/cliconfig/cliconfig.html#processing)
section of the documentation.

## How to contribute 👷

For **development**, install the package dynamically and dev requirements with:

```bash
pip install -e .
pip install -r requirements-dev.txt
```

Everyone can contribute to CLI Config, and we value everyone’s contributions.
Please see our [contributing guidelines](CONTRIBUTING.md) for more information 🤗

## License, usage and distribution :scroll:

This program is free software under the [MIT License](LICENSE).

It means that:

* If you use this package as a library without modifying it, there is no obligation
  regarding this license.
* If you modify the source code of this package, you must keep the original copyright
  in the source code and add your own. The LICENSE file must also contain the original
  copyright (and the original MIT license notice if not sublicensed).
* In any case, you can use this package in open source or closed source projects and for
  commercial or non-commercial purposes.

Copyright © 2023 Valentin Goldité

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cliconfig",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "cli,config,cliconfig,python,yaml,merge",
    "author": "",
    "author_email": "Valentin Goldite <valentin.goldite@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f0/aa/6e209961949e37401381c172fe5b6a0df9fc5628a889190715a2507c3000/cliconfig-1.4.4.tar.gz",
    "platform": null,
    "description": "# CLI Config\n\n## *Build your experiment configurations for complex projects with robustness, flexibility and simplicity*\n\n<p align=\"center\">\n  <img\n  src=\"https://raw.githubusercontent.com/valentingol/cliconfig/main/docs/_static/logo_extend_black.png\"\n  alt=\"CLI-Config-logo\" width=\"100%\" height=\"100%\"\n  />\n</p>\n\n*CLI Config* is a lightweight library that provides routines to merge nested configs\nand set parameters from command line. It contains many routines to create and manipulate\nthe config as flatten or nested python dictionaries. It also provides processing functions\nthat can change the whole configuration before and after each config manipulation.\n\nThe package was initially designed for machine learning experiments where the\nnumber of parameters is huge and a lot of them have to be set by the user between\neach experiment. If your project matches this description, this package is for you!\n\n[![Release](https://img.shields.io/github/v/tag/valentingol/cliconfig?label=Pypi&logo=pypi&logoColor=yellow)](https://pypi.org/project/cliconfig/)\n![PythonVersion](https://img.shields.io/badge/Python-3.7%20%7E%203.11-informational)\n[![License](https://img.shields.io/github/license/valentingol/cliconfig?color=999)](https://stringfixer.com/fr/MIT_license)\n\n[![Ruff_logo](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)\n[![Black_logo](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n[![Ruff](https://github.com/valentingol/cliconfig/actions/workflows/ruff.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/ruff.yaml)\n[![Flake8](https://github.com/valentingol/cliconfig/actions/workflows/flake.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/flake.yaml)\n[![Pydocstyle](https://github.com/valentingol/cliconfig/actions/workflows/pydocstyle.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/pydocstyle.yaml)\n[![MyPy](https://github.com/valentingol/cliconfig/actions/workflows/mypy.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/mypy.yaml)\n[![PyLint](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/valentingol/ab12676c87f0eaa715bef0f8ad31a604/raw/cliconfig_pylint.json)](https://github.com/valentingol/cliconfig/actions/workflows/pylint.yaml)\n\n[![Tests](https://github.com/valentingol/cliconfig/actions/workflows/tests.yaml/badge.svg)](https://github.com/valentingol/cliconfig/actions/workflows/tests.yaml)\n[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/valentingol/098e9c7c53be88779ee52ef2f2bc8803/raw/cliconfig_tests.json)](https://github.com/valentingol/cliconfig/actions/workflows/tests.yaml)\n[![Documentation Status](https://github.com/valentingol/cliconfig/actions/workflows/pdoc.yaml/badge.svg)](https://valentingol.github.io/cliconfig)\n\nOfficial badge :\n[![Config](https://custom-icon-badges.demolab.com/badge/cliconfig-black?logo=cliconfig)](https://github.com/valentingol/cliconfig)\n\n## Documentation :memo:\n\nHere you can find the [documentation](https://valentingol.github.io/cliconfig) (built with pdoc3).\n\nThe old documentation with readthedocs (1.3.6, not up to date) is also available\n[here](cliconfig.readthedocs.io).\n\n## Pypi :package:\n\nHere you can find the [Pypi page](https://pypi.org/project/cliconfig/).\n\n## Installation :inbox_tray:\n\nIn a new virtual environment, simply install the package with:\n\n```bash\npip install cliconfig\n```\n\nThis package is OS independent and supported on Linux, macOS and Windows.\n\n## Minimal example :rocket:\n\nSee the [*Quick Start*](https://valentingol.github.io/cliconfig/cliconfig.html#quick-start)\nsection of the documentation for a quick overview.\n\nFirst of all, make default config yaml file(s) in your project (configs are merged from left to right).\nThen you can create a config object from these files in python:\n\n```python\n# main.py\nfrom cliconfig import make_config\nconfig = make_config('default1.yaml', 'default2.yaml')\n```\n\nNow launch your script with eventually additional config file(s) and parameters by command line.\nThe additional configs are merged on the default one's then the parameters are set.\n\n```bash\npython main.py --config first.yaml,second.yaml --param1=1 --subconfig.param2='foo'\n```\n\n**By default, these additional configs cannot add new parameters to the default config\n(for security and retro-compatibility reasons).**\n\nSee the [*Edge cases*](https://valentingol.github.io/cliconfig/cliconfig.html#edge-cases)\nsection of the documentation for some edge cases due to implementation.\n\n## Tags :label:\n\nYou can add tags `@<tag_name>` at the end of parameters names to activate some features.\nSee the [*Quick start*](https://valentingol.github.io/cliconfig/cliconfig.html#quick-start)\nsection of the documentation for a quick overview.\n\nThe default tags include:\n\n* `@merge_add`, `@merge_before`, and `@merge_after`: merge other yaml files\n  indicating the path\n* `@copy`: copy another parameter\n* `@def`: safely evaluate an expression to define the parameter value (a lot of\n  operations and functions are available)\n* `@type:<my type>`: try to convert and check the type\n* `@select`: target a sub-config and delete the sub-config in the parent config\n* `@delete`: delete the key from the config\n* `@new`: allow adding parameters that are not present in default config\n* `@dict`: create a dict object that is not a sub-config (see the\n* [*Edge cases*](https://valentingol.github.io/cliconfig/cliconfig.html#edge-cases) section)\n\nIt is also easy to create your own features and possibilities are endless. The way to do\nit are explained in the\n[*Processing*](https://valentingol.github.io/cliconfig/cliconfig.html#processing)\nsection of the documentation.\n\n## How to contribute \ud83d\udc77\n\nFor **development**, install the package dynamically and dev requirements with:\n\n```bash\npip install -e .\npip install -r requirements-dev.txt\n```\n\nEveryone can contribute to CLI Config, and we value everyone\u2019s contributions.\nPlease see our [contributing guidelines](CONTRIBUTING.md) for more information \ud83e\udd17\n\n## License, usage and distribution :scroll:\n\nThis program is free software under the [MIT License](LICENSE).\n\nIt means that:\n\n* If you use this package as a library without modifying it, there is no obligation\n  regarding this license.\n* If you modify the source code of this package, you must keep the original copyright\n  in the source code and add your own. The LICENSE file must also contain the original\n  copyright (and the original MIT license notice if not sublicensed).\n* In any case, you can use this package in open source or closed source projects and for\n  commercial or non-commercial purposes.\n\nCopyright \u00a9 2023 Valentin Goldit\u00e9\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Merge your config files and set parameters from the command line in a simple way.",
    "version": "1.4.4",
    "project_urls": {
        "Source": "https://github.com/valentingol/cliconfig"
    },
    "split_keywords": [
        "cli",
        "config",
        "cliconfig",
        "python",
        "yaml",
        "merge"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e80a4b92c0f7c59d15a65689d9dc5a23fb1fb95e92c06b5a3233c6995c4be945",
                "md5": "c26333eae221a5fc5d66434dc175ef98",
                "sha256": "a46a8a8c91d9905f1155bc2eb0c007de3448942ba8f47a6e1a92ca74bdd4ed7c"
            },
            "downloads": -1,
            "filename": "cliconfig-1.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c26333eae221a5fc5d66434dc175ef98",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 40267,
            "upload_time": "2024-01-12T13:44:34",
            "upload_time_iso_8601": "2024-01-12T13:44:34.286536Z",
            "url": "https://files.pythonhosted.org/packages/e8/0a/4b92c0f7c59d15a65689d9dc5a23fb1fb95e92c06b5a3233c6995c4be945/cliconfig-1.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0aa6e209961949e37401381c172fe5b6a0df9fc5628a889190715a2507c3000",
                "md5": "9239e4f1bb92c9e5ac89963bb1dfc7ed",
                "sha256": "af48a029a4871652d07fa3fbe8ce26dfb66a59b0fecace5cceddae7232453e91"
            },
            "downloads": -1,
            "filename": "cliconfig-1.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "9239e4f1bb92c9e5ac89963bb1dfc7ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 113014,
            "upload_time": "2024-01-12T13:44:36",
            "upload_time_iso_8601": "2024-01-12T13:44:36.604078Z",
            "url": "https://files.pythonhosted.org/packages/f0/aa/6e209961949e37401381c172fe5b6a0df9fc5628a889190715a2507c3000/cliconfig-1.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-12 13:44:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "valentingol",
    "github_project": "cliconfig",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "cliconfig"
}
        
Elapsed time: 0.18871s