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 | hydra/_internal/config_loader_impl.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import os
import sys
import warnings
from textwrap import dedent
from typing import Any, List, MutableSequence, Optional, Tuple, Union
from omegaconf import (
Container,
DictConfig,
ListConfig,
OmegaConf,
flag_overri... | 640 | 25,369 |
hydra | hydra/_internal/deprecation_warning.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import warnings
from typing import Type
from hydra.errors import HydraDeprecationError
def deprecation_warning(
message: str, stacklevel: int = 1, category: Type[Warning] = UserWarning
) -> None:
warnings_as_errors = os.environ.... | 17 | 523 |
hydra | hydra/_internal/core_plugins/bash_completion.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
import sys
from typing import Optional
from hydra.plugins.completion_plugin import CompletionPlugin
log = logging.getLogger(__name__)
class BashCompletion(CompletionPlugin):
def install(self) -> None:
# Recor... | 104 | 3,077 |
hydra | hydra/_internal/core_plugins/zsh_completion.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Optional
from hydra.core.config_loader import ConfigLoader
from hydra.plugins.completion_plugin import CompletionPlugin
log = logging.getLogger(__name__)
class ZshCompletion(CompletionPlugin):
def __init__(s... | 49 | 1,545 |
hydra | hydra/_internal/core_plugins/importlib_resources_config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import zipfile
from importlib import resources
from typing import Any, List, Optional
from omegaconf import OmegaConf
from hydra.core.object_type import ObjectType
from hydra.plugins.config_source import ConfigLoadError, ConfigResult, Co... | 98 | 3,456 |
hydra | hydra/_internal/core_plugins/basic_sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Basic sweeper can generate cartesian products of multiple input commands, each with a
comma separated list of values.
for example, for:
python foo.py a=1,2,3 b=10,20
Basic Sweeper would generate 6 jobs:
1,10
1,20
2,10
2,20
3,10
3,20
The Basic ... | 202 | 6,585 |
hydra | hydra/_internal/core_plugins/file_config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from typing import List, Optional
from omegaconf import OmegaConf
from hydra.core.object_type import ObjectType
from hydra.plugins.config_source import ConfigLoadError, ConfigResult, ConfigSource
class FileConfigSource(ConfigSource):
... | 64 | 2,317 |
hydra | hydra/_internal/core_plugins/structured_config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import importlib
import warnings
from typing import List, Optional
from hydra.core.config_store import ConfigStore
from hydra.core.object_type import ObjectType
from hydra.plugins.config_source import ConfigResult, ConfigSource
class StructuredCo... | 64 | 2,328 |
hydra | hydra/_internal/core_plugins/basic_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from dataclasses import dataclass
from pathlib import Path
from typing import List, Optional, Sequence
from omegaconf import DictConfig, open_dict
from hydra.core.config_store import ConfigStore
from hydra.core.utils import (
Jo... | 84 | 2,755 |
hydra | hydra/_internal/core_plugins/fish_completion.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
import sys
from typing import List, Optional, Tuple
from hydra.plugins.completion_plugin import CompletionPlugin
log = logging.getLogger(__name__)
class FishCompletion(CompletionPlugin):
def install(self) -> None:
... | 82 | 2,395 |
hydra | hydra/_internal/grammar/utils.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import inspect
import re
from typing import Any, Union
from omegaconf._utils import is_dict_annotation, is_list_annotation
# All characters that must be escaped (must match the ESC grammar lexer token).
_ESC = "\\()[]{}:=, \t"
# Regular expressio... | 62 | 2,133 |
hydra | hydra/_internal/grammar/functions.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import inspect
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List
from omegaconf._utils import type_str
from hydra._internal.grammar.utils import is_type_matching
from hydra.core.override_parser.types import Quot... | 76 | 2,657 |
hydra | hydra/_internal/grammar/grammar_functions.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import builtins
import decimal
import json
import random
from copy import copy
from typing import Any, Callable, Dict, List, Optional, Union
from hydra._internal.deprecation_warning import deprecation_warning
from hydra._internal.grammar.utils impo... | 448 | 14,522 |
hydra | hydra/_internal/instantiate/_instantiate2.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import functools
import inspect
import os
import re
from contextvars import ContextVar
from enum import Enum
from textwrap import dedent
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union, cast
from omegacon... | 1,170 | 41,246 |
hydra | plugins/hydra_ax_sweeper/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-ax-sweeper",
version=read_version("hydra_plugins/hydra_ax_sweeper", "__init__.py"),
... | 36 | 1,265 |
hydra | plugins/hydra_ax_sweeper/hydra_plugins/hydra_ax_sweeper/_core.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from dataclasses import dataclass
from typing import (
Any,
Dict,
Iterable,
List,
Literal,
Mapping,
Optional,
Tuple,
Union,
cast,
)
from ax.api.client import Client # type: ignore
from ax.api.... | 444 | 16,446 |
hydra | plugins/hydra_ax_sweeper/hydra_plugins/hydra_ax_sweeper/__init__.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
__version__ = "1.4.0.dev9"
| 4 | 99 |
hydra | plugins/hydra_ax_sweeper/hydra_plugins/hydra_ax_sweeper/ax_sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List, Optional
from hydra.plugins.sweeper import Sweeper
from hydra.types import HydraContext, TaskFunction
from omegaconf import DictConfig
from .config import AxConfig
class AxSweeper(Sweeper):
"""Class to interface with... | 32 | 907 |
hydra | plugins/hydra_ax_sweeper/hydra_plugins/hydra_ax_sweeper/config.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 hydra.core.config_store import ConfigStore
@dataclass
class EarlyStopConfig:
minimize: bool = True
max_epochs_without_improvement: int = 10
#... | 67 | 2,046 |
hydra | plugins/hydra_ax_sweeper/hydra_plugins/hydra_ax_sweeper/_earlystopper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any, Mapping, Optional
log = logging.getLogger(__name__)
class EarlyStopper:
"""Class to implement the early stopping mechanism.
The optimization process is stopped when the performance does not
impro... | 60 | 2,158 |
hydra | plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import math
import os
from pathlib import Path
from typing import Any, List, Tuple
from hydra.core.plugins import Plugins
from hydra.plugins.sweeper import Sweeper
from hydra.test_utils.test_utils import (
TSweepRunner,
chdir_plugin_root,
... | 479 | 16,892 |
hydra | plugins/hydra_ax_sweeper/tests/apps/polynomial.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
import hydra
from omegaconf import DictConfig
@hydra.main(config_path=".", config_name="polynomial")
def polynomial(cfg: DictConfig) -> Any:
x = cfg.polynomial.x
y = cfg.polynomial.y
z = cfg.polynomial.x
a =... | 22 | 450 |
hydra | plugins/hydra_ax_sweeper/tests/apps/polynomial_with_constraint.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
import hydra
from omegaconf import DictConfig
@hydra.main(config_path=".", config_name="polynomial_with_constraint")
def polynomial(cfg: DictConfig) -> Any:
x = cfg.polynomial.x
y = cfg.polynomial.y
z = cfg.poly... | 23 | 548 |
hydra | plugins/hydra_ax_sweeper/tests/apps/polynomial_with_list_coefficients.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
import hydra
from omegaconf import DictConfig
@hydra.main(config_path=".", config_name="polynomial_with_coefficients")
def polynomial_with_list_coefficients(cfg: DictConfig) -> Any:
x, y, z = cfg.polynomial.coefficients... | 19 | 461 |
hydra | plugins/hydra_ax_sweeper/tests/apps/polynomial_with_dict_coefficients.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
import hydra
from omegaconf import DictConfig
@hydra.main(config_path=".", config_name="polynomial_with_dict_coefficients")
def polynomial_with_dict_coefficients(cfg: DictConfig) -> Any:
coeff = cfg.polynomial.coefficie... | 19 | 482 |
hydra | plugins/hydra_ax_sweeper/example/banana.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any
import hydra
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_path="conf", config_name="config")
def banana(cfg: DictConfig) -> Any:
x = cfg.banana.x
y = cfg.bana... | 24 | 498 |
hydra | plugins/hydra_rq_launcher/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-rq-launcher",
version=read_version("hydra_plugins/hydra_rq_launcher", "__init__.py"),
... | 37 | 1,309 |
hydra | plugins/hydra_rq_launcher/hydra_plugins/hydra_rq_launcher/rq_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any, Optional, Sequence, cast
from hydra.core.utils import JobReturn
from hydra.plugins.launcher import Launcher
from hydra.types import HydraContext, TaskFunction
from omegaconf import DictConfig, OmegaConf
from ... | 49 | 1,415 |
hydra | plugins/hydra_rq_launcher/hydra_plugins/hydra_rq_launcher/_core.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import time
import uuid
from base64 import b64decode
from binascii import Error as BinasciiError
from pathlib import Path
from pickle import UnpicklingError
from typing import Any, Dict, List, Optional, Sequence, cast
from fakeredis ... | 249 | 7,773 |
hydra | plugins/hydra_rq_launcher/hydra_plugins/hydra_rq_launcher/serializer.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import cloudpickle # type: ignore
class CloudpickleSerializer:
dumps = cloudpickle.dumps
loads = cloudpickle.loads
| 9 | 198 |
hydra | plugins/hydra_rq_launcher/hydra_plugins/hydra_rq_launcher/config.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
from typing import Optional
from hydra.core.config_store import ConfigStore
from omegaconf import II
@dataclass
class RedisConf:
# host address via REDIS_HOST environment variable, default: localhost
... | 63 | 2,695 |
hydra | plugins/hydra_rq_launcher/tests/test_rq_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from base64 import b64encode
from pickle import UnpicklingError
from typing import List
import pytest
from hydra.core.plugins import Plugins
from hydra.errors import CompactHydraException
from hydra.plugins.launcher import Launcher
from hydra.test_... | 140 | 4,264 |
hydra | plugins/hydra_rq_launcher/tests/conftest.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
from pytest import fixture
@fixture(autouse=True)
def env_setup(monkeypatch: Any) -> None:
# Tests use fake redis server by setting REDIS_MOCK to True
monkeypatch.setenv("REDIS_MOCK", "True")
| 11 | 297 |
hydra | plugins/hydra_rq_launcher/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
import time
import hydra
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_name="config")
def my_app(cfg: DictConfig) -> None:
log.info(f"Process ID {os.getpid()} executing task {c... | 21 | 396 |
hydra | plugins/hydra_colorlog/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-colorlog",
version=read_version("hydra_plugins/hydra_colorlog", "__init__.py"),
auth... | 31 | 1,125 |
hydra | plugins/hydra_colorlog/hydra_plugins/hydra_colorlog/colorlog.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 HydraColorlogSearchPathPlugin(SearchPathPlugin):
def manipulate_search_path(self, search_path: ConfigSearchPath) -> ... | 10 | 494 |
hydra | plugins/hydra_colorlog/tests/test_colorlog.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from pathlib import Path
from hydra import initialize
from hydra.core.global_hydra import GlobalHydra
from hydra.test_utils.test_utils import chdir_plugin_root, run_python_script
chdir_plugin_root()
def test_config_installed() -> None:... | 43 | 1,378 |
hydra | plugins/hydra_colorlog/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import hydra
from omegaconf import DictConfig
# A logger for this file
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def my_app(_cfg: DictConfig) -> None:
log.debug("Debug level message")... | 22 | 519 |
hydra | plugins/hydra_joblib_launcher/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-joblib-launcher",
version=read_version("hydra_plugins/hydra_joblib_launcher", "__init__.... | 36 | 1,316 |
hydra | plugins/hydra_joblib_launcher/hydra_plugins/hydra_joblib_launcher/_core.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import sys
from pathlib import Path
from typing import Any, Dict, List, Sequence, Tuple, cast
from hydra.core.hydra_config import HydraConfig
from hydra.core.singleton import Singleton
from hydra.core.utils import (
JobReturn,
... | 239 | 8,087 |
hydra | plugins/hydra_joblib_launcher/hydra_plugins/hydra_joblib_launcher/joblib_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any, Optional, Sequence, cast
from hydra.core.utils import JobReturn
from hydra.plugins.launcher import Launcher
from hydra.types import HydraContext, TaskFunction
from omegaconf import DictConfig
log = logging.ge... | 50 | 1,547 |
hydra | plugins/hydra_joblib_launcher/hydra_plugins/hydra_joblib_launcher/config.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from typing import Optional
from hydra.core.config_store import ConfigStore
@dataclass
class JobLibLauncherConf:
_target_: str = "hydra_plugins.hydra_joblib_launcher.joblib_launcher.JoblibLauncher"
# max... | 55 | 1,659 |
hydra | plugins/hydra_joblib_launcher/tests/test_joblib_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from collections.abc import Iterator
from contextlib import contextmanager
from pathlib import Path
from typing import Any, cast
from hydra.core.plugins import Plugins
from hydra.core.utils import JobReturn
from hydra.plugins.launcher import Launch... | 329 | 9,669 |
hydra | plugins/hydra_joblib_launcher/tests/apps/multiprocessing_callable_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pathlib import Path
import hydra
from hydra.core.hydra_config import HydraConfig
from omegaconf import DictConfig
class CallableTask:
def __init__(self, marker: str) -> None:
self.marker = marker
def __call__(self, cfg: Dict... | 26 | 631 |
hydra | plugins/hydra_joblib_launcher/tests/apps/multiprocessing_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from functools import wraps
from pathlib import Path
from types import ModuleType
from typing import Any, Callable, NoReturn
import hydra
from hydra.core.hydra_config import HydraConfig
from omegaconf import DictConfig, OmegaConf
class ... | 51 | 1,371 |
hydra | plugins/hydra_joblib_launcher/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
import time
import hydra
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def my_app(cfg: DictConfig) -> None:
log.info(f"Process ID {os.getpid()} ... | 21 | 413 |
hydra | plugins/hydra_nevergrad_sweeper/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-nevergrad-sweeper",
version=read_version("hydra_plugins/hydra_nevergrad_sweeper", "__ini... | 35 | 1,245 |
hydra | plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/_impl.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import math
from typing import (
Any,
Dict,
List,
MutableMapping,
MutableSequence,
Optional,
Tuple,
Union,
)
import nevergrad as ng
from hydra._internal.deprecation_warning import deprecation_warning
f... | 241 | 9,164 |
hydra | plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/config.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
from typing import Any, Dict, Optional
from hydra.core.config_store import ConfigStore
@dataclass
class ScalarConfigSpec:
"""Representation of all the options to define
a scalar.
"""
# low... | 91 | 2,587 |
hydra | plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/nevergrad_sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List, Optional
from hydra import TaskFunction
from hydra.plugins.sweeper import Sweeper
from hydra.types import HydraContext
from omegaconf import DictConfig
from .config import OptimConf
class NevergradSweeper(Sweeper):
"... | 38 | 1,033 |
hydra | plugins/hydra_nevergrad_sweeper/tests/test_nevergrad_sweeper_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import sys
import warnings
from pathlib import Path
from typing import Any, Optional
import nevergrad as ng
from hydra.core.override_parser.overrides_parser import OverridesParser
from hydra.core.plugins import Plugins
from hydra.plugins.sweeper im... | 290 | 10,068 |
hydra | plugins/hydra_nevergrad_sweeper/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import hydra
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def dummy_training(cfg: DictConfig) -> float:
"""A dummy function to minimize
Minimum is 0.... | 31 | 792 |
hydra | plugins/hydra_optuna_sweeper/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-optuna-sweeper",
version=read_version("hydra_plugins/hydra_optuna_sweeper", "__init__.py... | 36 | 1,334 |
hydra | plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/_impl.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import functools
import logging
import sys
from typing import (
Any,
Callable,
Dict,
List,
MutableSequence,
Optional,
Sequence,
Tuple,
)
import optuna
from hydra.core.override_parser.overrides_parser import Overrides... | 387 | 14,739 |
hydra | plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/config.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Dict, List, NoReturn, Optional
from hydra.core.config_store import ConfigStore
from omegaconf import MISSING
def raise_motpe_removed(*args: Any, **kwargs: Any)... | 247 | 6,702 |
hydra | plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/optuna_sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, List, Optional
from hydra.plugins.sweeper import Sweeper
from hydra.types import HydraContext, TaskFunction
from hydra.utils import instantiate
from omegaconf import DictConfig
class OptunaSweeper(Sweeper):
"""Class to... | 60 | 1,559 |
hydra | plugins/hydra_optuna_sweeper/tests/test_optuna_sweeper_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
from pathlib import Path
from typing import Any, List
import optuna
from hydra.core.override_parser.overrides_parser import OverridesParser
from hydra.core.plugins import Plugins
from hydra.errors import InstantiationException
... | 326 | 11,041 |
hydra | plugins/hydra_optuna_sweeper/example/multi-objective.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Tuple
import hydra
from omegaconf import DictConfig
@hydra.main(config_path="multi-objective-conf", config_name="config")
def binh_and_korn(cfg: DictConfig) -> Tuple[float, float]:
x: float = cfg.x
y: float = cfg.y
... | 20 | 450 |
hydra | plugins/hydra_optuna_sweeper/example/sphere.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import hydra
from omegaconf import DictConfig
@hydra.main(config_path="conf", config_name="config")
def sphere(cfg: DictConfig) -> float:
x: float = cfg.x
y: float = cfg.y
if cfg.get("error", False):
raise RuntimeError("cfg.er... | 19 | 400 |
hydra | plugins/hydra_optuna_sweeper/example/custom-search-space-objective.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import hydra
from omegaconf import DictConfig
from optuna.trial import Trial
@hydra.main(config_path="custom-search-space", config_name="config")
def multi_dimensional_sphere(cfg: DictConfig) -> float:
w: float = cfg.w
x: float = cfg.x
... | 28 | 769 |
hydra | plugins/hydra_submitit_launcher/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-submitit-launcher",
version=read_version("hydra_plugins/hydra_submitit_launcher", "__ini... | 36 | 1,319 |
hydra | plugins/hydra_submitit_launcher/hydra_plugins/hydra_submitit_launcher/submitit_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence
from hydra.core.singleton import Singleton
from hydra.core.utils import JobReturn, filter_overrides, run_job, setup_globals
from hydra.plugins.... | 154 | 5,017 |
hydra | plugins/hydra_submitit_launcher/hydra_plugins/hydra_submitit_launcher/config.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 hydra.core.config_store import ConfigStore
@dataclass
class BaseQueueConf:
"""Configuration shared by all executors"""
submitit_folder: str = "${h... | 104 | 3,461 |
hydra | plugins/hydra_submitit_launcher/tests/test_submitit_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pathlib import Path
from typing import Optional, Type
from unittest.mock import MagicMock, patch
import submitit
from hydra.core.plugins import Plugins
from hydra.plugins.launcher import Launcher
from hydra.test_utils.launcher_common_tests imp... | 141 | 4,291 |
hydra | plugins/hydra_submitit_launcher/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
import time
import hydra
import submitit
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def my_app(cfg: DictConfig) -> None:
env = submitit.JobEn... | 22 | 472 |
hydra | plugins/hydra_ray_launcher/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-ray-launcher",
version=read_version("hydra_plugins/hydra_ray_launcher", "__init__.py"),
... | 37 | 1,219 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/_launcher_util.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
from contextlib import contextmanager
from subprocess import PIPE, Popen
from typing import Any, Dict, Generator, List, Tuple, cast
import ray
from hydra.core.hydra_config import HydraConfig
from hydra.core.singleton import... | 150 | 4,521 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/_core.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from pathlib import Path
from typing import Sequence, cast
import ray
from hydra.core.singleton import Singleton
from hydra.core.utils import JobReturn, configure_log, filter_overrides, setup_globals
from omegaconf import DictConfig,... | 65 | 2,317 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/_config.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import sys
from dataclasses import dataclass, field
from enum import Enum, IntEnum
from importlib import import_module
from importlib.metadata import version
from typing import Any, Dict, List, Optional
from hydra.core.config_store import ConfigSto... | 387 | 12,782 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/_core_aws.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
import tempfile
from pathlib import Path
from typing import Any, Dict, List, Sequence, Union, cast
import cloudpickle # type: ignore
from hydra.core.singleton import Singleton
from hydra.core.utils import JobReturn, config... | 225 | 7,890 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/ray_aws_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any, Optional, Sequence, cast
from hydra.core.utils import JobReturn
from hydra.plugins.launcher import Launcher
from hydra.types import HydraContext, TaskFunction
from omegaconf import DictConfig
from ._config im... | 67 | 1,961 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/ray_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, Optional, Sequence, cast
from hydra.core.utils import JobReturn
from hydra.plugins.launcher import Launcher
from hydra.types import HydraContext, TaskFunction
from omegaconf import DictConfig
class RayLauncher(Launcher):
... | 38 | 1,147 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/_remote_invoke.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# This file is to be rsynced to ray cluster and invoke on the cluster.
import logging
import os
import sys
from pathlib import Path
from typing import List
from urllib.request import urlopen
import cloudpickle # type: ignore
import ray
from hydra... | 94 | 2,757 |
hydra | plugins/hydra_ray_launcher/integration_test_tools/setup_integration_test_ami.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import subprocess
import sys
from datetime import datetime
dependencies = [
"boto3==1.22.6",
"hydra-core>=1.1.2",
"ray[default]==1.12.0",
# https://github.com/aio-libs/aiohttp/issues/6203
"aiohttp==3.8.1",
"cloudpickle==2.0.... | 35 | 959 |
hydra | plugins/hydra_ray_launcher/integration_test_tools/create_integration_test_ami.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
This script is meant to be used for ray launcher integration tests only!
Run this script with AWS admin credentials to create new integration test AMIs if any hydra-core & hydra-ray-launcher
dependencies changes or there's a newer version of p... | 108 | 4,071 |
hydra | plugins/hydra_ray_launcher/tests/ray_aws_launcher_tests_disabled.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""Legacy Ray AWS tests disabled from automatic pytest collection.
Hydra no longer has the AWS test infrastructure required to run these tests.
"""
import logging
import os
import random
import string
import subprocess
import sys
import tempfile
f... | 353 | 11,390 |
hydra | plugins/hydra_ray_launcher/tests/test_ray_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import sys
from pathlib import Path
from types import SimpleNamespace
from typing import Any, cast
from hydra.core.plugins import Plugins
from hydra.plugins.launcher import Launcher
from hydra.test_utils.launcher_common_tests import (
Integrati... | 190 | 5,659 |
hydra | plugins/hydra_ray_launcher/examples/simple/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import time
import hydra
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_name="config", config_path=".")
def my_app(cfg: DictConfig) -> None:
log.info(f"Executing task {cfg.task}")
tim... | 19 | 373 |
hydra | plugins/hydra_ray_launcher/examples/upload_download/train.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import hydra
from model.my_model import MyModel
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_path="conf", config_name="config")
def main(cfg: DictConfig) -> None:
log.info("Start traini... | 21 | 487 |
hydra | plugins/hydra_ray_launcher/examples/upload_download/model/my_model.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from datetime import datetime
from pathlib import Path
log = logging.getLogger(__name__)
class MyModel:
def __init__(self, random_seed: int):
self.random_seed = random_seed
log.info("Init my model")
def sav... | 20 | 670 |
attrs | docs/conf.py | .py | # SPDX-License-Identifier: MIT
import os
from importlib import metadata
from pathlib import Path
# Set canonical URL from the Read the Docs Domain
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
# Tell Jinja2 templates the build is running on Read the Docs
if os.environ.get("READTHEDOCS", "") == "Tr... | 201 | 5,981 |
attrs | tests/dataclass_transform_example.py | .py | # SPDX-License-Identifier: MIT
import attr
import attrs
@attr.define()
class Define:
a: str
b: int
reveal_type(Define.__init__) # noqa: F821
@attr.define()
class DefineConverter:
with_converter: int = attr.field(converter=int)
reveal_type(DefineConverter.__init__) # noqa: F821
DefineConverter(wi... | 63 | 820 |
attrs | tests/test_init_subclass.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `__init_subclass__` related functionality.
"""
import attr
def test_init_subclass_vanilla(slots):
"""
`super().__init_subclass__` can be used if the subclass is not an attrs
class both with dict and slotted classes.
"""
@attr.s(slots=slots)
class... | 67 | 1,368 |
attrs | tests/test_3rd_party.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for compatibility against other Python modules.
"""
import pytest
from hypothesis import given
from .strategies import simple_classes
cloudpickle = pytest.importorskip("cloudpickle")
class TestCloudpickleCompat:
"""
Tests for compatibility with ``cloudpickle``.
... | 32 | 694 |
attrs | tests/utils.py | .py | # SPDX-License-Identifier: MIT
"""
Common helper functions for tests.
"""
from attr import Attribute
from attr._make import NOTHING, _default_init_alias_for, make_class
def simple_class(
eq=False,
order=False,
repr=False,
unsafe_hash=False,
str=False,
slots=False,
frozen=False,
cache... | 70 | 1,294 |
attrs | tests/test_compat.py | .py | # SPDX-License-Identifier: MIT
import types
from typing import Protocol
import pytest
import attr
from attr._compat import _IS_GENERATOR_RESULTS, _lazy_is_generator
@pytest.fixture(name="mp")
def _mp():
return types.MappingProxyType({"x": 42, "y": "foo"})
class TestMetadataProxy:
"""
Ensure propert... | 101 | 2,570 |
attrs | tests/test_next_gen.py | .py | # SPDX-License-Identifier: MIT
"""
Integration tests for next-generation APIs.
"""
import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
@at... | 586 | 14,246 |
attrs | tests/test_dunders.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for dunder methods from `attrib._make`.
"""
import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
... | 1,062 | 29,087 |
attrs | tests/strategies.py | .py | # SPDX-License-Identifier: MIT
"""
Testing strategies for Hypothesis-based tests.
"""
import functools
import keyword
import string
from collections import OrderedDict
from hypothesis import strategies as st
import attr
from .utils import make_class
optional_bool = st.one_of(st.none(), st.booleans())
def gen_... | 219 | 6,219 |
attrs | tests/test_config.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `attr._config`.
"""
import pytest
from attr import _config
class TestConfig:
def test_default(self):
"""
Run validators by default.
"""
assert True is _config._run_validators
def test_set_run_validators(self):
"""
... | 44 | 1,122 |
attrs | tests/test_converters.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `attr.converters`.
"""
import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestConverter:
@pytest.mark.parametr... | 367 | 9,093 |
attrs | tests/test_cmp.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for methods from `attrib._cmp`.
"""
import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
# Test parameters.
EqCSameType = cmp_using(eq=lambda a, b: a == b, class_name="EqCSameType")
PartialOrderCSameType = cmp_using(
eq=lambda a, b: a == b... | 506 | 15,151 |
attrs | tests/test_funcs.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `attr._funcs`.
"""
import re
from collections import OrderedDict
from typing import Generic, NamedTuple, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fie... | 851 | 24,424 |
attrs | tests/test_make.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `attr._make`.
"""
import copy
import functools
import gc
import inspect
import itertools
import pickle
import sys
import types
import unicodedata
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from ... | 3,213 | 86,730 |
attrs | tests/test_pyright.py | .py | # SPDX-License-Identifier: MIT
from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
pytestmark = [
pytest.mark.skipif(
shutil.which("pyright") is None, reason="Requires pyright."
),
]
def parse_pyright_output(test_file: Path) -> se... | 148 | 3,565 |
attrs | tests/test_version_info.py | .py | # SPDX-License-Identifier: MIT
import pytest
from attr import VersionInfo
@pytest.fixture(name="vi")
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
def test_from_string_no_releaselevel(self, vi):
"""
If there is no suffix, the releaselevel becomes "final" by defau... | 64 | 1,608 |
attrs | tests/test_functional.py | .py | # SPDX-License-Identifier: MIT
"""
End-to-end tests.
"""
import copy
import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._compat import PY_3_13_PLUS
from attr._make import NOTHING, Attribute
from attr.e... | 832 | 21,140 |
attrs | tests/test_validators.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `attr.validators`.
"""
import re
import sys
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
... | 1,405 | 37,771 |
attrs | tests/test_import.py | .py | # SPDX-License-Identifier: MIT
import attr
import attrs
class TestImportStar:
def test_from_attr_import_star(self):
"""
import * from attr
"""
# attr_import_star contains `from attr import *`, which cannot
# be done here because *-imports are only allowed on module level.
... | 35 | 1,001 |
attrs | tests/test_slots.py | .py | # SPDX-License-Identifier: MIT
"""
Unit tests for slots-related functionality.
"""
import functools
import pickle
import weakref
from unittest import mock
import pytest
import attr
import attrs
from attr._compat import PY_3_14_PLUS, PYPY
# Pympler doesn't work on PyPy.
try:
from pympler.asizeof import asize... | 1,217 | 27,231 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.