From 8b8b34488ae7acea63e570dc7d3183ceae5a4b9d Mon Sep 17 00:00:00 2001 From: Han Wang Date: Tue, 20 Aug 2024 23:10:38 -0700 Subject: [PATCH] Update Tune (#67) * Update Tune * update * update * update * update * update * update * update * fix tests --- .devcontainer/devcontainer.json | 59 +++++++++++++++++---------- .github/workflows/publish.yml | 4 +- .github/workflows/test.yml | 10 +++-- .github/workflows/testwin.yml | 2 +- .pre-commit-config.yaml | 6 ++- .pylintrc | 2 +- RELEASE.md | 4 ++ requirements.txt | 3 +- setup.cfg | 2 +- setup.py | 8 ++-- tests/tune/concepts/test_flow.py | 8 ++-- tests/tune/concepts/test_logger.py | 18 ++++++++ tests/tune/noniterative/test_study.py | 21 +++++++--- tests/tune_sklearn/test_suggest.py | 13 ++++-- tune/concepts/logger.py | 42 ++++++++++++++++++- tune/noniterative/objective.py | 10 +++-- tune_hyperopt/optimizer.py | 14 ++++--- tune_optuna/optimizer.py | 14 ++++--- tune_sklearn/objective.py | 6 +-- tune_tensorflow/spec.py | 4 +- tune_tensorflow/utils.py | 6 +-- tune_test/local_optmizer.py | 4 +- tune_version/__init__.py | 2 +- 23 files changed, 187 insertions(+), 75 deletions(-) create mode 100644 tests/tune/concepts/test_logger.py diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 06f078c..afd5392 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,29 +1,46 @@ { "name": "Fugue Development Environment", - "image": "fugueproject/devenv:latest", - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "python.pythonPath": "/usr/local/bin/python", - "python.linting.enabled": true, - "python.linting.pylintEnabled": true, - "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", - "python.formatting.blackPath": "/usr/local/py-utils/bin/black", - "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", - "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", - "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", - "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", - "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", - "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", - "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + "image": "mcr.microsoft.com/vscode/devcontainers/python:3.10", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/local/bin/python", + "python.defaultInterpreterPath": "/usr/local/bin/python", + "editor.defaultFormatter": "ms-python.black-formatter", + "isort.interpreter": [ + "/usr/local/bin/python" + ], + "flake8.interpreter": [ + "/usr/local/bin/python" + ], + "pylint.interpreter": [ + "/usr/local/bin/python" + ], + "black-formatter.interpreter": [ + "/usr/local/bin/python" + ] + }, + "extensions": [ + "ms-python.python", + "ms-python.isort", + "ms-python.flake8", + "ms-python.pylint", + "ms-python.mypy", + "ms-python.black-formatter", + "GitHub.copilot", + "njpwerner.autodocstring" + ] + } }, - "extensions": [ - "ms-python.python" - ], "forwardPorts": [ 8888 ], "postCreateCommand": "make devenv", - "mounts": [ - "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" - ] + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2.11.0": {}, + "ghcr.io/devcontainers/features/java:1": { + "version": "11" + } + } } diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a8de40b..e31bb51 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,8 +25,8 @@ jobs: - name: Build and publish env: RELEASE_TAG: ${{ github.event.release.tag_name }} - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | make package twine upload dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 26158aa..bf023fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9, "3.10"] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 @@ -27,7 +27,9 @@ jobs: - name: Test run: make test - name: "Upload coverage to Codecov" - if: matrix.python-version == 3.7 - uses: codecov/codecov-action@v1 + if: matrix.python-version == '3.10' + uses: codecov/codecov-action@v4 with: - fail_ci_if_error: true + fail_ci_if_error: false + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/testwin.yml b/.github/workflows/testwin.yml index 7a5e3ee..286d36d 100644 --- a/.github/workflows/testwin.yml +++ b/.github/workflows/testwin.yml @@ -14,7 +14,7 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: [ 3.7, 3.8, 3.9, "3.10"] + python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 499de78..0a15b5a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,9 +34,13 @@ repos: - flake8-tidy-imports - pycodestyle - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.782 + rev: v0.971 hooks: - id: mypy + - repo: https://github.com/pre-commit/mirrors-pylint + rev: v2.6.0 + hooks: + - id: pylint - repo: https://github.com/ambv/black rev: 22.3.0 hooks: diff --git a/.pylintrc b/.pylintrc index ddb5bc5..d834307 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,3 +1,3 @@ [MESSAGES CONTROL] -disable = C0103,C0114,C0115,C0116,C0122,C0200,C0201,C0302,C0411,C0415,E0401,E0712,E1130,R0201,R0205,R0801,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R1705,R1710,R1718,R1720,R1724,W0102,W0107,W0108,W0201,W0212,W0221,W0223,W0237,W0511,W0613,W0631,W0640,W0703,W0707,W1116 +disable = C0103,C0114,C0115,C0116,C0122,C0200,C0201,C0302,C0411,C0415,E0401,E0712,E1130,E1136,R0201,R0205,R0801,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R1705,R1710,R1718,R1720,R1724,W0102,W0107,W0108,W0201,W0212,W0221,W0223,W0237,W0511,W0613,W0631,W0640,W0703,W0707,W1116 # TODO: R0205: inherits from object, can be safely removed diff --git a/RELEASE.md b/RELEASE.md index b635b20..935dba5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,9 @@ # Release Notes +## 0.1.6 + +- Support Python 3.12 + ## 0.1.5 - Refactor `FunctionWrapper`, remove the Fugue contraint diff --git a/requirements.txt b/requirements.txt index 15d338d..4263206 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,8 +19,7 @@ sphinx-autodoc-typehints nbsphinx flask -pyspark -dask[dataframe,distributed] +fugue[spark,dask] # publish to pypi wheel diff --git a/setup.cfg b/setup.cfg index 5dc717d..62d35e9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,7 +19,7 @@ spark_options = spark.sql.adaptive.enabled: false [flake8] -ignore = E24,E203,W503,C408,A003,W504,C407,C405 +ignore = E24,E203,W503,C408,A003,A005,W504,C407,C405 max-line-length = 88 format = pylint exclude = .svc,CVS,.bzr,.hg,.git,__pycache__,venv,tests/*,docs/* diff --git a/setup.py b/setup.py index 87bbaac..88f1d57 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def get_version() -> str: author_email="goodwanghan@gmail.com", keywords="hyper parameter hyperparameter tuning tune tuner optimzation", url="http://github.com/fugue-project/tune", - install_requires=["fugue", "cloudpickle", "triad>=0.8.4"], + install_requires=["fugue", "cloudpickle", "triad>=0.8.4", "fs"], extras_require={ "hyperopt": ["hyperopt"], "optuna": ["optuna"], @@ -54,14 +54,14 @@ def get_version() -> str: "Intended Audience :: Developers", "Topic :: Software Development :: Libraries :: Python Modules", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3 :: Only", ], - python_requires=">=3.6", + python_requires=">=3.8", entry_points={ "tune.plugins": [ "mlflow = tune_mlflow[mlflow]", diff --git a/tests/tune/concepts/test_flow.py b/tests/tune/concepts/test_flow.py index 427f6c8..47c70d6 100644 --- a/tests/tune/concepts/test_flow.py +++ b/tests/tune/concepts/test_flow.py @@ -56,7 +56,7 @@ def test_trial_report(): report = copy.copy( TrialReport( trial, - metric=np.float(0.1), + metric=np.float64(0.1), params={"c": Rand(1, 2)}, metadata={"d": 4}, cost=2.0, @@ -73,7 +73,7 @@ def test_trial_report(): assert 0.1 == report.sort_metric report = copy.deepcopy( - TrialReport(trial, metric=np.float(0.111), cost=2.0, rung=4, sort_metric=1.23) + TrialReport(trial, metric=np.float64(0.111), cost=2.0, rung=4, sort_metric=1.23) ) assert trial is report.trial report = cloudpickle.loads(cloudpickle.dumps(report)) @@ -109,7 +109,7 @@ def test_trial_report(): assert 5 == report.with_rung(5).rung td = trial.with_dfs({"a": pd.DataFrame}) - report = TrialReport(td, metric=np.float(0.1)) + report = TrialReport(td, metric=np.float64(0.1)) assert 0 == len(report.trial.dfs) @@ -177,7 +177,7 @@ def test_trial_report_heap(): def test_trial_decision(): trial = Trial("abc", {"a": 1}, {"b": Rand(0, 2)}) report = TrialReport( - trial, metric=np.float(0.1), params={"c": Rand(0, 3)}, metadata={"d": 4} + trial, metric=np.float64(0.1), params={"c": Rand(0, 3)}, metadata={"d": 4} ) decision = TrialDecision( report, budget=0.0, should_checkpoint=True, metadata={"x": 1}, reason="p" diff --git a/tests/tune/concepts/test_logger.py b/tests/tune/concepts/test_logger.py new file mode 100644 index 0000000..3dd4d2b --- /dev/null +++ b/tests/tune/concepts/test_logger.py @@ -0,0 +1,18 @@ +from tune.concepts.logger import ( + MetricLogger, + get_current_metric_logger, + set_current_metric_logger, +) + + +def test_logger_context(): + m1 = MetricLogger() + m2 = MetricLogger() + + with set_current_metric_logger(m1) as mm1: + assert get_current_metric_logger() is m1 + assert mm1 is m1 + with set_current_metric_logger(m2) as mm2: + assert get_current_metric_logger() is m2 + assert mm2 is m2 + assert get_current_metric_logger() is m1 diff --git a/tests/tune/noniterative/test_study.py b/tests/tune/noniterative/test_study.py index 1a47dd9..f8f5716 100644 --- a/tests/tune/noniterative/test_study.py +++ b/tests/tune/noniterative/test_study.py @@ -3,9 +3,11 @@ import pandas as pd from fugue import FugueWorkflow from pytest import raises + from tune import optimize_noniterative, suggest_for_noniterative_objective from tune.concepts.dataset import TuneDatasetBuilder from tune.concepts.flow import Monitor +from tune.concepts.logger import MetricLogger, get_current_metric_logger from tune.concepts.space import Grid, Space from tune.constants import TUNE_REPORT, TUNE_REPORT_METRIC from tune.exceptions import TuneInterrupted @@ -14,23 +16,29 @@ def objective(a: float, b: pd.DataFrame) -> float: - return a ** 2 + b.shape[0] + return a**2 + b.shape[0] + + +def objective_with_logger(a: float, b: pd.DataFrame) -> float: + m = get_current_metric_logger() + assert m.mock + return a**2 + b.shape[0] def objective2(a: float, b: pd.DataFrame) -> float: - return -(a ** 2 + b.shape[0]) + return -(a**2 + b.shape[0]) def objective3(a: float, b: pd.DataFrame) -> float: if a == -2: raise TuneInterrupted() - return a ** 2 + b.shape[0] + return a**2 + b.shape[0] def objective4(a: float, b: pd.DataFrame) -> float: if a == -2: raise ValueError("expected") - return a ** 2 + b.shape[0] + return a**2 + b.shape[0] def assert_metric(df: pd.DataFrame, metrics: List[float]) -> None: @@ -56,12 +64,15 @@ def test_study(tmpdir): # no data partition builder = TuneDatasetBuilder(space, str(tmpdir)).add_df("b", dag.df(input_df)) dataset = builder.build(dag, 1) + logger = MetricLogger() + logger.mock = True for distributed in [True, False, None]: # min_better = True result = optimize_noniterative( - objective=objective, + objective=objective_with_logger, dataset=dataset, distributed=distributed, + logger=logger, ) result.result()[[TUNE_REPORT, TUNE_REPORT_METRIC]].output( assert_metric, params=dict(metrics=[3.0, 4.0, 7.0]) diff --git a/tests/tune_sklearn/test_suggest.py b/tests/tune_sklearn/test_suggest.py index f6e2c91..b512233 100644 --- a/tests/tune_sklearn/test_suggest.py +++ b/tests/tune_sklearn/test_suggest.py @@ -1,6 +1,7 @@ -from fugue_dask import DaskExecutionEngine +import fugue.test as ft from sklearn.datasets import load_diabetes from sklearn.linear_model import Lasso, LinearRegression + from tune import TUNE_OBJECT_FACTORY, Grid, Rand from tune_hyperopt.optimizer import HyperoptLocalOptimizer from tune_sklearn import sk_space, suggest_sk_models, suggest_sk_models_by_cv @@ -8,6 +9,7 @@ # from fugue_spark import SparkExecutionEngine +@ft.with_backend("dask") def test_suggest(tmpdir): TUNE_OBJECT_FACTORY.set_temp_path(str(tmpdir)) @@ -31,6 +33,7 @@ def test_suggest(tmpdir): top_n=0, distributed=False, local_optimizer=HyperoptLocalOptimizer(max_iter=10, seed=0), + execution_engine="native", ) assert 4 == len(result) assert 50 > result[0].sort_metric @@ -44,6 +47,7 @@ def test_suggest(tmpdir): partition_keys=["sex"], temp_path=str(tmpdir), save_model=True, + execution_engine="native", ) assert 16 == len(result) assert 50 > result[0].sort_metric @@ -55,12 +59,13 @@ def test_suggest(tmpdir): "neg_mean_absolute_error", top_n=1, partition_keys=["sex"], - execution_engine=DaskExecutionEngine, + execution_engine="dask", ) assert 2 == len(result) assert 50 > result[0].sort_metric +@ft.with_backend("dask") def test_suggest_cv(tmpdir): TUNE_OBJECT_FACTORY.set_temp_path(str(tmpdir)) @@ -80,6 +85,7 @@ def test_suggest_cv(tmpdir): top_n=0, distributed=False, local_optimizer=HyperoptLocalOptimizer(max_iter=10, seed=0), + execution_engine="native", ) assert 4 == len(result) assert 50 > result[0].sort_metric @@ -92,6 +98,7 @@ def test_suggest_cv(tmpdir): partition_keys=["sex"], temp_path=str(tmpdir), save_model=True, + execution_engine="native", ) assert 16 == len(result) assert 50 > result[0].sort_metric @@ -102,7 +109,7 @@ def test_suggest_cv(tmpdir): "neg_mean_absolute_error", top_n=1, partition_keys=["sex"], - execution_engine=DaskExecutionEngine, + execution_engine="dask", ) assert 2 == len(result) assert 50 > result[0].sort_metric diff --git a/tune/concepts/logger.py b/tune/concepts/logger.py index a0fadf7..e007d95 100644 --- a/tune/concepts/logger.py +++ b/tune/concepts/logger.py @@ -1,8 +1,48 @@ -from typing import Any, Dict, Optional +from contextlib import contextmanager +from contextvars import ContextVar +from typing import Any, Dict, Iterator, Optional from uuid import uuid4 from tune.concepts.flow.report import TrialReport +_TUNE_CONTEXT_VAR: ContextVar[Any] = ContextVar("TUNE_CONTEXT_VAR", default=None) + + +@contextmanager +def set_current_metric_logger(logger: "MetricLogger") -> Iterator["MetricLogger"]: + """Set the current metric logger + + :param logger: the logger + + .. admonition:: Examples + + .. code-block:: python + + with set_current_metric_logger(logger): + pass + """ + with logger: + token = _TUNE_CONTEXT_VAR.set(logger) + try: + yield logger + finally: + _TUNE_CONTEXT_VAR.reset(token) + + +def get_current_metric_logger() -> Optional["MetricLogger"]: + """Get the current metric logger + + :return: the current logger + + .. admonition:: Examples + + .. code-block:: python + + with set_current_metric_logger(logger): + logger = get_current_metric_logger() + """ + return _TUNE_CONTEXT_VAR.get(None) + def make_logger(obj: Any) -> "MetricLogger": """Convert an object to a MetricLogger. This function is usually called on diff --git a/tune/noniterative/objective.py b/tune/noniterative/objective.py index 6600593..51a2acb 100644 --- a/tune/noniterative/objective.py +++ b/tune/noniterative/objective.py @@ -2,7 +2,7 @@ from tune._utils import run_monitored_process from tune.concepts.flow import Trial, TrialReport -from tune.concepts.logger import make_logger +from tune.concepts.logger import make_logger, set_current_metric_logger from tune.constants import TUNE_STOPPER_DEFAULT_CHECK_INTERVAL @@ -31,9 +31,11 @@ def run( report = func.safe_run(trial) else: with make_logger(logger) as p_logger: - with p_logger.create_child( - name=trial.trial_id[:5] + "-" + p_logger.unique_id, - description=repr(trial), + with set_current_metric_logger( + p_logger.create_child( + name=trial.trial_id[:5] + "-" + p_logger.unique_id, + description=repr(trial), + ) ) as c_logger: report = func.safe_run(trial) c_logger.log_report( diff --git a/tune_hyperopt/optimizer.py b/tune_hyperopt/optimizer.py index 44eb762..e81a1a7 100644 --- a/tune_hyperopt/optimizer.py +++ b/tune_hyperopt/optimizer.py @@ -5,7 +5,7 @@ from triad import SerializableRLock from tune._utils.math import adjust_high from tune.concepts.flow import Trial, TrialReport -from tune.concepts.logger import make_logger +from tune.concepts.logger import make_logger, set_current_metric_logger from tune.concepts.space import ( Choice, Rand, @@ -44,13 +44,17 @@ def run( best_report: List[TrialReport] = [] with make_logger(logger) as p_logger: - with p_logger.create_child( - name=trial.trial_id[:5] + "-" + p_logger.unique_id, - description=repr(trial), + with set_current_metric_logger( + p_logger.create_child( + name=trial.trial_id[:5] + "-" + p_logger.unique_id, + description=repr(trial), + ) ) as c_logger: def obj(args) -> Dict[str, Any]: - with c_logger.create_child(is_step=True) as s_logger: + with set_current_metric_logger( + c_logger.create_child(is_step=True) + ) as s_logger: params = template.fill([p[1](v) for p, v in zip(proc, args)]) report = func.safe_run(trial.with_params(params)) with lock: diff --git a/tune_optuna/optimizer.py b/tune_optuna/optimizer.py index d554ad9..20d36bc 100644 --- a/tune_optuna/optimizer.py +++ b/tune_optuna/optimizer.py @@ -14,7 +14,7 @@ TrialReport, ) from tune._utils.math import _IGNORABLE_ERROR, uniform_to_discrete, uniform_to_integers -from tune.concepts.logger import make_logger +from tune.concepts.logger import make_logger, set_current_metric_logger from tune.concepts.space import TuningParametersTemplate @@ -36,13 +36,17 @@ def run( best_report: List[TrialReport] = [] with make_logger(logger) as p_logger: - with p_logger.create_child( - name=trial.trial_id[:5] + "-" + p_logger.unique_id, - description=repr(trial), + with set_current_metric_logger( + p_logger.create_child( + name=trial.trial_id[:5] + "-" + p_logger.unique_id, + description=repr(trial), + ) ) as c_logger: def obj(otrial: optuna.trial.Trial) -> float: - with c_logger.create_child(is_step=True) as s_logger: + with set_current_metric_logger( + c_logger.create_child(is_step=True) + ) as s_logger: params = template.fill_dict(_convert(otrial, template)) report = func.safe_run(trial.with_params(params)) with lock: diff --git a/tune_sklearn/objective.py b/tune_sklearn/objective.py index f937550..b938d65 100644 --- a/tune_sklearn/objective.py +++ b/tune_sklearn/objective.py @@ -1,21 +1,21 @@ import os -import cloudpickle -from tune.api.factory import TUNE_OBJECT_FACTORY from typing import Any, Optional, Tuple from uuid import uuid4 +import cloudpickle import numpy as np import pandas as pd from sklearn.metrics import get_scorer from sklearn.model_selection import cross_val_score from triad import FileSystem + from tune import NonIterativeObjectiveFunc, Trial, TrialReport +from tune.api.factory import TUNE_OBJECT_FACTORY from tune.constants import ( SPACE_MODEL_NAME, TUNE_DATASET_DF_DEFAULT_NAME, TUNE_DATASET_VALIDATION_DF_DEFAULT_NAME, ) - from tune_sklearn.utils import to_sk_model, to_sk_model_expr diff --git a/tune_tensorflow/spec.py b/tune_tensorflow/spec.py index 8c70c97..989716b 100644 --- a/tune_tensorflow/spec.py +++ b/tune_tensorflow/spec.py @@ -39,13 +39,13 @@ def get_model(self) -> keras.models.Model: raise NotImplementedError # pragma: no cover def save_checkpoint(self, fs: FSBase, model: keras.models.Model) -> None: - with tempfile.NamedTemporaryFile(suffix=".h5") as tf: + with tempfile.NamedTemporaryFile(suffix=".weights.h5") as tf: model.save_weights(tf.name) with open(tf.name, "rb") as fin: fs.writefile("model.h5", fin) def load_checkpoint(self, fs: FSBase, model: keras.models.Model) -> None: - with tempfile.NamedTemporaryFile(suffix=".h5") as tf: + with tempfile.NamedTemporaryFile(suffix=".weights.h5") as tf: local_fs = FileSystem() with fs.open("model.h5", "rb") as fin: local_fs.writefile(tf.name, fin) diff --git a/tune_tensorflow/utils.py b/tune_tensorflow/utils.py index c94dd3d..aac57b0 100644 --- a/tune_tensorflow/utils.py +++ b/tune_tensorflow/utils.py @@ -1,11 +1,11 @@ -from typing import Any, Type, Dict +from typing import Any, Dict, Type from triad.utils.convert import get_full_type_path, to_type -from tune.concepts.space.parameters import TuningParametersTemplate -from tune_tensorflow.spec import KerasTrainingSpec from tune import Space +from tune.concepts.space.parameters import TuningParametersTemplate from tune.constants import SPACE_MODEL_NAME +from tune_tensorflow.spec import KerasTrainingSpec _TYPE_DICT: Dict[str, Type[KerasTrainingSpec]] = {} diff --git a/tune_test/local_optmizer.py b/tune_test/local_optmizer.py index 4e7132c..71db980 100644 --- a/tune_test/local_optmizer.py +++ b/tune_test/local_optmizer.py @@ -45,7 +45,7 @@ def test_rand(self): # common case values = self._generate_values(Rand(-2.0, 3.0), lambda x: x**2) assert len(values) > 0 - assert all(x >= -2.0 and x <= 3.0 for x in values) + assert all(-2.0 <= x <= 3.0 for x in values) # with q, and range%q == 0 values = self._generate_values(Rand(-2.0, 3.0, q=2.5), lambda x: x**2) @@ -65,7 +65,7 @@ def test_rand(self): # with log values = self._generate_values(Rand(0.1, 3.0, log=True), lambda x: x**2) - assert all(x >= 0.1 and x <= 3.0 for x in values) + assert all(0.1 <= x <= 3.0 for x in values) # with log and q, and range%q == 0 values = self._generate_values( diff --git a/tune_version/__init__.py b/tune_version/__init__.py index 1276d02..0a8da88 100644 --- a/tune_version/__init__.py +++ b/tune_version/__init__.py @@ -1 +1 @@ -__version__ = "0.1.5" +__version__ = "0.1.6"