Skip to content

Commit

Permalink
Fix black formatting errors
Browse files Browse the repository at this point in the history
These changes were produced by running `FIX=1 nox -s lint-3.10`

This fixes a number of problems reported by the lint tests.  This does
not fix all errors: bandit still reports security issues due to using
pickle.
  • Loading branch information
Adam Simpkins authored and Jasha10 committed Feb 7, 2023
1 parent 6c9a5fd commit 3051114
Show file tree
Hide file tree
Showing 26 changed files with 28 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# when installed and executed from the command line.
# You don't need to repeat those tests in your own app.
class TestAppOutput:

# Testing the Hydra app as an executable script
# This only works if we are at the root of the hydra-app-example
def test_python_run(self, tmpdir: str) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def is_config(self, config_path: str) -> bool:
return config_path in configs

def list(self, config_path: str, results_filter: Optional[ObjectType]) -> List[str]:

groups: Dict[str, List[str]] = {
"": ["dataset", "level1", "optimizer"],
"dataset": [],
Expand Down
1 change: 0 additions & 1 deletion hydra/_internal/config_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def initialize_sources(self, config_search_path: ConfigSearchPath) -> None:


class ConfigRepository(IConfigRepository):

config_search_path: ConfigSearchPath
sources: List[ConfigSource]

Expand Down
1 change: 0 additions & 1 deletion hydra/_internal/core_plugins/basic_sweeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def split_overrides_to_chunks(
def split_arguments(
overrides: List[Override], max_batch_size: Optional[int]
) -> List[List[List[str]]]:

lists = []
final_overrides = OrderedDict()
for override in overrides:
Expand Down
1 change: 0 additions & 1 deletion hydra/_internal/defaults_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ def _create_defaults_list(
prepend_hydra: bool,
skip_missing: bool,
) -> Tuple[List[ResultDefault], DefaultsTreeNode]:

root = _create_root(config_name=config_name, with_hydra=prepend_hydra)

defaults_tree = _create_defaults_tree(
Expand Down
1 change: 0 additions & 1 deletion hydra/_internal/hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ def _print_all_info(
overrides: List[str],
run_mode: RunMode = RunMode.RUN,
) -> None:

from .. import __version__

self._log_header(f"Hydra {__version__}", filler="=")
Expand Down
4 changes: 0 additions & 4 deletions hydra/_internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def _get_module_name_override() -> Optional[str]:
def detect_calling_file_or_module_from_task_function(
task_function: Any,
) -> Tuple[Optional[str], Optional[str]]:

# if function is decorated, unwrap it
while hasattr(task_function, "__wrapped__"):
task_function = task_function.__wrapped__
Expand Down Expand Up @@ -65,7 +64,6 @@ def detect_calling_file_or_module_from_task_function(
def detect_calling_file_or_module_from_stack_frame(
stack_depth: int,
) -> Tuple[Optional[str], Optional[str]]:

stack = inspect.stack()
frame = stack[stack_depth]
if is_notebook() and "_dh" in frame[0].f_globals:
Expand Down Expand Up @@ -102,7 +100,6 @@ def is_notebook() -> bool:


def detect_task_name(calling_file: Optional[str], calling_module: Optional[str]) -> str:

if calling_file is not None:
target_file = os.path.basename(calling_file)
task_name = get_valid_filename(os.path.splitext(target_file)[0])
Expand Down Expand Up @@ -310,7 +307,6 @@ def _run_hydra(
config_name: Optional[str],
caller_stack_depth: int = 2,
) -> None:

from hydra.core.global_hydra import GlobalHydra

from .hydra import Hydra
Expand Down
1 change: 0 additions & 1 deletion hydra/core/override_parser/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ def _convert_value(value: ParsedElementType) -> Optional[ElementType]:
if isinstance(value, list):
return [Override._convert_value(x) for x in value]
elif isinstance(value, dict):

return {
# We ignore potential type mismatch here so as to let OmegaConf
# raise an explicit error in case of invalid type.
Expand Down
2 changes: 0 additions & 2 deletions hydra/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def _instantiate(self, config: DictConfig) -> Plugin:

@staticmethod
def is_in_toplevel_plugins_module(clazz: str) -> bool:

return clazz.startswith("hydra_plugins.") or clazz.startswith(
"hydra._internal.core_plugins."
)
Expand Down Expand Up @@ -164,7 +163,6 @@ def instantiate_launcher(
def _scan_all_plugins(
modules: List[Any],
) -> Tuple[List[Type[Plugin]], ScanStats]:

stats = ScanStats()
stats.total_time = timer()

Expand Down
52 changes: 28 additions & 24 deletions hydra/extra/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ def hydra_restore_singletons() -> Generator[None, None, None]:


@fixture(scope="function")
def hydra_sweep_runner() -> Callable[
[
Optional[str],
Optional[str],
Optional[TaskFunction],
Optional[str],
Optional[str],
Optional[List[str]],
Optional[Path],
bool,
],
SweepTaskFunction,
]:
def hydra_sweep_runner() -> (
Callable[
[
Optional[str],
Optional[str],
Optional[TaskFunction],
Optional[str],
Optional[str],
Optional[List[str]],
Optional[Path],
bool,
],
SweepTaskFunction,
]
):
def _(
calling_file: Optional[str],
calling_module: Optional[str],
Expand All @@ -59,17 +61,19 @@ def _(


@fixture(scope="function")
def hydra_task_runner() -> Callable[
[
Optional[str],
Optional[str],
Optional[str],
Optional[str],
Optional[List[str]],
bool,
],
TaskTestFunction,
]:
def hydra_task_runner() -> (
Callable[
[
Optional[str],
Optional[str],
Optional[str],
Optional[str],
Optional[List[str]],
bool,
],
TaskTestFunction,
]
):
def _(
calling_file: Optional[str],
calling_module: Optional[str],
Expand Down
1 change: 0 additions & 1 deletion hydra/plugins/completion_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def _query(self, config_name: Optional[str], line: str) -> List[str]:
)
config_matches: List[str] = []
if not exact_match:

run_mode = RunMode.MULTIRUN if parsed_args.multirun else RunMode.RUN
config_matches = []
try:
Expand Down
1 change: 0 additions & 1 deletion hydra/test_utils/launcher_common_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def test_sweep_with_custom_resolver(
overrides: List[str],
tmpdir: Path,
) -> None:

overrides1 = ["hydra/launcher=" + launcher_name] + overrides

def task_func(c: DictConfig) -> Any:
Expand Down
1 change: 0 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def list_plugins(directory: str) -> List[Plugin]:

plugins: List[Plugin] = []
for dir_name in _plugin_directories:

abspath = os.path.join(BASE, directory, dir_name)
setup_py = os.path.join(abspath, "setup.py")
name_and_classifiers: List[str] = subprocess.check_output(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ExperimentConfig:

@dataclass
class ClientConfig:

verbose_logging: bool = False

# set random seed here to make Ax results reproducible
Expand All @@ -43,7 +42,6 @@ class ClientConfig:

@dataclass
class AxConfig:

# max_trials is application-specific. Tune it for your use case
max_trials: int = 10
early_stop: EarlyStopConfig = field(default_factory=EarlyStopConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def setup(
)

def sweep(self, arguments: List[str]) -> None:

assert self.config is not None
assert self.launcher is not None
assert self.job_idx is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ScalarConfigSpec:

@dataclass
class OptimConf:

# name of the Nevergrad optimizer to use. Here is a sample:
# - "OnePlusOne" extremely simple and robust, especially at low budget, but
# tends to converge early.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class MOTPESamplerConfig(SamplerConfig):

@dataclass
class DistributionConfig:

# Type of distribution. "int", "float" or "categorical"
type: DistributionType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def launch_jobs(
**launcher.create_update_cluster,
)
with tempfile.TemporaryDirectory() as local_tmp_download_dir:

with ray_tmp_dir(config, launcher.ray_cfg.run_env.name) as remote_tmp_dir:
sdk.rsync(
config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def _run_command(command: str) -> str:


def run(py_version):

_run_command("rm /home/ubuntu/ray_bootstrap_config.yaml")

_run_command(f"conda create -n hydra_{py_version} python={py_version} -y")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class BaseSubmititLauncher(Launcher):

_EXECUTOR = "abstract"

def __init__(self, **params: Any) -> None:
Expand Down
1 change: 0 additions & 1 deletion tests/instantiate/test_instantiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ def test_instantiate_bad_adam_conf(instantiate_func: Any, recwarn: Any) -> None:


def test_instantiate_with_missing_module(instantiate_func: Any) -> None:

_target_ = "tests.instantiate.ClassWithMissingModule"
with raises(
InstantiationException,
Expand Down
1 change: 0 additions & 1 deletion tests/test_env_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


def test_env_defaults(tmpdir: Path) -> None:

cmd = [
"tests/test_apps/custom_env_defaults/my_app.py",
"hydra.run.dir=" + str(tmpdir),
Expand Down
1 change: 0 additions & 1 deletion tests/test_examples/test_tutorials_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def test_sweeping_example(
def test_advanced_ad_hoc_composition(
monkeypatch: Any, tmpdir: Path, args: List[str], expected: Any
) -> None:

monkeypatch.setenv("USER", "test_user")
cmd = [
"examples/advanced/ad_hoc_composition/hydra_compose_example.py",
Expand Down
2 changes: 0 additions & 2 deletions tests/test_hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,6 @@ def test_hydra_mode(
]
)
if error:

expected = normalize_newlines(expected_output)
ret = run_with_error(cmd)
assert_regex_match(
Expand All @@ -1834,7 +1833,6 @@ def test_hydra_mode(
to_name="Actual output",
)
elif warning:

out, err = run_python_script(cmd, allow_warnings=True)
assert_regex_match(
from_line=expected_output,
Expand Down
1 change: 0 additions & 1 deletion tools/configen/configen/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class ModuleConf:

@dataclass
class ConfigenConf:

# output dir
output_dir: str = MISSING

Expand Down
2 changes: 0 additions & 2 deletions tools/configen/configen/configen.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class ClassInfo:


def is_incompatible(type_: Type[Any]) -> bool:

opt = _resolve_optional(type_)
# Unions are not supported (Except Optional)
if not opt[0] and is_union_annotation(type_):
Expand Down Expand Up @@ -131,7 +130,6 @@ def is_incompatible(type_: Type[Any]) -> bool:


def get_default_flags(module: ModuleConf) -> List[Parameter]:

def_flags: List[Parameter] = []

if module.default_flags._convert_ is not None:
Expand Down

0 comments on commit 3051114

Please sign in to comment.