From b9544f116c76b2cf928609804ade54c1abab898a Mon Sep 17 00:00:00 2001 From: Jasha <8935917+Jasha10@users.noreply.github.com> Date: Tue, 29 Mar 2022 22:58:40 -0500 Subject: [PATCH] Support Python3.10 --- .circleci/config.yml | 14 ++++++------- .../example_configsource_plugin/setup.py | 1 + .../plugins/example_generic_plugin/setup.py | 1 + .../plugins/example_launcher_plugin/setup.py | 1 + .../example_registered_plugin/setup.py | 1 + .../example_searchpath_plugin/setup.py | 1 + .../plugins/example_sweeper_plugin/setup.py | 1 + hydra/_internal/utils.py | 2 +- hydra/core/plugins.py | 20 ++++++++++++++++--- news/1856.feature | 1 + noxfile.py | 10 ++++++++-- plugins/hydra_ax_sweeper/news/1856.feature | 1 + plugins/hydra_ax_sweeper/setup.py | 1 + plugins/hydra_colorlog/news/1856.feature | 1 + plugins/hydra_colorlog/setup.py | 1 + .../hydra_joblib_launcher/news/1856.feature | 1 + plugins/hydra_joblib_launcher/setup.py | 1 + .../hydra_nevergrad_sweeper/news/1856.feature | 1 + plugins/hydra_nevergrad_sweeper/setup.py | 1 + .../hydra_optuna_sweeper/news/1856.feature | 1 + plugins/hydra_optuna_sweeper/setup.py | 1 + plugins/hydra_rq_launcher/news/1856.feature | 1 + plugins/hydra_rq_launcher/setup.py | 1 + .../hydra_submitit_launcher/news/1856.feature | 1 + plugins/hydra_submitit_launcher/setup.py | 1 + setup.py | 1 + 26 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 news/1856.feature create mode 100644 plugins/hydra_ax_sweeper/news/1856.feature create mode 100644 plugins/hydra_colorlog/news/1856.feature create mode 100644 plugins/hydra_joblib_launcher/news/1856.feature create mode 100644 plugins/hydra_nevergrad_sweeper/news/1856.feature create mode 100644 plugins/hydra_optuna_sweeper/news/1856.feature create mode 100644 plugins/hydra_rq_launcher/news/1856.feature create mode 100644 plugins/hydra_submitit_launcher/news/1856.feature diff --git a/.circleci/config.yml b/.circleci/config.yml index fdd8c35ad5e..c9cffda9c96 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -271,19 +271,19 @@ workflows: - test_macos: matrix: parameters: - py_version: ["3.6", "3.7", "3.8", "3.9"] + py_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] - test_linux: matrix: parameters: - py_version: ["3.6", "3.7", "3.8", "3.9"] + py_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] - test_win: matrix: parameters: - py_version: ["3.6", "3.7", "3.8", "3.9"] + py_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] - test_linux_omc_dev: matrix: parameters: - py_version: ["3.6", "3.7", "3.8", "3.9"] + py_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] plugin_tests: @@ -292,17 +292,17 @@ workflows: - test_plugin_linux: matrix: parameters: - py_version: ["3.6", "3.7", "3.8", "3.9"] + py_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] test_plugin: [<< pipeline.parameters.test_plugins >>] - test_plugin_macos: matrix: parameters: - py_version: ["3.6", "3.7", "3.8", "3.9"] + py_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] test_plugin: [<< pipeline.parameters.test_plugins >>] - test_plugin_win: matrix: parameters: - py_version: ["3.6", "3.7", "3.8", "3.9"] + py_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] test_plugin: [<< pipeline.parameters.test_plugins >>] diff --git a/examples/plugins/example_configsource_plugin/setup.py b/examples/plugins/example_configsource_plugin/setup.py index 1c6bc19e30e..a2f478cd74a 100644 --- a/examples/plugins/example_configsource_plugin/setup.py +++ b/examples/plugins/example_configsource_plugin/setup.py @@ -23,6 +23,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", ], install_requires=[ diff --git a/examples/plugins/example_generic_plugin/setup.py b/examples/plugins/example_generic_plugin/setup.py index 85c09f067a0..4da9ff7294b 100644 --- a/examples/plugins/example_generic_plugin/setup.py +++ b/examples/plugins/example_generic_plugin/setup.py @@ -23,6 +23,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", ], install_requires=[ diff --git a/examples/plugins/example_launcher_plugin/setup.py b/examples/plugins/example_launcher_plugin/setup.py index df428a9f88a..63f8444022b 100644 --- a/examples/plugins/example_launcher_plugin/setup.py +++ b/examples/plugins/example_launcher_plugin/setup.py @@ -23,6 +23,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", ], install_requires=[ diff --git a/examples/plugins/example_registered_plugin/setup.py b/examples/plugins/example_registered_plugin/setup.py index d55d1053b8f..55dd3afd6b5 100644 --- a/examples/plugins/example_registered_plugin/setup.py +++ b/examples/plugins/example_registered_plugin/setup.py @@ -23,6 +23,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", ], install_requires=[ diff --git a/examples/plugins/example_searchpath_plugin/setup.py b/examples/plugins/example_searchpath_plugin/setup.py index 125a139f1df..e49d63caacf 100644 --- a/examples/plugins/example_searchpath_plugin/setup.py +++ b/examples/plugins/example_searchpath_plugin/setup.py @@ -25,6 +25,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", ], install_requires=[ diff --git a/examples/plugins/example_sweeper_plugin/setup.py b/examples/plugins/example_sweeper_plugin/setup.py index d62e4b4d5a7..62655266ae0 100644 --- a/examples/plugins/example_sweeper_plugin/setup.py +++ b/examples/plugins/example_sweeper_plugin/setup.py @@ -23,6 +23,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", ], install_requires=[ diff --git a/hydra/_internal/utils.py b/hydra/_internal/utils.py index 2bf2872e51d..11e2c4c3425 100644 --- a/hydra/_internal/utils.py +++ b/hydra/_internal/utils.py @@ -282,7 +282,7 @@ class FakeTracebackType: assert iter_tb.tb_next is not None iter_tb = iter_tb.tb_next - print_exception(etype=None, value=ex, tb=final_tb) # type: ignore + print_exception(None, value=ex, tb=final_tb) # type: ignore sys.stderr.write( "\nSet the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.\n" ) diff --git a/hydra/core/plugins.py b/hydra/core/plugins.py index ccb807da689..be1cdd5b799 100644 --- a/hydra/core/plugins.py +++ b/hydra/core/plugins.py @@ -1,5 +1,6 @@ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import importlib +import importlib.util import inspect import pkgutil import sys @@ -181,10 +182,23 @@ def _scan_all_plugins( if module_name.startswith("_") and not module_name.startswith("__"): continue import_time = timer() - m = importer.find_module(modname) # type: ignore - assert m is not None + with warnings.catch_warnings(record=True) as recorded_warnings: - loaded_mod = m.load_module(modname) + if sys.version_info < (3, 10): + m = importer.find_module(modname) # type: ignore + assert m is not None + loaded_mod = m.load_module(modname) + else: + spec = importer.find_spec(modname) + assert spec is not None + if modname in sys.modules: + loaded_mod = sys.modules[modname] + else: + loaded_mod = importlib.util.module_from_spec(spec) + if loaded_mod is not None: + spec.loader.exec_module(loaded_mod) + sys.modules[modname] = loaded_mod + import_time = timer() - import_time if len(recorded_warnings) > 0: sys.stderr.write( diff --git a/news/1856.feature b/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/noxfile.py b/noxfile.py index 81af690503c..c1daafcda29 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,7 +12,7 @@ BASE = os.path.abspath(os.path.dirname(__file__)) -DEFAULT_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] +DEFAULT_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] DEFAULT_OS_NAMES = ["Linux", "MacOS", "Windows"] PYTHON_VERSIONS = os.environ.get( @@ -546,6 +546,7 @@ def test_jupyter_notebooks(session): install_hydra(session, ["pip", "install", "-e"]) args = pytest_args( "--nbval", + "-W ignore::DeprecationWarning", "-W ignore::ResourceWarning", "examples/jupyter_notebooks/compose_configs_in_notebook.ipynb", ) @@ -555,7 +556,12 @@ def test_jupyter_notebooks(session): for notebook in [ file for file in notebooks_dir.iterdir() if str(file).endswith(".ipynb") ]: - args = pytest_args("--nbval", "-W ignore::ResourceWarning", str(notebook)) + args = pytest_args( + "--nbval", + "-W ignore::DeprecationWarning", + "-W ignore::ResourceWarning", + str(notebook), + ) args = [x for x in args if x != "-Werror"] session.run(*args, silent=SILENT) diff --git a/plugins/hydra_ax_sweeper/news/1856.feature b/plugins/hydra_ax_sweeper/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/plugins/hydra_ax_sweeper/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/plugins/hydra_ax_sweeper/setup.py b/plugins/hydra_ax_sweeper/setup.py index 7a5cf8e9425..844723f05fc 100644 --- a/plugins/hydra_ax_sweeper/setup.py +++ b/plugins/hydra_ax_sweeper/setup.py @@ -20,6 +20,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Development Status :: 4 - Beta", diff --git a/plugins/hydra_colorlog/news/1856.feature b/plugins/hydra_colorlog/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/plugins/hydra_colorlog/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/plugins/hydra_colorlog/setup.py b/plugins/hydra_colorlog/setup.py index 92233a1c8ce..4813ee788c0 100644 --- a/plugins/hydra_colorlog/setup.py +++ b/plugins/hydra_colorlog/setup.py @@ -21,6 +21,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", ], install_requires=["colorlog", "hydra-core>=1.0.0"], diff --git a/plugins/hydra_joblib_launcher/news/1856.feature b/plugins/hydra_joblib_launcher/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/plugins/hydra_joblib_launcher/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/plugins/hydra_joblib_launcher/setup.py b/plugins/hydra_joblib_launcher/setup.py index 21c6cbbde59..9a1d2b87d13 100644 --- a/plugins/hydra_joblib_launcher/setup.py +++ b/plugins/hydra_joblib_launcher/setup.py @@ -20,6 +20,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", diff --git a/plugins/hydra_nevergrad_sweeper/news/1856.feature b/plugins/hydra_nevergrad_sweeper/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/plugins/hydra_nevergrad_sweeper/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/plugins/hydra_nevergrad_sweeper/setup.py b/plugins/hydra_nevergrad_sweeper/setup.py index d0303350e35..c32acc87d88 100644 --- a/plugins/hydra_nevergrad_sweeper/setup.py +++ b/plugins/hydra_nevergrad_sweeper/setup.py @@ -21,6 +21,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", "Development Status :: 4 - Beta", ], diff --git a/plugins/hydra_optuna_sweeper/news/1856.feature b/plugins/hydra_optuna_sweeper/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/plugins/hydra_optuna_sweeper/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/plugins/hydra_optuna_sweeper/setup.py b/plugins/hydra_optuna_sweeper/setup.py index 2dd9246b813..389cd9e1bdb 100644 --- a/plugins/hydra_optuna_sweeper/setup.py +++ b/plugins/hydra_optuna_sweeper/setup.py @@ -21,6 +21,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Development Status :: 4 - Beta", diff --git a/plugins/hydra_rq_launcher/news/1856.feature b/plugins/hydra_rq_launcher/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/plugins/hydra_rq_launcher/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/plugins/hydra_rq_launcher/setup.py b/plugins/hydra_rq_launcher/setup.py index bb30e6403dd..b95fe3a6b46 100644 --- a/plugins/hydra_rq_launcher/setup.py +++ b/plugins/hydra_rq_launcher/setup.py @@ -21,6 +21,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: MacOS", "Operating System :: POSIX :: Linux", ], diff --git a/plugins/hydra_submitit_launcher/news/1856.feature b/plugins/hydra_submitit_launcher/news/1856.feature new file mode 100644 index 00000000000..bb4351ee8a5 --- /dev/null +++ b/plugins/hydra_submitit_launcher/news/1856.feature @@ -0,0 +1 @@ +Support for Python 3.10 diff --git a/plugins/hydra_submitit_launcher/setup.py b/plugins/hydra_submitit_launcher/setup.py index 28c4438c67f..91971c42154 100644 --- a/plugins/hydra_submitit_launcher/setup.py +++ b/plugins/hydra_submitit_launcher/setup.py @@ -20,6 +20,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: MacOS", "Operating System :: POSIX :: Linux", "Development Status :: 4 - Beta", diff --git a/setup.py b/setup.py index 42642d6f252..a440649b728 100644 --- a/setup.py +++ b/setup.py @@ -50,6 +50,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows",