hydra-utils


Namehydra-utils JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryUtilities for hydra-core library
upload_time2025-01-27 07:46:53
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.10
licenseNone
keywords hydra hydra-core hydra-utils
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # hydra-utils

[![test](https://github.com/rcmdnk/hydra-utils/actions/workflows/test.yml/badge.svg)](https://github.com/rcmdnk/hydra-utils/actions/workflows/test.yml)
[![test coverage](https://img.shields.io/badge/coverage-check%20here-blue.svg)](https://github.com/rcmdnk/hydra-utils/tree/coverage)

Wrapper for ([hydra-core](https://pypi.org/project/hydra-core/) to add flexible configuration treatment.

## Requirement

- Python 3.13, 3.12, 3.11, 3.10

## Installation

```bash
pip install hydra-utils
```

## Usage

```python
@hydra_utils.hydra_wrapper(
    app_name='my_app',
    app_version='0.1.0',
    app_file=__file__,
    conf_path='conf',
    conf_name='config',
    version_base='1.2',
)
def main(conf: dict[Any, Any]) -> None: ...


if __name__ == '__main__':
    main()
```

- `app_name` and `app_version` are used to log information of current version.
  - It is useful if app_version is set to `__version__` of the app.
- `app_file` is used to check the file place's git status to log the git commit hash and diff from the last commit.
- The argument which the main function takes is `dict[Any, Any]` instead of `DictConfig`.
- Configuration file can be passed by the first argument or `conf_file=...` at the command line, which will be merged to the configuration file specified by conf_path and conf_name.
- Configuration file can have `include` keyword which has the list of configuration files to include.
  - Included files are merged to the main configuration file.
  - It is resolved at the place of `include`. If the main file has other configurations after the `include`, they will overwrite the included configurations.
- `n_jobs` is fixed to the number of CPUs.
  - It is used to set the number of jobs for parallel processing.
  - If `n_jobs` is set to 0 or 1, it is set to 1.
  - If `n_jobs` is set to -1, it is set to the number of logical cores.
  - If `n_jobs` is set to None, it is set to the number of physical cores.
  - If `n_jobs` is set to a negative number, it is set to the number of logical cores + 1 + n_jobs, i.e. -1 is the same as the number of logical cores.

There is also wrapper function for `to_absolute_path`.

```python
from hydra_utils import to_absolute_path
```

- It returns empty string if the input is empty.
- It returns the input as is if the input includes `:` (e.g., `http://`, `s3://`, ...).

Based on [rcmdnk/python-template](https://github.com/rcmdnk/python-template), v0.1.2

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hydra-utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.10",
    "maintainer_email": null,
    "keywords": "hydra, hydra-core, hydra-utils",
    "author": null,
    "author_email": "rcmdnk <rcmdnk@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d6/db/5134004cb34a3ae3c5be0cfc30d6d025e7d1b9f8f900bcc6bc751ee58f47/hydra_utils-0.2.1.tar.gz",
    "platform": null,
    "description": "# hydra-utils\n\n[![test](https://github.com/rcmdnk/hydra-utils/actions/workflows/test.yml/badge.svg)](https://github.com/rcmdnk/hydra-utils/actions/workflows/test.yml)\n[![test coverage](https://img.shields.io/badge/coverage-check%20here-blue.svg)](https://github.com/rcmdnk/hydra-utils/tree/coverage)\n\nWrapper for ([hydra-core](https://pypi.org/project/hydra-core/) to add flexible configuration treatment.\n\n## Requirement\n\n- Python 3.13, 3.12, 3.11, 3.10\n\n## Installation\n\n```bash\npip install hydra-utils\n```\n\n## Usage\n\n```python\n@hydra_utils.hydra_wrapper(\n    app_name='my_app',\n    app_version='0.1.0',\n    app_file=__file__,\n    conf_path='conf',\n    conf_name='config',\n    version_base='1.2',\n)\ndef main(conf: dict[Any, Any]) -> None: ...\n\n\nif __name__ == '__main__':\n    main()\n```\n\n- `app_name` and `app_version` are used to log information of current version.\n  - It is useful if app_version is set to `__version__` of the app.\n- `app_file` is used to check the file place's git status to log the git commit hash and diff from the last commit.\n- The argument which the main function takes is `dict[Any, Any]` instead of `DictConfig`.\n- Configuration file can be passed by the first argument or `conf_file=...` at the command line, which will be merged to the configuration file specified by conf_path and conf_name.\n- Configuration file can have `include` keyword which has the list of configuration files to include.\n  - Included files are merged to the main configuration file.\n  - It is resolved at the place of `include`. If the main file has other configurations after the `include`, they will overwrite the included configurations.\n- `n_jobs` is fixed to the number of CPUs.\n  - It is used to set the number of jobs for parallel processing.\n  - If `n_jobs` is set to 0 or 1, it is set to 1.\n  - If `n_jobs` is set to -1, it is set to the number of logical cores.\n  - If `n_jobs` is set to None, it is set to the number of physical cores.\n  - If `n_jobs` is set to a negative number, it is set to the number of logical cores + 1 + n_jobs, i.e. -1 is the same as the number of logical cores.\n\nThere is also wrapper function for `to_absolute_path`.\n\n```python\nfrom hydra_utils import to_absolute_path\n```\n\n- It returns empty string if the input is empty.\n- It returns the input as is if the input includes `:` (e.g., `http://`, `s3://`, ...).\n\nBased on [rcmdnk/python-template](https://github.com/rcmdnk/python-template), v0.1.2\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Utilities for hydra-core library",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/rcmdnk/hydra-utils",
        "Repository": "https://github.com/rcmdnk/hydra-utils"
    },
    "split_keywords": [
        "hydra",
        " hydra-core",
        " hydra-utils"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "352c3c441b2d69a0a082edaf3d436d4b7c8f40060da68edbd938be92b9e190bd",
                "md5": "b2ad894cc76de8c2d4d9b29e406a3c86",
                "sha256": "638992a3b8d1cd1052eb3b3255e383861b57bef4bc84f82f658614c285c4f537"
            },
            "downloads": -1,
            "filename": "hydra_utils-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b2ad894cc76de8c2d4d9b29e406a3c86",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.10",
            "size": 9976,
            "upload_time": "2025-01-27T07:46:51",
            "upload_time_iso_8601": "2025-01-27T07:46:51.582612Z",
            "url": "https://files.pythonhosted.org/packages/35/2c/3c441b2d69a0a082edaf3d436d4b7c8f40060da68edbd938be92b9e190bd/hydra_utils-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d6db5134004cb34a3ae3c5be0cfc30d6d025e7d1b9f8f900bcc6bc751ee58f47",
                "md5": "1a5ad0ac981639f9c63b0d4ce217fbb4",
                "sha256": "aa98ad9160fa3d758ad4a61242783501878f52af12623994968ad9f1d3a41b17"
            },
            "downloads": -1,
            "filename": "hydra_utils-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1a5ad0ac981639f9c63b0d4ce217fbb4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.10",
            "size": 84512,
            "upload_time": "2025-01-27T07:46:53",
            "upload_time_iso_8601": "2025-01-27T07:46:53.010903Z",
            "url": "https://files.pythonhosted.org/packages/d6/db/5134004cb34a3ae3c5be0cfc30d6d025e7d1b9f8f900bcc6bc751ee58f47/hydra_utils-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-27 07:46:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rcmdnk",
    "github_project": "hydra-utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "hydra-utils"
}
        
Elapsed time: 1.28206s