repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
omegaconf
omegaconf/grammar_parser.py
.py
import re import threading from typing import Any from .errors import GrammarParseError # Import from visitor in order to check the presence of generated grammar files # files in a single place. from .grammar_visitor import ( # type: ignore OmegaConfGrammarLexer, OmegaConfGrammarParser, ) from .typing import...
149
5,691
omegaconf
omegaconf/_impl.py
.py
from typing import Any from omegaconf import Container, DictConfig, ListConfig, Node, TupleConfig, ValueNode from omegaconf.errors import ( ConfigKeyError, ConfigTypeError, InterpolationToMissingValueError, ) from omegaconf.nodes import InterpolationResultNode from ._utils import ( _DEFAULT_MARKER_, ...
133
3,983
omegaconf
omegaconf/__init__.py
.py
from .base import Container, DictKeyType, Node, SCMode, UnionNode from .dictconfig import DictConfig from .errors import ( KeyValidationError, MissingMandatoryValue, ReadonlyConfigError, UnsupportedValueType, ValidationError, ) from .listconfig import ListConfig from .nodes import ( AnyNode, ...
72
1,337
omegaconf
omegaconf/version.py
.py
import sys # pragma: no cover # Managed by bump-my-version; see pyproject.toml for bump commands. __version__ = "2.4.0.dev16" msg = """OmegaConf 2.4 and above is compatible with Python 3.10 and newer. You have the following options: 1. Upgrade to Python 3.10 or newer. This is highly recommended. new features will...
16
519
omegaconf
omegaconf/listconfig.py
.py
import copy import operator from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, List, MutableSequence, Optional, Tuple, Type, Union, ) if TYPE_CHECKING: from .tupleconfig import TupleConfig from ._utils import ( ValueKind, _get_value...
688
24,976
omegaconf
omegaconf/omegaconf.py
.py
"""OmegaConf module""" import copy import functools import inspect import io import os import pathlib import re import sys import warnings from collections import defaultdict from contextlib import contextmanager, nullcontext from enum import Enum from textwrap import dedent from typing import ( IO, Annotated,...
2,118
77,930
omegaconf
omegaconf/_yaml.py
.py
import os import pathlib import re from typing import Any, Dict, Optional import yaml try: from yaml import CSafeLoader BaseLoader = CSafeLoader except ImportError: # pragma: no cover BaseLoader = yaml.SafeLoader # This URL is also spelled out in public OmegaConf docstrings so IDE/help() views # show i...
311
12,200
omegaconf
omegaconf/tupleconfig.py
.py
import copy import operator from collections.abc import Sequence from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Union from ._utils import ( ValueKind, _get_value, _is_missing_literal, _is_none, _resolve_optional, format_and_raise, get_tuple_item_types, get_valu...
523
19,525
omegaconf
omegaconf/dictconfig.py
.py
import copy import difflib from enum import Enum from typing import ( Any, Dict, ItemsView, Iterable, Iterator, KeysView, List, MutableMapping, Optional, Sequence, Tuple, Type, Union, ) from ._utils import ( _DEFAULT_MARKER_, ValueKind, _get_value, _i...
824
29,919
omegaconf
omegaconf/base.py
.py
import copy import sys from abc import ABC, abstractmethod from collections import defaultdict from dataclasses import dataclass, field from enum import Enum from typing import ( Any, Dict, Iterator, List, NoReturn, Optional, Set, Tuple, Type, Union, ) from ._utils import ( ...
1,275
45,294
omegaconf
omegaconf/basecontainer.py
.py
import copy import sys from abc import ABC, abstractmethod from enum import Enum from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Tuple, Union import yaml from ._utils import ( _DEFAULT_MARKER_, ValueKind, _ensure_container, _find_eq, _get_value, _is_interpolation, _i...
1,227
47,142
omegaconf
omegaconf/resolvers/__init__.py
.py
from omegaconf.resolvers import oc __all__ = [ "oc", ]
6
60
omegaconf
omegaconf/resolvers/oc/__init__.py
.py
import os import string import warnings from typing import Any, Optional from omegaconf import Container, Node from omegaconf._utils import _DEFAULT_MARKER_, _get_value from omegaconf.basecontainer import BaseContainer from omegaconf.errors import ConfigKeyError from omegaconf.grammar_parser import parse from omegacon...
114
3,548
omegaconf
omegaconf/resolvers/oc/dict.py
.py
from typing import Any, List from omegaconf import AnyNode, Container, DictConfig, ListConfig from omegaconf._utils import Marker from omegaconf.basecontainer import BaseContainer from omegaconf.errors import ConfigKeyError _DEFAULT_SELECT_MARKER_: Any = Marker("_DEFAULT_SELECT_MARKER_") def keys( key: str, ...
84
2,324
omegaconf
docs/source/conf.py
.py
# type: ignore # -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ---------------------------------------------...
174
5,208
omegaconf
subprojects/omegaconf-pydevd/setup.py
.py
# type: ignore import pathlib import re import setuptools ROOT = pathlib.Path(__file__).parent.resolve() def find_version(*file_paths: str) -> str: with open(ROOT / pathlib.Path(*file_paths), "r", encoding="utf-8") as fp: version_file = fp.read() version_match = re.search(r"^__version__ = ['\"]([^'\...
60
1,806
omegaconf
subprojects/omegaconf-pydevd/version.py
.py
# Managed by bump-my-version; see pyproject.toml for bump commands. __version__ = "2.4.0.dev16"
3
96
omegaconf
subprojects/omegaconf-pydevd/pydevd_plugins/__init__.py
.py
try: __import__("pkg_resources").declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__)
7
160
omegaconf
subprojects/omegaconf-pydevd/pydevd_plugins/extensions/pydevd_plugin_omegaconf.py
.py
# based on https://github.com/fabioz/PyDev.Debugger/tree/main/pydevd_plugins/extensions import os import sys from typing import Any, Dict from _pydevd_bundle.pydevd_extension_api import ( # type: ignore StrPresentationProvider, TypeResolveProvider, ) DEBUG = False def print_debug(msg: str) -> None: # prag...
127
4,251
omegaconf
subprojects/omegaconf-pydevd/tests/test_pydev_resolver_plugin.py
.py
import builtins from enum import Enum from typing import Any from pydevd_plugins.extensions.pydevd_plugin_omegaconf import ( OmegaConfDeveloperResolver, OmegaConfUserResolver, ) from pytest import fixture, mark, param from omegaconf import ( AnyNode, BooleanNode, BytesNode, Container, Dict...
269
7,513
omegaconf
subprojects/omegaconf-pydevd/tests/test_pydevd_plugin_namespace.py
.py
import json import os import subprocess import sys from pathlib import Path OLD_NAMESPACE_INIT = """import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) """ FAKE_PKG_RESOURCES = """_namespaces = set() def _package_paths(name): import os import sys relpath = os.path.join(*name.split("."))...
241
7,004
omegaconf
subprojects/omegaconf-pydevd/examples/debug_demo.py
.py
from omegaconf import OmegaConf cfg = OmegaConf.create( { "name": "OmegaConf", "release": "???", "greeting": "Hello ${name}", "subprojects": { "omegaconf-pydevd": { "version": "???", "status": "debugger plugin", } }, ...
24
502
omegaconf
tests/test_merge.py
.py
import copy import re import sys from contextlib import AbstractContextManager from dataclasses import dataclass, field from textwrap import dedent from typing import ( Any, Dict, List, MutableMapping, MutableSequence, Optional, Tuple, Union, ) from pytest import mark, param, raises, wa...
1,872
56,538
omegaconf
tests/test_struct.py
.py
import re from typing import Any, Dict from pytest import mark, raises from omegaconf import OmegaConf from omegaconf.errors import ConfigKeyError def test_struct_default() -> None: c = OmegaConf.create() assert OmegaConf.is_struct(c) is None def test_struct_set_on_dict() -> None: c = OmegaConf.create...
72
1,960
omegaconf
tests/test_basic_ops_dict.py
.py
# -*- coding: utf-8 -*- import copy import re import tempfile from contextlib import nullcontext from typing import Any, Dict, List, Optional, Union from pytest import mark, param, raises from omegaconf import ( MISSING, AnyNode, DictConfig, DictKeyType, ListConfig, MissingMandatoryValue, ...
1,337
40,369
omegaconf
tests/test_nodes.py
.py
import copy import functools import re import sys from enum import Enum from functools import partial from pathlib import Path from typing import Any, Callable, Dict, Literal, Tuple, Type, Union from pytest import fixture, mark, param, raises from omegaconf import ( AnyNode, BooleanNode, BytesNode, Di...
1,140
36,530
omegaconf
tests/test_errors.py
.py
import gc import re from dataclasses import dataclass from enum import Enum from pathlib import Path from textwrap import dedent from typing import Any, Callable, Dict, List, Optional, Type, Union from pytest import mark, param, raises, warns import tests from omegaconf import ( BytesNode, DictConfig, Flo...
1,995
66,397
omegaconf
tests/test_update.py
.py
from typing import Any, Union from pytest import mark, param, raises from omegaconf import DictConfig, ListConfig, OmegaConf, ValidationError from omegaconf._utils import _ensure_container, is_primitive_container from omegaconf.errors import ( ConfigAttributeError, ConfigKeyError, ConfigTypeError, Int...
556
16,483
omegaconf
tests/test_grammar.py
.py
import math import re import threading import time from contextlib import nullcontext from typing import Any, Callable, List, Optional, Set, Tuple from pytest import mark, param, raises, warns from omegaconf import ( AnyNode, Container, DictConfig, ListConfig, OmegaConf, _utils, grammar_pa...
834
33,951
omegaconf
tests/test_unions.py
.py
from dataclasses import dataclass, field from pathlib import Path from typing import Any, Dict, List, Literal, Union from pytest import mark, param, raises from omegaconf import OmegaConf, UnionNode, ValidationError from omegaconf._utils import _get_value, get_type_hint from tests import Color @dataclass class Lite...
172
5,144
omegaconf
tests/test_basic_ops_tuple.py
.py
import copy import pickle from collections.abc import MutableSequence, Sequence from typing import Any, Optional, Tuple from pytest import mark, param, raises from omegaconf import ( MISSING, DictConfig, ListConfig, Node, OmegaConf, TupleConfig, ValidationError, ) from omegaconf.errors imp...
412
12,802
omegaconf
tests/test_get_full_key.py
.py
from typing import Any, Union from pytest import mark, param from omegaconf import DictConfig, IntegerNode, OmegaConf, UnionNode from tests import Color @mark.parametrize( "cfg, select, key, expected", [ ({}, "", "a", "a"), # 1 # dict ({"a": 1}, "", "a", "a"), ({"a": ...
133
4,485
omegaconf
tests/test_to_yaml.py
.py
import platform from pathlib import Path from textwrap import dedent from typing import Any, Literal, Optional import yaml from pytest import mark from omegaconf import DictConfig, EnumNode, ListConfig, LiteralNode, OmegaConf, _utils from tests import Enum1, User @mark.parametrize( "input_, expected", [ ...
222
6,399
omegaconf
tests/test_nested_containers.py
.py
import copy import re from typing import Any, Dict, List, Optional, Union from pytest import mark, param, raises from omegaconf import ( MISSING, Container, DictConfig, IntegerNode, KeyValidationError, ListConfig, Node, OmegaConf, ValidationError, ) from omegaconf._utils import ( ...
1,444
43,731
omegaconf
tests/test_structured_config_unions.py
.py
import copy import pickle from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import attr from pytest import mark, param, raises from omegaconf import ( MISSING, DictConfig, OmegaConf, UnionNode, ValidationError, open_dict, ) from omegaconf._utils impor...
615
16,100
omegaconf
tests/test_container_unions.py
.py
""" Tests for Union[List[...], Dict[...], ...] support (issue #1261). """ import copy import pickle from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Tuple, Union from pytest import mark, param, raises from omegaconf import OmegaConf, ReadonlyConfigError, TupleConfig, ValidationE...
560
19,494
omegaconf
tests/__init__.py
.py
import re from dataclasses import dataclass, field from enum import Enum from typing import Any, Dict, Generic, List, NamedTuple, Optional, Tuple, TypeVar, Union import attr from pytest import warns from omegaconf import II, MISSING class IllegalType: def __init__(self) -> None: pass def __eq__(sel...
345
6,799
omegaconf
tests/test_base_config.py
.py
import copy from contextlib import nullcontext from typing import Any, Dict, List, Optional, Union from pytest import mark, param, raises from omegaconf import ( AnyNode, Container, DictConfig, DictKeyType, IntegerNode, ListConfig, OmegaConf, ReadonlyConfigError, StringNode, Un...
742
22,773
omegaconf
tests/test_tuple_structured.py
.py
from dataclasses import dataclass, field from types import GenericAlias from typing import Any, List, NamedTuple, Optional, Tuple import attr from pytest import mark, param, raises from typing_extensions import TypeVarTuple, Unpack from omegaconf import MISSING, ListConfig, OmegaConf, TupleConfig, ValidationError @...
206
6,551
omegaconf
tests/test_basic_ops_list.py
.py
# -*- coding: utf-8 -*- import re from contextlib import AbstractContextManager, nullcontext from pathlib import Path from textwrap import dedent from typing import Any, Callable, List, MutableSequence, Optional, Union from pytest import mark, param, raises from omegaconf import ( MISSING, AnyNode, DictCo...
1,278
34,533
omegaconf
tests/test_create.py
.py
"""Testing for OmegaConf""" import platform import re import sys from collections import OrderedDict from collections.abc import Sequence from dataclasses import dataclass from pathlib import Path from textwrap import dedent from typing import Any, Dict, List, Optional import attr import yaml from pytest import mark,...
784
22,816
omegaconf
tests/test_readonly.py
.py
import re from typing import Any, Callable, Dict, List, Union from pytest import mark, param, raises from omegaconf import DictConfig, ListConfig, OmegaConf, ReadonlyConfigError @mark.parametrize( "src, func, expectation", [ param( {}, lambda c: c.__setitem__("a", 1), ...
240
6,946
omegaconf
tests/test_tuple_integration.py
.py
from dataclasses import dataclass from typing import Any, Dict, Tuple from pytest import raises from omegaconf import MISSING, DictConfig, Node, OmegaConf, TupleConfig, read_write from omegaconf.errors import ConfigTypeError, InterpolationToMissingValueError @dataclass class TupleObject: values: Tuple[int, str]...
187
5,905
omegaconf
tests/test_select.py
.py
from contextlib import AbstractContextManager from typing import Any, Optional, Union from pytest import mark, param, raises, warns from omegaconf import DictConfig, ListConfig, MissingMandatoryValue, OmegaConf from omegaconf._impl import select_value from omegaconf._utils import _ensure_container from omegaconf.erro...
444
17,052
omegaconf
tests/test_config_eq.py
.py
from dataclasses import dataclass, field from typing import Any, List import attr from pytest import mark, param from omegaconf import MISSING, AnyNode, DictConfig, ListConfig, OmegaConf from tests import Group, User @mark.parametrize( "i1,i2", [ # === LISTS === # empty list param([]...
430
14,714
omegaconf
tests/test_compare_dictconfig_vs_dict.py
.py
""" This file compares DictConfig methods with the corresponding methods of standard python's dict. The following methods are compared: __contains__ __delitem__ __eq__ __getitem__ __setitem__ get pop keys values items We have separate test classes for the following cases: Te...
657
22,483
omegaconf
tests/test_to_container.py
.py
import re from enum import Enum from importlib import import_module from typing import Any, Callable, Dict, List, Optional from pytest import fixture, mark, param, raises from omegaconf import ( DictConfig, ListConfig, MissingMandatoryValue, OmegaConf, SCMode, open_dict, ) from omegaconf._util...
774
26,783
omegaconf
tests/test_matrix.py
.py
import copy import re from pathlib import Path from typing import Any, Optional, Union from pytest import mark, raises, warns from omegaconf import ( BooleanNode, BytesNode, DictConfig, EnumNode, FloatNode, IntegerNode, ListConfig, OmegaConf, PathNode, StringNode, UnionNode...
411
12,901
omegaconf
tests/test_serialization.py
.py
# -*- coding: utf-8 -*- import copy import io import os import pathlib import pickle import tempfile from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Type, Union import yaml from pytest import mark, param, raises from omegaconf import MISSING, DictConfig, ListConfig, Node, OmegaConf, U...
483
13,267
omegaconf
tests/test_utils.py
.py
import re import sys from collections import OrderedDict from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union import attr from pytest import mark, param, raises from omegaconf import DictConfig, ListConfig...
1,695
57,350
omegaconf
tests/test_omegaconf.py
.py
import pathlib import platform from contextlib import nullcontext from pathlib import Path from typing import Any, Union from pytest import mark, param, raises from omegaconf import ( MISSING, BooleanNode, BytesNode, DictConfig, EnumNode, FloatNode, IntegerNode, ListConfig, Missing...
810
24,829
omegaconf
tests/test_tuple_merge.py
.py
from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Tuple from pytest import mark, raises from omegaconf import ( DictConfig, ListConfig, OmegaConf, TupleConfig, ValidationError, ) from omegaconf.basecontainer import _deep_update_type_hint from omegaconf.errors i...
164
4,849
omegaconf
tests/conftest.py
.py
import copy from typing import Any from pytest import fixture from omegaconf import OmegaConf from omegaconf.basecontainer import BaseContainer @fixture(scope="function") def restore_resolvers() -> Any: """ A fixture to restore singletons state after this the function. This is useful for functions that ...
36
962
omegaconf
tests/structured_conf/test_structured_basic.py
.py
import re import sys from importlib import import_module from typing import Any, Optional from pytest import fixture, mark, param, raises from omegaconf import ( DictConfig, IntegerNode, Node, OmegaConf, ValidationError, _utils, flag_override, ) from omegaconf._utils import _is_optional, g...
731
27,630
omegaconf
tests/structured_conf/test_structured_config.py
.py
import dataclasses import inspect import pathlib import re import sys from contextlib import AbstractContextManager from enum import Enum from importlib import import_module from pathlib import Path from types import LambdaType from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, TypeVar, Union from...
2,664
92,265
omegaconf
tests/structured_conf/data/dataclasses.py
.py
import dataclasses import sys from dataclasses import dataclass, field from pathlib import Path from typing import Any, Dict, List, Literal, Optional, Tuple, Union, cast from pytest import importorskip from omegaconf import II, MISSING, SI from tests import Color, Enum1 if sys.version_info >= (3, 8): # pragma: no c...
944
23,625
omegaconf
tests/structured_conf/data/dataclasses_pre_311.py
.py
import dataclasses import sys from dataclasses import dataclass, field from pathlib import Path from typing import Any, Dict, List, Literal, Optional, Tuple, Union, cast from pytest import importorskip from omegaconf import II, MISSING, SI from tests import Color, Enum1 if sys.version_info >= (3, 8): # pragma: no c...
942
23,434
omegaconf
tests/structured_conf/data/attr_classes.py
.py
import sys from pathlib import Path from typing import Any, Dict, List, Literal, Optional, Tuple, Union, cast import attr from pytest import importorskip from omegaconf import II, MISSING, SI from tests import Color, Enum1 if sys.version_info >= (3, 8): # pragma: no cover from typing import TypedDict # attr is...
897
22,487
omegaconf
tests/interpolation/__init__.py
.py
from typing import Any from omegaconf import Container, Node def dereference_node(cfg: Container, key: Any) -> Node: node = cfg._get_node(key) assert isinstance(node, Node) node = node._dereference_node() assert isinstance(node, Node) return node
12
270
omegaconf
tests/interpolation/test_interpolation.py
.py
import copy import re from pathlib import Path from textwrap import dedent from typing import Any, Tuple, Union from pytest import mark, param, raises from omegaconf import ( II, SI, AnyNode, Container, DictConfig, IntegerNode, ListConfig, Node, OmegaConf, StringNode, Valid...
576
17,297
omegaconf
tests/interpolation/test_resolver_annotation_validation.py
.py
import inspect from collections.abc import Sequence from dataclasses import dataclass from functools import partial from typing import Annotated, Any, Literal, Optional, Protocol, TypedDict, TypeVar from pytest import mark, raises, warns from omegaconf import DictConfig, ListConfig, OmegaConf, TupleConfig from omegac...
523
16,386
omegaconf
tests/interpolation/test_custom_resolvers.py
.py
import random import re from typing import Any from pytest import mark, param, raises, warns from omegaconf import OmegaConf, Resolver from omegaconf.nodes import InterpolationResultNode from tests import User from tests.interpolation import dereference_node def legacy_register_resolver(name: str, resolver: Resolve...
505
15,966
omegaconf
tests/interpolation/built_in_resolvers/test_oc_create.py
.py
from typing import Any, Dict, List from pytest import mark, param, raises from omegaconf import DictConfig, ListConfig, OmegaConf from omegaconf.errors import InterpolationResolutionError @mark.parametrize( ("cfg", "key", "expected"), [ # Note that since `oc.create` is simply calling `OmegaConf.crea...
140
3,890
omegaconf
tests/interpolation/built_in_resolvers/test_oc_dict.py
.py
import re from typing import Any, List from pytest import mark, param, raises from omegaconf import DictConfig, ListConfig, OmegaConf from omegaconf.errors import ( InterpolationResolutionError, InterpolationToMissingValueError, ) from omegaconf.resolvers.oc.dict import _get_and_validate_dict_input from tests...
338
9,570
omegaconf
tests/interpolation/built_in_resolvers/test_oc_decode.py
.py
import re from typing import Any, Optional from pytest import mark, param, raises from omegaconf import OmegaConf from omegaconf.errors import InterpolationResolutionError @mark.parametrize( "value,expected", [ # We only test a few typical cases: more extensive grammar tests are # found in `...
106
2,973
omegaconf
tests/interpolation/built_in_resolvers/test_oc_select.py
.py
from dataclasses import dataclass from typing import Any from pytest import mark, raises from omegaconf import SI, OmegaConf from omegaconf.errors import InterpolationKeyError def test_oc_select_abs() -> None: cfg = OmegaConf.create( { "a0": "${k}", "a1": "${oc.select:k}", ...
155
3,527
omegaconf
tests/interpolation/built_in_resolvers/test_oc_deprecated.py
.py
import re from typing import Any from pytest import mark, param, raises, warns from omegaconf import OmegaConf from omegaconf.errors import InterpolationResolutionError @mark.parametrize( ("cfg", "key", "expected_value", "expected_warning"), [ param( {"a": 10, "b": "${oc.deprecated: a}"}...
108
3,245
omegaconf
tests/interpolation/built_in_resolvers/test_oc_env.py
.py
import re from typing import Any, Optional from pytest import mark, param, raises from omegaconf import OmegaConf from omegaconf._utils import _ensure_container from omegaconf.errors import InterpolationResolutionError class TestEnvInterpolation: @mark.parametrize( ("cfg", "env_name", "env_val", "key", ...
115
3,033
omegaconf
tests/data/load.py
.py
import pickle import sys from omegaconf import OmegaConf with open(f"{sys.argv[1]}.pickle", mode="rb") as fp: cfg = pickle.load(fp) assert cfg == OmegaConf.create({"a": [{"b": 10}]})
9
193
omegaconf
tests/data/save.py
.py
import pickle from omegaconf import OmegaConf, __version__ cfg = OmegaConf.create({"a": [{"b": 10}]}) with open(f"{__version__}.pickle", mode="wb") as fp: pickle.dump(cfg, fp)
9
183
omegaconf
tests/examples/dataclass_postponed_annotations.py
.py
# `from __future__` has to be the very first thing in a module # otherwise a syntax error is raised from __future__ import annotations from dataclasses import dataclass, fields from enum import Enum from pathlib import Path from pytest import raises from omegaconf import OmegaConf, ValidationError class Height(Enu...
57
1,477
omegaconf
tests/examples/test_postponed_annotations.py
.py
def test_simple_types_class_postponed() -> None: # import from a module which has `from __future__ import annotations` from tests.examples.dataclass_postponed_annotations import simple_types_class simple_types_class() def test_conversions_postponed() -> None: # import from a module which has `from __...
13
443
omegaconf
tests/examples/test_dataclass_example.py
.py
from dataclasses import dataclass, field from enum import Enum from typing import Any, Dict, List, Optional from pytest import raises from omegaconf import ( MISSING, DictConfig, MissingMandatoryValue, OmegaConf, ReadonlyConfigError, ValidationError, ) class Height(Enum): SHORT = 0 T...
405
11,719
omegaconf
benchmark/benchmark.py
.py
import copy from typing import Any, Dict, List from pytest import fixture, mark, param from omegaconf import OmegaConf from omegaconf._utils import ValueKind, _is_missing_literal, get_value_kind, split_key def build_dict( d: Dict[str, Any], depth: int, width: int, leaf_value: Any = 1 ) -> Dict[str, Any]: if...
192
4,916
hydra
setup.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # type: ignore import pathlib from setuptools import find_namespace_packages, setup from build_helpers.build_helpers import ( ANTLRCommand, BuildPyCommand, CleanCommand, Develop, SDistCommand, find_version, ) with pathlib....
63
2,152
hydra
noxfile.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import copy import functools import importlib.util import os import platform import subprocess import sys from dataclasses import dataclass from pathlib import Path from typing import Iterator, List, Optional, Tuple, Union import nox from nox impor...
750
23,956
hydra
build_helpers/build_helpers.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import codecs import errno import logging import os import re import shutil import subprocess from functools import partial from os.path import abspath, basename, dirname, exists, isdir, join from pathlib import Path from typing import List, Optiona...
239
6,947
hydra
build_helpers/test_helpers.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import os.path from pathlib import Path from typing import List from pytest import mark, param from build_helpers.build_helpers import find, matches @mark.parametrize( "path,include_files,include_dirs,excludes,scan_exclude,expected", [ ...
132
3,382
hydra
tools/copyright/test_check_new_files.py
.py
# SPDX-FileCopyrightText: Contributors to Hydra # SPDX-License-Identifier: MIT import subprocess from pathlib import Path import check_new_files NEW_HEADER = """\ # SPDX-FileCopyrightText: Contributors to Hydra # SPDX-License-Identifier: MIT """ def write(root: Path, relative_path: str, content: str) -> Path: ...
133
4,100
hydra
tools/copyright/check_new_files.py
.py
#!/usr/bin/env python3 # SPDX-FileCopyrightText: Contributors to Hydra # SPDX-License-Identifier: MIT """Check copyright headers on newly added Python files.""" from __future__ import annotations import argparse import os import re import subprocess import sys from pathlib import Path from typing import Sequence R...
141
3,979
hydra
tools/landscape/analyze_hydra_usage.py
.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """Analyze how dependent GitHub repositories use and document Hydra. The analyzer reads repositories from the enriched github-to-sqlite database, visits them in descending star order, and appends one JSON object per reposit...
1,529
53,577
hydra
tools/landscape/test_analyze_hydra_projects.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import json import subprocess import threading from pathlib import Path from types import SimpleNamespace from typing import Any import analyze_hydra_projects as analyzer import pytest def row(**overrides: object) -> dict[str, object]: value...
545
18,109
hydra
tools/landscape/analyze_hydra_projects.py
.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """Classify project-level Hydra usage from the dependent-repository crawl. The existing crawl is mechanical discovery evidence. This analyzer first routes those records with deterministic rules, then optionally asks Codex t...
902
32,617
hydra
tools/landscape/refresh_landscape_metadata.py
.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """Refresh live GitHub metadata used for Hydra Landscape maintenance evidence.""" from __future__ import annotations import argparse import json import re import shutil import subprocess from datetime import datetime, time...
236
8,097
hydra
tools/landscape/build_landscape_review.py
.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """Build a resumable, evidence-backed Hydra Landscape review queue.""" from __future__ import annotations import argparse import json from datetime import datetime, timezone from pathlib import Path from typing import Any,...
514
19,221
hydra
tools/landscape/test_build_landscape_review.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import json from pathlib import Path import build_landscape_review as review def usage(**overrides: object) -> dict[str, object]: value: dict[str, object] = { "repo": "example/project", "tree_sha": "a" * 40, "version_...
269
8,428
hydra
tools/landscape/test_build_public_landscape.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import json from pathlib import Path import build_public_landscape as landscape import pytest def included_decision(**overrides: object) -> dict[str, object]: decision: dict[str, object] = { "repo": "example/project", "decisi...
93
3,014
hydra
tools/landscape/test_analyze_hydra_usage.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from argparse import Namespace from pathlib import Path import analyze_hydra_usage as analyzer from pytest import MonkeyPatch, raises def entry(path: str, *, size: int = 100) -> dict[str, object]: return {"path": path, "sha": f"sha-{path}", ...
636
19,854
hydra
tools/landscape/build_public_landscape.py
.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """Generate public Hydra Landscape data from maintainer decisions.""" from __future__ import annotations import argparse import json import re from pathlib import Path from typing import Any, Iterable ROOT = Path(__file__...
218
7,692
hydra
tools/landscape/test_refresh_landscape_metadata.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import json from pathlib import Path from types import SimpleNamespace import refresh_landscape_metadata as refresh def test_default_input_uses_analyzer_output() -> None: assert refresh.DEFAULT_INPUT.name == "hydra-project-analysis-v1.ndjson...
121
4,047
hydra
tools/release/release.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import json import logging import os import re import shutil import subprocess import sys import tempfile from dataclasses import dataclass from enum import Enum from functools import lru_cache from pathlib import Path from typing import Dict, List,...
777
25,499
hydra
tools/release/test_release.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from contextlib import nullcontext import pytest from tools.release import release from tools.release.release import ( DevReleasePackageInfo, LocalPackageInfo, Package, PackageInfo, fail_if_any_target_version_published, fil...
249
7,393
hydra
tools/configen/setup.py
.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from setuptools import find_packages, setup setup( name="hydra-configen", version="0.9.0.dev9", packages=find_packages(include=["configen"]), entry_points={"console_scripts": ["configen = configen.configen:mai...
20
614
hydra
tools/configen/tests/test_generate.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from difflib import unified_diff from pathlib import Path from textwrap import dedent from typing import Any from configen.config import ConfigenConf, Flags, ModuleConf from hydra.test_utils.test_utils import chdir_hydra_root, run_python_script fro...
295
8,544
hydra
tools/configen/tests/test_modules/future_annotations.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from __future__ import annotations # type: ignore # noqa: F407 from dataclasses import dataclass from typing import List, Optional from omegaconf import MISSING @dataclass class User: name: str = MISSING age: int = MISSING class Libra...
55
1,533
hydra
tools/configen/tests/test_modules/__init__.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Tuple, Union from omegaconf import MISSING class Color(Enum): RED = 0 GREEN = 1 BLUE = 2 @dataclass class User: name: str = ...
216
5,316
hydra
tools/configen/example/my_app.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import hydra # Generated config dataclasses from example.config.configen.samples.my_module import AdminConf, UserConf from hydra.core.config_store import ConfigStore from omegaconf import DictConfig # Underlying objects from configen.samples.my_mo...
32
824
hydra
tools/configen/configen/utils.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from enum import Enum from typing import Any, Dict, Iterable, List, Optional, Set from omegaconf._utils import ( _resolve_optional, get_dict_key_value_types, get_list_element_type, is_dict_annotation, is_list_annotation, is_...
63
1,832
hydra
tools/configen/configen/configen.py
.py
import inspect import logging import os import pkgutil import sys from dataclasses import dataclass from enum import Enum from pathlib import Path # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from textwrap import dedent from typing import Any, Dict, List, Optional, Set, Type, cast, get_type_h...
268
8,079
hydra
tools/configen/configen/config.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from dataclasses import dataclass, field from typing import List, Optional from hydra.core.config_store import ConfigStore from hydra.utils import ConvertMode from omegaconf import MISSING @dataclass class Flags: _convert_: Optional[ConvertMo...
44
960