Skip to content

Commit

Permalink
drop py3.7 & fix CI (facebookresearch#2854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 authored Feb 29, 2024
1 parent d0b8e73 commit 4db334b
Show file tree
Hide file tree
Showing 72 changed files with 162 additions and 294 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:
# Misc
coverage:
docker:
- image: circleci/python:3.7
- image: circleci/python:3.8
steps:
- checkout
- run: sudo pip install nox --progress-bar off
Expand All @@ -287,19 +287,19 @@ workflows:
- test_macos:
matrix:
parameters:
py_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11"]
- test_linux:
matrix:
parameters:
py_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11"]
- test_win:
matrix:
parameters:
py_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11"]
- test_linux_omc_dev:
matrix:
parameters:
py_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11"]


plugin_tests:
Expand All @@ -308,17 +308,17 @@ workflows:
- test_plugin_linux:
matrix:
parameters:
py_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11"]
test_plugin: [<< pipeline.parameters.test_plugins >>]
- test_plugin_macos:
matrix:
parameters:
py_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11"]
test_plugin: [<< pipeline.parameters.test_plugins >>]
- test_plugin_win:
matrix:
parameters:
py_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
py_version: ["3.8", "3.9", "3.10", "3.11"]
test_plugin: [<< pipeline.parameters.test_plugins >>]


Expand Down
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ max-line-length = 119
copyright-check = True
select = E,F,W,C
copyright-regexp=Copyright \(c\) Facebook, Inc. and its affiliates. All Rights Reserved
ignore=W503,E203
ignore=W503,E203,E701,E704
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
files: 'hydra/.*'
Expand All @@ -10,7 +10,7 @@ repos:
files: 'tools/.*'

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.2.0
hooks:
- id: black

Expand All @@ -20,7 +20,7 @@ repos:
- id: flake8

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.30.0
rev: v1.35.1
hooks:
- id: yamllint
args: [-c=.yamllint, --strict]
3 changes: 1 addition & 2 deletions examples/instantiate/object/my_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@


class DBConnection:
def connect(self) -> None:
...
def connect(self) -> None: ...


class MySQLConnection(DBConnection):
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/example_configsource_plugin/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"License :: OSI Approved :: MIT License",
# Hydra uses Python version and Operating system to determine
# In which environments to test this plugin
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/example_generic_plugin/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"License :: OSI Approved :: MIT License",
# Hydra uses Python version and Operating system to determine
# In which environments to test this plugin
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/example_launcher_plugin/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"License :: OSI Approved :: MIT License",
# Hydra uses Python version and Operating system to determine
# In which environments to test this plugin
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/example_registered_plugin/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"License :: OSI Approved :: MIT License",
# Hydra uses Python version and Operating system to determine
# In which environments to test this plugin
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/example_searchpath_plugin/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"License :: OSI Approved :: MIT License",
# Hydra uses Python version and Operating system to determine
# In which environments to test this plugin
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/example_sweeper_plugin/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"License :: OSI Approved :: MIT License",
# Hydra uses Python version and Operating system to determine
# In which environments to test this plugin
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def test_launched_jobs(hydra_sweep_runner: TSweepRunner) -> None:
)
],
)
class TestExampleSweeper(LauncherTestSuite):
...
class TestExampleSweeper(LauncherTestSuite): ...


# Many sweepers are batching jobs in groups.
Expand All @@ -73,8 +72,7 @@ class TestExampleSweeper(LauncherTestSuite):
)
],
)
class TestExampleSweeperWithBatching(BatchedSweeperTestSuite):
...
class TestExampleSweeperWithBatching(BatchedSweeperTestSuite): ...


# Run integration test suite with the basic launcher and this sweeper
Expand Down
2 changes: 1 addition & 1 deletion hydra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved

# Source of truth for Hydra's version
__version__ = "1.4.0.dev0"
__version__ = "1.4.0.dev1"
from hydra import utils
from hydra.errors import MissingConfigException
from hydra.main import main
Expand Down
21 changes: 7 additions & 14 deletions hydra/_internal/config_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,27 @@

class IConfigRepository(ABC):
@abstractmethod
def get_schema_source(self) -> ConfigSource:
...
def get_schema_source(self) -> ConfigSource: ...

@abstractmethod
def load_config(self, config_path: str) -> Optional[ConfigResult]:
...
def load_config(self, config_path: str) -> Optional[ConfigResult]: ...

@abstractmethod
def group_exists(self, config_path: str) -> bool:
...
def group_exists(self, config_path: str) -> bool: ...

@abstractmethod
def config_exists(self, config_path: str) -> bool:
...
def config_exists(self, config_path: str) -> bool: ...

@abstractmethod
def get_group_options(
self, group_name: str, results_filter: Optional[ObjectType] = ObjectType.CONFIG
) -> List[str]:
...
) -> List[str]: ...

@abstractmethod
def get_sources(self) -> List[ConfigSource]:
...
def get_sources(self) -> List[ConfigSource]: ...

@abstractmethod
def initialize_sources(self, config_search_path: ConfigSearchPath) -> None:
...
def initialize_sources(self, config_search_path: ConfigSearchPath) -> None: ...


class ConfigRepository(IConfigRepository):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ def scheme() -> str:

def _read_config(self, res: Any) -> ConfigResult:
try:
if sys.version_info[0:2] >= (3, 8) and isinstance(res, zipfile.Path):
if isinstance(res, zipfile.Path):
# zipfile does not support encoding, read() calls returns bytes.
f = res.open()
else:
f = res.open(encoding="utf-8")
header_text = f.read(512)
if isinstance(header_text, bytes):
# if header is bytes, utf-8 decode (zipfile path)
header_text = header_text.decode("utf-8")
header = ConfigSource._get_header_dict(header_text)
header_text_str = header_text.decode("utf-8")
else:
header_text_str = header_text
header = ConfigSource._get_header_dict(header_text_str)
f.seek(0)
cfg = OmegaConf.load(f)
return ConfigResult(
Expand Down
21 changes: 7 additions & 14 deletions hydra/core/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,21 @@ def load_configuration(
run_mode: RunMode,
from_shell: bool = True,
validate_sweep_overrides: bool = True,
) -> DictConfig:
...
) -> DictConfig: ...

@abstractmethod
def load_sweep_config(
self, master_config: DictConfig, sweep_overrides: List[str]
) -> DictConfig:
...
) -> DictConfig: ...

@abstractmethod
def get_search_path(self) -> ConfigSearchPath:
...
def get_search_path(self) -> ConfigSearchPath: ...

@abstractmethod
def get_sources(self) -> List[ConfigSource]:
...
def get_sources(self) -> List[ConfigSource]: ...

@abstractmethod
def list_groups(self, parent_name: str) -> List[str]:
...
def list_groups(self, parent_name: str) -> List[str]: ...

@abstractmethod
def get_group_options(
Expand All @@ -51,14 +46,12 @@ def get_group_options(
results_filter: Optional[ObjectType] = ObjectType.CONFIG,
config_name: Optional[str] = None,
overrides: Optional[List[str]] = None,
) -> List[str]:
...
) -> List[str]: ...

@abstractmethod
def compute_defaults_list(
self,
config_name: Optional[str],
overrides: List[str],
run_mode: RunMode,
) -> Any:
...
) -> Any: ...
3 changes: 1 addition & 2 deletions hydra/core/config_search_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class SearchPathQuery:

class ConfigSearchPath(ABC):
@abstractmethod
def get_path(self) -> MutableSequence[SearchPathElement]:
...
def get_path(self) -> MutableSequence[SearchPathElement]: ...

@abstractmethod
def append(
Expand Down
3 changes: 1 addition & 2 deletions hydra/core/config_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def store(
group=group, name=name, node=node, package=package, provider=self.provider
)

def __exit__(self, exc_type: Any, exc_value: Any, exc_traceback: Any) -> Any:
...
def __exit__(self, exc_type: Any, exc_value: Any, exc_traceback: Any) -> Any: ...


@dataclass
Expand Down
18 changes: 6 additions & 12 deletions hydra/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from typing import Optional, Sequence


class HydraException(Exception):
...
class HydraException(Exception): ...


class CompactHydraException(HydraException):
...
class CompactHydraException(HydraException): ...


class OverrideParseException(CompactHydraException):
Expand All @@ -17,16 +15,13 @@ def __init__(self, override: str, message: str) -> None:
self.message = message


class InstantiationException(CompactHydraException):
...
class InstantiationException(CompactHydraException): ...


class ConfigCompositionException(CompactHydraException):
...
class ConfigCompositionException(CompactHydraException): ...


class SearchPathException(CompactHydraException):
...
class SearchPathException(CompactHydraException): ...


class MissingConfigException(IOError, ConfigCompositionException):
Expand All @@ -41,5 +36,4 @@ def __init__(
self.options = options


class HydraDeprecationError(HydraException):
...
class HydraDeprecationError(HydraException): ...
9 changes: 7 additions & 2 deletions hydra/experimental/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(
config_path=config_path,
job_name=job_name,
caller_stack_depth=caller_stack_depth + 1,
version_base=str(version.getbase()),
)

def __enter__(self, *args: Any, **kwargs: Any) -> None:
Expand Down Expand Up @@ -80,7 +81,9 @@ def __init__(self, config_module: str, job_name: str = "app") -> None:
deprecation_warning(message=message)

self.delegate = real_initialize_config_module(
config_module=config_module, job_name=job_name
config_module=config_module,
job_name=job_name,
version_base=str(version.getbase()),
)

def __enter__(self, *args: Any, **kwargs: Any) -> None:
Expand Down Expand Up @@ -116,7 +119,9 @@ def __init__(self, config_dir: str, job_name: str = "app") -> None:
deprecation_warning(message=message)

self.delegate = real_initialize_config_dir(
config_dir=config_dir, job_name=job_name
config_dir=config_dir,
job_name=job_name,
version_base=str(version.getbase()),
)

def __enter__(self, *args: Any, **kwargs: Any) -> None:
Expand Down
Loading

0 comments on commit 4db334b

Please sign in to comment.