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 |
|---|---|---|---|---|---|
hydra | examples/advanced/package_overrides/two_packages.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main(config_path="conf", config_name="two_packages")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
my_app()
| 14 | 304 |
hydra | examples/advanced/ray_example/ray_compose_example.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import time
from typing import List, Tuple
import ray
from omegaconf import DictConfig, OmegaConf
import hydra
@ray.remote # type: ignore
def train(overrides: List[str], cfg: DictConfig) -> Tuple[List[str], float]:
print(OmegaConf.to_yaml(c... | 36 | 939 |
hydra | examples/advanced/ad_hoc_composition/hydra_compose_example.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import OmegaConf
from hydra import compose, initialize
if __name__ == "__main__":
# initialize the Hydra subsystem.
# This is needed for apps that cannot have a standard @hydra.main() entry point
initialize(config_path="... | 12 | 458 |
hydra | examples/advanced/hydra_app_example/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-app",
version="0.1",
packages=find_packages(include=["hydra_app"]),
entry_points={"console_scripts": ["hydra_app = hydra_app.main:main"]},
au... | 18 | 493 |
hydra | examples/advanced/hydra_app_example/tests/test_example.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from typing import List
from pytest import mark
import hydra_app.main
from hydra import compose, initialize, initialize_config_module
# 1. initialize will add config_path the config search path within the context
# 2. The module ... | 63 | 2,691 |
hydra | examples/advanced/hydra_app_example/tests/test_installed_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import re
import subprocess
import sys
# The following tests are testing that the app actually runs as expected
# when installed and executed from the command line.
# You don't need to repeat those tests in your own app.
class TestAppOutput:
#... | 41 | 1,509 |
hydra | examples/advanced/hydra_app_example/hydra_app/main.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
from omegaconf import DictConfig
import hydra
def add(app_cfg: DictConfig, key1: str, key2: str) -> Any:
num1 = app_cfg[key1]
num2 = app_cfg[key2]
ret = num1 + num2
print(f"Hello {app_cfg.user}, {num1} + {n... | 24 | 514 |
hydra | examples/tutorials/basic/your_first_hydra_app/1_simple_cli/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main()
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
my_app()
| 14 | 258 |
hydra | examples/tutorials/basic/your_first_hydra_app/4_config_groups/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main(config_path="conf")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
my_app()
| 14 | 276 |
hydra | examples/tutorials/basic/your_first_hydra_app/3_using_config/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, MissingMandatoryValue, open_dict
from pytest import raises
import hydra
@hydra.main(config_path=".", config_name="config")
def my_app(cfg: DictConfig) -> None:
assert cfg.node.loompa == 10 # attribute style ... | 36 | 1,238 |
hydra | examples/tutorials/basic/running_your_hydra_app/4_logging/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from omegaconf import DictConfig
import hydra
# A logger for this file
log = logging.getLogger(__name__)
@hydra.main()
def my_app(_cfg: DictConfig) -> None:
log.info("Info level message")
log.debug("Debug level message")
... | 20 | 362 |
hydra | examples/tutorials/basic/running_your_hydra_app/5_basic_sweep/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(f"driver={cfg.db.driver}, timeout={cfg.db.timeout}")
if __name__ == "__main__":
my_app()
| 14 | 316 |
hydra | examples/tutorials/basic/running_your_hydra_app/3_working_directory/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
@hydra.main()
def my_app(_cfg: DictConfig) -> None:
print(f"Working directory : {os.getcwd()}")
print(f"Output directory : {HydraCon... | 18 | 394 |
hydra | examples/tutorials/basic/running_your_hydra_app/3_working_directory/original_cwd.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from omegaconf import DictConfig
import hydra
from hydra.utils import get_original_cwd, to_absolute_path
@hydra.main()
def my_app(_cfg: DictConfig) -> None:
print(f"Current working directory : {os.getcwd()}")
print(f"Orig worki... | 20 | 540 |
hydra | examples/tutorials/structured_configs/4_defaults/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
from typing import Any, List
from omegaconf import MISSING, OmegaConf # Do not confuse with dataclass.MISSING
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class MySQLConfig:
... | 58 | 1,314 |
hydra | examples/tutorials/structured_configs/1_minimal/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class MySQLConfig:
host: str = "localhost"
port: int = 3306
cs = ConfigStore.instance()
# Registering the Config class with the na... | 26 | 540 |
hydra | examples/tutorials/structured_configs/1_minimal/my_app_type_error.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class MySQLConfig:
host: str = "localhost"
port: int = 3306
cs = ConfigStore.instance()
# Registering the Config class with the na... | 28 | 595 |
hydra | examples/tutorials/structured_configs/2_static_complex/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class MySQLConfig:
host: str = "localhost"
port: int = 3306
@dataclass
class UserInterface:
title: str = "My app"
w... | 38 | 767 |
hydra | examples/tutorials/structured_configs/5.2_structured_config_schema_different_config_group/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
import database_lib
from omegaconf import MISSING, OmegaConf
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class Config:
db: database_lib.DBConfig = MISSING
debug: bool = False
... | 35 | 659 |
hydra | examples/tutorials/structured_configs/5.2_structured_config_schema_different_config_group/database_lib.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from omegaconf import MISSING
from hydra.core.config_store import ConfigStore
@dataclass
class DBConfig:
driver: str = MISSING
host: str = "localhost"
port: int = MISSING
@dataclass
class MySQLConf... | 45 | 884 |
hydra | examples/tutorials/structured_configs/3_config_groups/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from typing import Any
from omegaconf import OmegaConf
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class MySQLConfig:
driver: str = "mysql"
host: str = "localhost"
port: i... | 45 | 881 |
hydra | examples/tutorials/structured_configs/3_config_groups/my_app_with_inheritance.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from omegaconf import MISSING, OmegaConf
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class DBConfig:
host: str = "localhost"
port: int = MISSING
driver: str = MISSING
@d... | 50 | 997 |
hydra | examples/tutorials/structured_configs/5.1_structured_config_schema_same_config_group/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from omegaconf import MISSING, OmegaConf
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class DBConfig:
driver: str = MISSING
host: str = "localhost"
port: int = MISSING
@d... | 53 | 1,071 |
hydra | examples/experimental/rerun/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
from hydra.utils import target_whitelist
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def my_a... | 23 | 558 |
hydra | examples/patterns/write_protect_config_node/frozen.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
import hydra
from hydra.core.config_store import ConfigStore
@dataclass(frozen=True)
class SerialPort:
baud_rate: int = 19200
data_bits: int = 8
stop_bits: int = 1
cs = ConfigStore.instance()
cs.sto... | 26 | 485 |
hydra | examples/patterns/specializing_config/example.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import sys
from omegaconf import DictConfig, OmegaConf
import hydra
log = logging.getLogger(__name__)
@hydra.main(config_path="conf", config_name="config")
def experiment(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg)... | 19 | 378 |
hydra | examples/configure_hydra/job_name/no_config_file_override.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
@hydra.main()
def experiment(_cfg: DictConfig) -> None:
print(HydraConfig.get().job.name)
if __name__ == "__main__":
experiment()
| 15 | 308 |
hydra | examples/configure_hydra/job_name/with_config_file_override.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
@hydra.main(config_path=".", config_name="config")
def experiment(_cfg: DictConfig) -> None:
print(HydraConfig.get().job.name)
if __name__ == "__m... | 15 | 345 |
hydra | examples/configure_hydra/job_override_dirname/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from omegaconf import DictConfig
import hydra
@hydra.main(config_path=".", config_name="config")
def my_app(_cfg: DictConfig) -> None:
print(f"Working dir {os.getcwd()}")
if __name__ == "__main__":
my_app()
| 16 | 302 |
hydra | examples/configure_hydra/logging/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from omegaconf import DictConfig
import hydra
log = logging.getLogger(__name__)
@hydra.main(config_path="conf", config_name="config")
def my_app(_cfg: DictConfig) -> None:
log.info("Info level message")
if __name__ == "__ma... | 18 | 340 |
hydra | examples/configure_hydra/workdir/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from omegaconf import DictConfig
import hydra
@hydra.main(config_path="conf", config_name="config")
def experiment(_cfg: DictConfig) -> None:
print(os.getcwd())
if __name__ == "__main__":
experiment()
| 16 | 296 |
hydra | examples/instantiate/partial/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
from omegaconf import DictConfig
import hydra
from hydra.utils import instantiate, target_whitelist
class Optimizer:
algo: str
lr: float
def __init__(self, algo: str, lr: float) -> None:
self.algo = al... | 40 | 871 |
hydra | examples/instantiate/schema_recursive/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from typing import Optional
from omegaconf import MISSING
import hydra
from hydra.core.config_store import ConfigStore
from hydra.utils import instantiate, target_whitelist
class Tree:
def __init__(
... | 58 | 1,446 |
hydra | examples/instantiate/docs_example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
from hydra.utils import instantiate, target_whitelist
class Optimizer:
algo: str
lr: float
def __init__(self, algo: str, lr: float) -> None:
self.algo = algo
self.lr = lr... | 85 | 2,384 |
hydra | examples/instantiate/object/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
from hydra.utils import instantiate, target_whitelist
class DBConnection:
def connect(self) -> None: ...
class MySQLConnection(DBConnection):
def __init__(self, host: str, user: str, passwor... | 42 | 1,073 |
hydra | examples/instantiate/object_recursive/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List
from omegaconf import DictConfig
import hydra
from hydra.utils import instantiate, target_whitelist
class Driver:
def __init__(self, name: str, age: int) -> None:
self.name = name
self.age = age
clas... | 40 | 904 |
hydra | examples/instantiate/schema/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
from typing import Any, List
from omegaconf import MISSING
import hydra
from hydra.core.config_store import ConfigStore
from hydra.utils import instantiate, target_whitelist
class DBConnection:
def __... | 81 | 1,926 |
hydra | examples/plugins/example_configsource_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import find_namespace_packages, setup
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-configsource",
version="1.0.0",
author="Omry Yadan",
author_... | 40 | 1,721 |
hydra | examples/plugins/example_configsource_plugin/hydra_plugins/example_configsource_plugin/example_configsource_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, Dict, List, Optional
from hydra.core.object_type import ObjectType
from hydra.plugins.config_source import ConfigLoadError, ConfigResult, ConfigSource
from omegaconf import OmegaConf
class ConfigSourceExample(ConfigSource)... | 131 | 5,279 |
hydra | examples/plugins/example_configsource_plugin/tests/test_example_config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pytest import mark
from hydra.core.plugins import Plugins
from hydra.plugins.config_source import ConfigSource
from hydra.test_utils.config_source_common_tests import ConfigSourceTestSuite
from hydra_plugins.example_configsource_plugin.examp... | 24 | 759 |
hydra | examples/plugins/example_launcher_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import find_namespace_packages, setup
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-launcher",
version="1.0.0",
author="Omry Yadan",
author_emai... | 40 | 1,713 |
hydra | examples/plugins/example_launcher_plugin/hydra_plugins/example_launcher_plugin/example_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
import logging
from pathlib import Path
from typing import Optional, Sequence
from hydra.types import HydraContext
from hydra.core.config_store import ConfigStore
from hydra.core.singleton import Singleton
from hy... | 128 | 4,952 |
hydra | examples/plugins/example_launcher_plugin/tests/test_example_launcher_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pytest import mark
from hydra.core.plugins import Plugins
from hydra.plugins.launcher import Launcher
from hydra.test_utils.launcher_common_tests import (
IntegrationTestSuite,
LauncherTestSuite,
)
from hydra_plugins.example_launcher... | 42 | 1,132 |
hydra | examples/plugins/example_launcher_plugin/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import hydra
from omegaconf import OmegaConf, DictConfig
@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
my_app()
| 13 | 297 |
hydra | examples/plugins/example_sweeper_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import find_namespace_packages, setup
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-sweeper",
version="1.0.0",
author="Omry Yadan",
author_email... | 40 | 1,711 |
hydra | examples/plugins/example_sweeper_plugin/hydra_plugins/example_sweeper_plugin/example_sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
import itertools
import logging
from pathlib import Path
from typing import Any, Iterable, List, Optional, Sequence
from hydra.types import HydraContext
from hydra.core.config_store import ConfigStore
from hydra.c... | 126 | 5,225 |
hydra | examples/plugins/example_sweeper_plugin/tests/test_example_sweeper_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pytest import mark
from hydra.core.plugins import Plugins
from hydra.plugins.sweeper import Sweeper
from hydra.test_utils.launcher_common_tests import (
BatchedSweeperTestSuite,
IntegrationTestSuite,
LauncherTestSuite,
)
from hydra... | 95 | 2,853 |
hydra | examples/plugins/example_generic_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import find_namespace_packages, setup
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-generic-plugin",
version="1.0.0",
author="Omry Yadan",
autho... | 39 | 1,611 |
hydra | examples/plugins/example_generic_plugin/hydra_plugins/example_generic_plugin/example_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.plugins.plugin import Plugin
class ExamplePlugin(Plugin):
def __init__(self, v: int) -> None:
self.v = v
def add(self, x: int) -> int:
return self.v + x
| 11 | 262 |
hydra | examples/plugins/example_generic_plugin/tests/test_example_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.core.plugins import Plugins
from hydra.plugins.plugin import Plugin
from hydra_plugins.example_generic_plugin.example_plugin import ExamplePlugin
def test_discovery() -> None:
# Tests that this plugin can be discovered via the plug... | 18 | 561 |
hydra | examples/plugins/example_registered_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import setup
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-registered-plugin",
version="1.0.0",
author="Jasha Sommer-Simpson",
description="Example of Hydra Plugin ... | 35 | 1,273 |
hydra | examples/plugins/example_registered_plugin/tests/test_example_registered_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.core.plugins import Plugins
from hydra.plugins.plugin import Plugin
from example_registered_plugin import ExampleRegisteredPlugin, register_example_plugin
def test_discovery() -> None:
# Tests that this plugin can be discovered aft... | 23 | 707 |
hydra | examples/plugins/example_registered_plugin/example_registered_plugin/__init__.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.core.plugins import Plugins
from hydra.plugins.plugin import Plugin
class ExampleRegisteredPlugin(Plugin):
def __init__(self, v: int) -> None:
self.v = v
def add(self, x: int) -> int:
return self.v + x
def reg... | 17 | 488 |
hydra | examples/plugins/example_searchpath_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import find_namespace_packages, setup, find_packages
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-searchpath-plugin",
version="1.0.0",
author="Omry Yad... | 41 | 1,796 |
hydra | examples/plugins/example_searchpath_plugin/hydra_plugins/example_searchpath_plugin/example_searchpath_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.core.config_search_path import ConfigSearchPath
from hydra.plugins.search_path_plugin import SearchPathPlugin
class ExampleSearchPathPlugin(SearchPathPlugin):
def manipulate_search_path(self, search_path: ConfigSearchPath) -> None:
... | 17 | 858 |
hydra | examples/plugins/example_searchpath_plugin/tests/test_example_search_path_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.core.global_hydra import GlobalHydra
from hydra.core.plugins import Plugins
from hydra import initialize
from hydra.plugins.search_path_plugin import SearchPathPlugin
from hydra_plugins.example_searchpath_plugin.example_searchpath_plugin... | 25 | 860 |
hydra | hydra/types.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable
TaskFunction = Callable[[Any], Any]
if TYPE_CHECKING:
from hydra._internal.callbacks import Callbacks
from hydra.core.config_loader im... | 66 | 2,183 |
hydra | hydra/errors.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Optional, Sequence
class HydraException(Exception): ...
class CompactHydraException(HydraException): ...
class OverrideParseException(CompactHydraException):
def __init__(self, override: str, message: str) -> None:
... | 48 | 1,221 |
hydra | hydra/main.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import functools
import pickle
import warnings
from pathlib import Path
from typing import Any, Callable, List, Optional
from omegaconf import DictConfig, open_dict, read_write
from . import version
from ._internal.utils import _run_hy... | 84 | 3,292 |
hydra | hydra/utils.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import json
import logging.config
import os
from pathlib import Path
from typing import Any, Callable
import hydra._internal.instantiate._instantiate2
import hydra.types
from hydra._internal.deprecation_warning import deprecation_warning
from hydr... | 157 | 4,577 |
hydra | hydra/compose.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List, Optional
from omegaconf import DictConfig, open_dict
from hydra.core.global_hydra import GlobalHydra
from hydra.types import RunMode
def compose(
config_name: Optional[str] = None,
overrides: Optional[List[str]] ... | 47 | 1,341 |
hydra | hydra/initialize.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import os
from typing import Any, Optional
from hydra import version
from hydra._internal.hydra import Hydra
from hydra._internal.utils import (
create_config_search_path,
detect_calling_file_or_module_from_stack_frame,
dete... | 155 | 5,233 |
hydra | hydra/__init__.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# Source of truth for Hydra's version
__version__ = "1.4.0.dev9"
from hydra import utils
from hydra.errors import MissingConfigException
from hydra.main import main
from hydra.types import TaskFunction
from .compose import compose
from .initialize... | 24 | 591 |
hydra | hydra/version.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# Source of truth for Hydra's version
import re
from textwrap import dedent
from typing import Any, Tuple
from . import __version__
from ._internal.deprecation_warning import deprecation_warning
from .core.singleton import Singleton
from .errors ... | 86 | 2,638 |
hydra | hydra/conf/__init__.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional
from omegaconf import MISSING
from hydra.core.config_store import ConfigStore
from hydra.types import RunMode
@dataclass
class HelpConf:
app_name: str = MI... | 181 | 5,183 |
hydra | hydra/extra/pytest_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
from pathlib import Path
from typing import Callable, Generator, List, Optional
from pytest import fixture
from hydra.core.singleton import Singleton
from hydra.test_utils.test_utils import SweepTaskFunction, TaskTestFunction
from hydr... | 91 | 2,508 |
hydra | hydra/experimental/callback.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any
from omegaconf import DictConfig
from hydra.core.utils import JobReturn
from hydra.types import TaskFunction
logger = logging.getLogger(__name__)
class Callback:
def on_run_start(self, config: DictConfi... | 66 | 2,378 |
hydra | hydra/experimental/callbacks.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import pickle
from pathlib import Path
from typing import Any
from omegaconf import DictConfig
from hydra.core.utils import JobReturn, JobStatus
from hydra.experimental.callback import Callback
class LogJobReturnCallback(Callback... | 61 | 2,336 |
hydra | hydra/test_utils/example_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main(config_path="configs", config_name="db_conf")
def run_cli(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
run_cli()
| 14 | 304 |
hydra | hydra/test_utils/completion.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main(config_path="configs/completion_test", config_name="config")
def run_cli(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
run_cli()
| 14 | 319 |
hydra | hydra/test_utils/a_module.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
@hydra.main()
def experiment(_: DictConfig) -> None:
pass
if __name__ == "__main__":
experiment()
| 14 | 228 |
hydra | hydra/test_utils/config_source_common_tests.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, List, Optional, Type
from pytest import mark, param, raises, skip
from hydra.core.default_element import InputDefault
from hydra.core.object_type import ObjectType
from hydra.plugins.config_source import ConfigLoadError, Co... | 310 | 10,900 |
hydra | hydra/test_utils/launcher_common_tests.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Common test functions testing launchers
"""
import copy
import os
import re
from pathlib import Path
from typing import Any, Callable, List, Optional, Set
from omegaconf import DictConfig, OmegaConf
from pytest import mark, param, raises
from... | 688 | 23,749 |
hydra | hydra/test_utils/test_utils.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Utilities used by tests
"""
import copy
import logging
import os
import re
import shutil
import string
import subprocess
import sys
import tempfile
from contextlib import contextmanager
from difflib import unified_diff
from pathlib import Path
... | 472 | 15,175 |
hydra | hydra/core/utils.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import logging
import os
import re
import sys
from contextlib import contextmanager
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from os.path import splitext
from pathlib import Path
from t... | 473 | 15,880 |
hydra | hydra/core/singleton.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from copy import deepcopy
from typing import Any, Dict
from omegaconf.basecontainer import BaseContainer
class Singleton(type):
_instances: Dict[type, "Singleton"] = {}
def __call__(cls, *args: Any, **kwargs: Any) -> Any:
if cls ... | 40 | 1,324 |
hydra | hydra/core/object_type.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from enum import Enum
class ObjectType(Enum):
NOT_FOUND = 0
CONFIG = 1
GROUP = 2
| 9 | 166 |
hydra | hydra/core/hydra_config.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, Optional
from omegaconf import DictConfig, OmegaConf
from hydra.conf import HydraConf
from hydra.core.singleton import Singleton
class HydraConfig(metaclass=Singleton):
def __init__(self) -> None:
self.cfg: Op... | 42 | 1,561 |
hydra | hydra/core/config_store.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
from dataclasses import dataclass
from typing import Any, Dict, List, Optional
from omegaconf import DictConfig, OmegaConf
from hydra.core.object_type import ObjectType
from hydra.core.singleton import Singleton
from hydra.plugins.conf... | 155 | 4,729 |
hydra | hydra/core/default_element.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import re
from dataclasses import dataclass, field
from textwrap import dedent
from typing import List, Optional, Pattern, Union
from omegaconf import AnyNode, DictConfig
from hydra.errors import ConfigCompositionException
_defaults_list_interpol... | 590 | 18,126 |
hydra | hydra/core/config_search_path.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import MutableSequence, Optional, Union
class SearchPathElement:
def __init__(self, provider: str, search_path: str):
self.provider = provider
se... | 67 | 2,062 |
hydra | hydra/core/global_hydra.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, Optional
from hydra._internal.hydra import Hydra
from hydra.core.config_loader import ConfigLoader
from hydra.core.singleton import Singleton
class GlobalHydra(metaclass=Singleton):
def __init__(self) -> None:
... | 39 | 1,324 |
hydra | hydra/core/config_loader.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from abc import ABC, abstractmethod
from typing import Any, List, Optional
from omegaconf import DictConfig
from hydra.core.config_search_path import ConfigSearchPath
from hydra.core.object_type import ObjectType
from hydra.plugins.config_source i... | 58 | 1,521 |
hydra | hydra/core/plugins.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import importlib
import importlib.util
import inspect
import pkgutil
import sys
import warnings
from collections import defaultdict
from dataclasses import dataclass, field
from timeit import default_timer as timer
from typing import Any, Dict, List... | 277 | 10,607 |
hydra | hydra/core/override_parser/types.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import decimal
import fnmatch
from copy import copy
from dataclasses import dataclass, field
from enum import Enum
from random import shuffle
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Union, cast
from omegaconf import O... | 498 | 15,901 |
hydra | hydra/core/override_parser/overrides_visitor.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import sys
import warnings
from typing import Any, Dict, List, Optional, Tuple, Union, cast
from omegaconf.vendor.antlr4 import ( # type: ignore[attr-defined]
ParserRuleContext,
TerminalNode,
Token,
)
from omegaconf.vendor.antlr4.error... | 444 | 16,919 |
hydra | hydra/core/override_parser/overrides_parser.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import sys
from typing import Any, List, Optional
from omegaconf.vendor.antlr4.error.Errors import (
LexerNoViableAltException,
RecognitionException,
)
from hydra._internal.grammar import grammar_functions
from hydra._internal.grammar.func... | 129 | 4,985 |
hydra | hydra/plugins/launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Launcher plugin interface
"""
from abc import abstractmethod
from typing import Sequence
from omegaconf import DictConfig
from hydra.core.utils import JobReturn
from hydra.types import TaskFunction, HydraContext
from .plugin import Plugin
... | 41 | 975 |
hydra | hydra/plugins/completion_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# TODO: Test with /miniconda3/envs/hydra36/bin/python , seems to be running python for some reason.
# TODO: Add tests for completion with +prefix (should suggest config groups that are not listed)
# TODO: Test completion when defaults has a missing... | 304 | 11,337 |
hydra | hydra/plugins/search_path_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from abc import abstractmethod
from hydra.core.config_search_path import ConfigSearchPath
from .plugin import Plugin
class SearchPathPlugin(Plugin):
@abstractmethod
def manipulate_search_path(self, search_path: ConfigSearchPath) -> None:... | 12 | 325 |
hydra | hydra/plugins/sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Sweeper plugin interface
"""
from abc import abstractmethod
from typing import Any, List, Optional, Sequence
from omegaconf import DictConfig
from hydra.types import HydraContext, TaskFunction
from .launcher import Launcher
from .plugin impo... | 61 | 1,896 |
hydra | hydra/plugins/config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import re
from abc import abstractmethod
from dataclasses import dataclass
from typing import Dict, List, Optional
from omegaconf import Container
from hydra.core.default_element import InputDefault
from hydra.core.object_type import ObjectType
fr... | 154 | 4,915 |
hydra | hydra/plugins/plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from abc import ABC
class Plugin(ABC): ...
| 6 | 116 |
hydra | hydra/_internal/hydra.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import logging
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict
from typing import Any, Callable, DefaultDict, List, Optional, Sequence, Type, Union
from omegaconf import (
MISSING,
... | 778 | 26,703 |
hydra | hydra/_internal/config_search_path_impl.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List, MutableSequence, Optional, Union
from hydra.core.config_search_path import (
ConfigSearchPath,
SearchPathElement,
SearchPathQuery,
)
class ConfigSearchPathImpl(ConfigSearchPath):
config_search_path: List[S... | 99 | 3,565 |
hydra | hydra/_internal/utils.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import inspect
import logging.config
import os
import sys
import traceback
import warnings
from os.path import dirname, join, normpath, realpath
from types import TracebackType
from typing import Any, List, Optional, Sequence, Tuple
... | 693 | 23,264 |
hydra | hydra/_internal/defaults_list.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
from dataclasses import dataclass, field
from textwrap import dedent
from typing import Callable, Dict, List, Optional, Set, Tuple, Union
from omegaconf import OmegaConf
from hydra import MissingConfigException
from hydra._internal.co... | 1,004 | 36,085 |
hydra | hydra/_internal/sources_registry.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, Dict, Type
from hydra.core.singleton import Singleton
from hydra.plugins.config_source import ConfigSource
class SourcesRegistry(metaclass=Singleton):
types: Dict[str, Type[ConfigSource]]
def __init__(self) -> Non... | 37 | 1,298 |
hydra | hydra/_internal/config_repository.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Dict, List, Optional, Tuple
from omegaconf import (
Container,
DictConfig,
ListConfig,
Node,
OmegaConf,
open_dict,
read... | 343 | 12,876 |
hydra | hydra/_internal/callbacks.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import warnings
from typing import TYPE_CHECKING, Any, Optional
from omegaconf import DictConfig, OmegaConf
from hydra.types import TaskFunction
if TYPE_CHECKING:
from hydra.core.utils import JobReturn
class Callbacks:
def __init__(self... | 66 | 2,310 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.