Skip to main content

Utilities for hydra-core library

Project description

hydra-utils

test test coverage

Wrapper for (hydra-core to add flexible configuration treatment.

Requirement

  • Python 3.13, 3.12, 3.11, 3.10

Installation

pip install hydra-utils

Usage

@hydra_utils.hydra_wrapper(
    app_name='my_app',
    app_version='0.1.0',
    app_file=__file__,
    config_path='conf',
    config_name='config',
    version_base='1.2',
    verbose=1,
)
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.

It is recommended to define hydra.job.name in your default configuration file (<conf_pth>/<conf_name>.yaml):

hydra:
  job:
    name: my_custom_job_name

Otherwise the job name is utils as hydra detect the file where hydra.main is executed.

There is also wrapper function for to_absolute_path.

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, v0.1.2

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

hydra_utils-0.3.2.tar.gz (77.9 kB view details)

Uploaded Source

Built Distribution

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

hydra_utils-0.3.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file hydra_utils-0.3.2.tar.gz.

File metadata

  • Download URL: hydra_utils-0.3.2.tar.gz
  • Upload date:
  • Size: 77.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for hydra_utils-0.3.2.tar.gz
Algorithm Hash digest
SHA256 f65ac1e510b764459f6ebe5cfb47f1b87ab71ab3e6f83c444b6bedebc07e5dd8
MD5 fce032f235a3b0ce23a9d3d16c31b5c1
BLAKE2b-256 039c98671165dfec9aade6d42ead8eb980111a2fee107ee895550d888fe9b5d0

See more details on using hashes here.

File details

Details for the file hydra_utils-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for hydra_utils-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b0d396ec4078b0aad1af855d7e3c6696bb139eaf2d8d66e8aaa4479f7662d0a
MD5 48edaebf449098eb799e45ab9acfa155
BLAKE2b-256 56cb41a0ef1210ccfea882b9b55883d7bfb66634bee86e4580e82a21cd944fbb

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