omegaconf | The last one | Configuration Management library

 by   omry Python Version: 2.4.0.dev3 License: BSD-3-Clause

kandi X-RAY | omegaconf Summary

kandi X-RAY | omegaconf Summary

omegaconf is a Python library typically used in Devops, Configuration Management applications. omegaconf has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install omegaconf' or download it from GitHub, PyPI.

OmegaConf is a hierarchical configuration system, with support for merging configurations from multiple sources (YAML config files, dataclasses/objects and CLI arguments) providing a consistent API regardless of how the configuration was created.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              omegaconf has a highly active ecosystem.
              It has 1503 star(s) with 83 fork(s). There are 16 watchers for this library.
              There were 3 major release(s) in the last 6 months.
              There are 72 open issues and 427 have been closed. On average issues are closed in 69 days. There are 8 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of omegaconf is 2.4.0.dev3

            kandi-Quality Quality

              omegaconf has 0 bugs and 0 code smells.

            kandi-Security Security

              omegaconf has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              omegaconf code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              omegaconf is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              omegaconf releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              It has 19188 lines of code, 1193 functions and 75 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed omegaconf and discovered the below as its top functions. This is intended to give you an instant insight into omegaconf implemented functionality, and help decide if they suit your requirements.
            • Update the value of a key in the cfg
            • Parse the given value into a grammar rule
            • Split a key into a list
            • Merge multiple configs together
            • Merge this container with other
            • Return the type of the given class or object
            • Parse a config value
            • Convert a Config object to a dict
            • Return the content of the configuration
            • Return a tuple containing the value of a key
            • Convert a Config object into a dictionary
            • Dereference the node
            • Insert an item into the list
            • Removes a value from the config
            • Safely merge two configs
            • Update a key in a nested dict
            • Mark a key as deprecated
            • Visit the interpolation node
            • Merge two configurations
            • Clean up files and directories
            • Sort the list
            • Removes the value at index
            • Visit interpolation resolver
            • Return the resolver name as a string
            • Test notebook on Python 3
            • Convert a configuration object into a python object
            • Convert a Config object into a dict
            • Invalidate flags cache
            • Decode the given expression into a Python value
            • Gets a value from the list
            • Test whether a key is in the config file
            • Merge this container into another container
            Get all kandi verified functions for this library.

            omegaconf Key Features

            No Key Features are available at this moment for omegaconf.

            omegaconf Examples and Code Snippets

            lightning_cli_advanced_2.rst
            Pythondot img1Lines of Code : 83dot img1no licencesLicense : No License
            copy iconCopy
            import torch
            from unittest import mock
            from typing import List
            import pytorch_lightning.cli as pl_cli
            from pytorch_lightning import LightningModule, LightningDataModule, Trainer, Callback
            
            
            class NoFitTrainer(Trainer):
                def fit(self, *_, **__):
                
            How to install,How to use
            Pythondot img2Lines of Code : 70dot img2License : Permissive (MIT)
            copy iconCopy
            from monet_pytorch import Monet
            
            monet = Monet.from_config(model='monet')
            
            from monet_pytorch import Monet
            
            monet = Monet.from_config(model='monet', dataset='tetrominoes')
            
            from monet_pytorch import Monet
            
            monet = Monet.from_config(model='monet', dat  
            copy iconCopy
            python my_scripy.py MY_PATHS="[a,b,c]"
            
            conf = OmegaConf.structured(ConfDef())
            cli_conf = OmegaConf.from_cli()
            conf = OmegaConf.merge(conf, cli_conf)
            print("\n\nCONFIGURATION:")
            print(OmegaConf.to_yaml(conf), end="\
            use data types or other library-specific variables as arguments in hydra
            Pythondot img4Lines of Code : 34dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # config.yaml
            
            arg1: numpy.float32  # note: use "numpy" here, not "np"
            arg2: tensorflow.float16
            
            # python code
            ...
            from hydra.utils import get_class
            arg1 = get_class(config.arg1)
            arg2 = get_class(config.arg2)
            
            Using Typer and Hydra together
            Pythondot img5Lines of Code : 44dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            with initialize(config_path="conf", job_name="test_app"):
                cfg = compose(config_name="config", overrides=["db=mysql", "db.user=me"])
            
            from typing import List, Optional
            
            import typer
            from omegaconf import OmegaCon
            ModuleNotFoundError: No module named 'taming'
            Pythondot img6Lines of Code : 2dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            pip install taming-transformers
            
            Get original Hydra configuration from instantiated config
            Pythondot img7Lines of Code : 54dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # conf.yaml
            _target_: app.ClassA
            foo: bar
            model:
              _target_: app.ClassB
              hello: world
            modelconf: "${remove_target: ${.model}}"
            
            # app.py
            import hydra
            from omegaconf import DictConfig, OmegaConf
            
            
            class ClassB:
                
            read variables resolved with `oc.env` as integer in hydra
            Pythondot img8Lines of Code : 3dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            var1: 42
            var2: ${oc.decode:${oc.env:PROJECT_NUMBER}}
            
            Hydra: access name of config file from code
            Pythondot img9Lines of Code : 27dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # my_app.py
            import hydra
            from pprint import pprint
            from hydra.core.hydra_config import HydraConfig
            from omegaconf import OmegaConf
            
            @hydra.main(config_path=".", config_name="config")
            def main(config):
                hydra_cfg = HydraConfig.get()
                
            copy iconCopy
            # my_app.py
            import hydra
            import hydra.utils as hu
            
            from omegaconf import OmegaConf
            
            def resolve_tuple(*args):
                return tuple(args)
            
            OmegaConf.register_new_resolver('as_tuple', resolve_tuple)
            
            @hydra.main(config_path='conf', config_name='

            Community Discussions

            QUESTION

            How to get the file path of a loaded OmegaConf configuration
            Asked 2022-Mar-30 at 12:36

            I am using OmegaConf to read a .yaml configuration file (file path is given through hydra). After I edit it, I want to save the file again. Possibly using:

            ...

            ANSWER

            Answered 2022-Mar-30 at 12:36

            This is not supported. Hydra abstracts away the config files it loads. In fact - those config files may exist inside Python packages, the file system or arbitrary locations backed by specialized plugins.

            Source https://stackoverflow.com/questions/71675070

            QUESTION

            override complete config for submodule with hydra
            Asked 2022-Feb-25 at 18:03

            So, I have a hydra model config (autoencoder.yaml) defined as:

            ...

            ANSWER

            Answered 2022-Feb-25 at 18:03

            When modifying the defaults list, use a slash ('/') instead of a period ('.') as the separator for path components:

            Source https://stackoverflow.com/questions/71258632

            QUESTION

            How to provide a List/Tuple/Collection to OmegaConf's structured config from Command Line Interface (CLI)?
            Asked 2022-Feb-21 at 23:12

            I am using OmegaConf's structured config system in order to get a convenient, strongly typed way of configuring my Python application, since it takes very few lines of code and allows merging confs from source, filesystem and CLI. This is defined through a ConfDef class like the one below.

            Now, I want to provide a parameter as a collection of, say, strings. While the OmegaConf documentation addresses how should the ConfDef look like, no details about the CLI interaction are provided. Hence the question:

            How can we provide a collection of values when calling the Python app from CLI using structured OmegaConf?

            I am using Ubuntu20.04, but generic approaches if existing would be preferred.

            ...

            ANSWER

            Answered 2022-Feb-21 at 23:12
            In Linux bash, we are expected to provide the collection in the form:

            Source https://stackoverflow.com/questions/71213904

            QUESTION

            Documentation of Hydra Config
            Asked 2022-Feb-15 at 02:47

            Hydra provides a way to dynamically create a hierarchical configuration by composition and override it through config files and the command line, leveraging OmegaConf. I look for a recommended way to document the parameters but I could not find (a documented) one. What are best practices for that? Coming from argparse, I like the way of documenting the parameter inline, i.e. close to the code.

            ...

            ANSWER

            Answered 2022-Feb-15 at 02:47

            Excellent question! The answer is: parameter-by-parameter documentation is not yet implemented (as of Hydra v1.1, OmegaConf v2.1).

            The future plans are:

            • in OmegaConf, expose an API allowing users to attach documentation (and other metadata) to each field of a structured config. See this open OmegaConf issue.
            • Once the above is complete, implement a Hydra feature allowing a parameter-specific help messages to be printed based on the parameter's metadata. See this open Hydra issue.

            For now, the best we can do is to customize the general application help message (i.e. the --help command line flag).

            Source https://stackoverflow.com/questions/71115798

            QUESTION

            Is it possible to use Pydantic instead of dataclasses in Structured Configs in hydra-core python package?
            Asked 2022-Feb-12 at 20:43

            Recently I have started to use hydra to manage the configs in my application. I use Structured Configs to create schema for .yaml config files. Structured Configs in Hyda uses dataclasses for type checking. However, I also want to use some kind of validators for some of the parameter I specify in my Structured Configs (something like this).

            Do you know if it is somehow possible to use Pydantic for this purpose? When I try to use Pydantic, OmegaConf complains about it:

            ...

            ANSWER

            Answered 2022-Jan-10 at 05:58

            See pydantic.dataclasses.dataclass, which are a drop-in replacement for the standard-library dataclasses with some extra type-checking.

            Source https://stackoverflow.com/questions/70639556

            QUESTION

            Custom resolver to select a field from a DictConfig
            Asked 2022-Feb-09 at 16:38
            nodes:
              node1: 1
              node2: 2
              node3: 3
            
            selected_node: ${subfield:${nodes},node1}
            
            ...

            ANSWER

            Answered 2022-Feb-09 at 16:38

            I managed to solve this using the implementation below.

            It would be better to avoid importing the private interface omegaconf._impl, but I haven't yet found a way to do that.

            Source https://stackoverflow.com/questions/71038681

            QUESTION

            Using Typer and Hydra together
            Asked 2022-Jan-24 at 09:28

            I have a simple Typer application:

            ...

            ANSWER

            Answered 2022-Jan-24 at 09:28

            The compose function accepts an optional list of override strings:

            Source https://stackoverflow.com/questions/70811640

            QUESTION

            How to set up hydra config to accept a custom enum?
            Asked 2021-Dec-16 at 18:08

            How do I set up a my hydra config to accept a custom enum? Specifically I followed the Structured Config Schema tutorial.

            I have a dataclass config:

            ...

            ANSWER

            Answered 2021-Dec-16 at 17:46

            Note the error message: Invalid value 'enum1', expected one of [ENUM1, ENUM2].

            This is to say, in your data/config.yaml file, you should be using ENUM1 instead of enum1.

            Source https://stackoverflow.com/questions/70373670

            QUESTION

            ModuleNotFoundError: No module named 'taming'
            Asked 2021-Dec-16 at 12:20
            ModuleNotFoundError                       Traceback (most recent call last)
             in 
                 16 from omegaconf import OmegaConf
                 17 from PIL import Image
            ---> 18 from taming.models import cond_transformer, vqgan
                 19 import taming.modules
                 20 import torch
            
            ModuleNotFoundError: No module named 'taming'
            
            ...

            ANSWER

            Answered 2021-Dec-16 at 12:20

            Try the following command:

            Source https://stackoverflow.com/questions/69983020

            QUESTION

            read variables resolved with `oc.env` as integer in hydra
            Asked 2021-Nov-24 at 01:31

            In my project, I'm setting an environment variables using python-dotenv. I then reference it in my YAML using the co.env OmegaConf resolver.

            ...

            ANSWER

            Answered 2021-Nov-24 at 01:31

            You can use oc.decode to decode to get it as a number.

            Something like:

            Source https://stackoverflow.com/questions/70088278

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install omegaconf

            You can install using 'pip install omegaconf' or download it from GitHub, PyPI.
            You can use omegaconf like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install omegaconf

          • CLONE
          • HTTPS

            https://github.com/omry/omegaconf.git

          • CLI

            gh repo clone omry/omegaconf

          • sshUrl

            git@github.com:omry/omegaconf.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Configuration Management Libraries

            dotfiles

            by mathiasbynens

            consul

            by hashicorp

            viper

            by spf13

            eureka

            by Netflix

            confd

            by kelseyhightower

            Try Top Libraries by omry

            banana

            by omryJava

            snapdump

            by omryPython

            hydra-article-code

            by omryPython

            hydra-torch-config

            by omryPython