Skip to content

Commit

Permalink
Drop python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
HideakiImamura committed Nov 8, 2022
1 parent 4bc3dfc commit 391a82e
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# TODO (nzw0301): Remove `exclude` once integration works with Python 3.10.
strategy:
matrix:
python_version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python_version: ['3.7', '3.8', '3.9', '3.10']
build_type: ['', 'dev'] # "dev" installs all the dependencies including pytest.
exclude:
- python_version: '3.10'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10']

services:
mysql:
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ concurrency:

jobs:
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10']

services:
redis:
Expand Down Expand Up @@ -66,11 +66,7 @@ jobs:
pip install scikit-optimize
pip install cma
pip install shap
# TODO(nzw): Move `run` part to the end of `Install` after Optuna drops Python 3.6 support.
- name: Install PyTorch and BoTorch.
run: pip install botorch torch==1.11.0 --extra-index-url https://download.pytorch.org/whl/cpu
if: matrix.python-version != '3.6'
pip install botorch torch==1.11.0 --extra-index-url https://download.pytorch.org/whl/cpu
- name: Tests
run: |
Expand Down
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ COPY . .
ARG BUILD_TYPE='dev'

RUN if [ "${BUILD_TYPE}" = "dev" ]; then \
if [ "${PYTHON_VERSION}" \< "3.6" ]; then \
pip install ${PIP_OPTIONS} -e '.[document, integration]' -f https://download.pytorch.org/whl/torch_stable.html; \
else \
pip install ${PIP_OPTIONS} -e '.[checking, document, integration]' -f https://download.pytorch.org/whl/torch_stable.html; \
fi \
pip install ${PIP_OPTIONS} -e '.[checking, document, integration]' -f https://download.pytorch.org/whl/torch_stable.html; \
else \
pip install ${PIP_OPTIONS} -e .; \
fi \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ $ pip install optuna
$ conda install -c conda-forge optuna
```

Optuna supports Python 3.6 or newer.
Optuna supports Python 3.7 or newer.

Also, we also provide Optuna docker images on [DockerHub](https://hub.docker.com/r/optuna/optuna).

Expand Down
5 changes: 0 additions & 5 deletions optuna/_transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections import OrderedDict
import math
from typing import Any
from typing import Dict
Expand Down Expand Up @@ -64,10 +63,6 @@ def __init__(
transform_log: bool = True,
transform_step: bool = True,
) -> None:
# TODO(hvy): Avoid casting to `OrderedDict` when Python 3.6 is no longer supported since
# order will be guaranteed.
search_space = OrderedDict(search_space)

bounds, column_to_encoded_columns, encoded_column_to_column = _transform_search_space(
search_space, transform_log, transform_step
)
Expand Down
4 changes: 0 additions & 4 deletions optuna/samplers/_qmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ class QMCSampler(BaseSampler):
determined by the first trial of the study. Once the search space is determined, it cannot
be changed afterwards.
.. note:
`QMCSampler` is not supported for Python 3.6 as it depends on `scipy.stat.qmc` module which
only supports Python 3.7 or the later versions.
Args:
qmc_type:
The type of QMC sequence to be sampled. This must be one of
Expand Down
13 changes: 4 additions & 9 deletions optuna/storages/_journal/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class JournalOperation(enum.IntEnum):
SET_TRIAL_SYSTEM_ATTR = 10


def datetime_from_isoformat(datetime_str: str) -> datetime.datetime:
# TODO(wattlebirdaz): Use datetime.fromisoformat after dropped Python 3.6 support.
return datetime.datetime.strptime(datetime_str, "%Y-%m-%dT%H:%M:%S.%f")


@experimental_class("3.1.0")
class JournalStorage(BaseStorage):
"""Storage class for Journal storage backend.
Expand Down Expand Up @@ -496,11 +491,11 @@ def _apply_create_trial(self, log: Dict[str, Any]) -> None:
if "params" in log:
params = {k: distributions[k].to_external_repr(p) for k, p in log["params"].items()}
if log["datetime_start"] is not None:
datetime_start = datetime_from_isoformat(log["datetime_start"])
datetime_start = datetime.datetime.fromisoformat(log["datetime_start"])
else:
datetime_start = None
if "datetime_complete" in log:
datetime_complete = datetime_from_isoformat(log["datetime_complete"])
datetime_complete = datetime.datetime.fromisoformat(log["datetime_complete"])
else:
datetime_complete = None

Expand Down Expand Up @@ -572,11 +567,11 @@ def _apply_set_trial_state_values(self, log: Dict[str, Any]) -> None:

trial = copy.copy(self._trials[trial_id])
if state == TrialState.RUNNING:
trial.datetime_start = datetime_from_isoformat(log["datetime_start"])
trial.datetime_start = datetime.datetime.fromisoformat(log["datetime_start"])
if self._is_issued_by_this_worker(log):
self._worker_id_to_owned_trial_id[self.worker_id] = trial_id
if state.is_finished():
trial.datetime_complete = datetime_from_isoformat(log["datetime_complete"])
trial.datetime_complete = datetime.datetime.fromisoformat(log["datetime_complete"])
trial.state = state
if log["values"] is not None:
trial.values = log["values"]
Expand Down
33 changes: 15 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def get_install_requires() -> List[str]:
"importlib-metadata<5.0.0",
"numpy",
"packaging>=20.0",
# TODO(kstoneriv3): remove this after deprecation of Python 3.6
"scipy!=1.4.0" if sys.version[:3] == "3.6" else "scipy>=1.7.0",
"scipy>=1.7.0",
"sqlalchemy>=1.3.0",
"tqdm",
"PyYAML", # Only used in `optuna/cli.py`.
Expand Down Expand Up @@ -81,36 +80,36 @@ def get_extras_require() -> Dict[str, List[str]]:
"sphinx-gallery",
"sphinx-plotly-directive",
"sphinx_rtd_theme",
"torch==1.11.0 ; python_version>'3.6'",
"torchaudio==0.11.0 ; python_version>'3.6'",
"torchvision==0.12.0 ; python_version>'3.6'",
"torch==1.11.0",
"torchaudio==0.11.0",
"torchvision==0.12.0",
],
"integration": [
"allennlp>=2.2.0 ; python_version>'3.6'",
"allennlp>=2.2.0",
# TODO(c-bata): Remove cached-path after allennllp supports v1.1.3
"cached-path<=1.1.2 ; python_version>'3.6'",
"botorch>=0.4.0 ; python_version>'3.6'",
"catalyst>=21.3 ; python_version>'3.6'",
"catboost>=0.26",
"chainer>=5.0.0",
"cma",
"fastai ; python_version>'3.6'",
"fastai",
"lightgbm",
"mlflow",
"mpi4py",
"mxnet",
"pandas",
"pytorch-ignite ; python_version>'3.6'",
"pytorch-lightning>=1.5.0 ; python_version>'3.6'",
"pytorch-ignite",
"pytorch-lightning>=1.5.0",
"scikit-learn>=0.24.2",
"scikit-optimize",
"shap",
"skorch ; python_version>'3.6'",
"tensorflow ; python_version>'3.6'",
"skorch",
"tensorflow",
"tensorflow-datasets",
"torch==1.11.0 ; python_version>'3.6'",
"torchaudio==0.11.0 ; python_version>'3.6'",
"torchvision==0.12.0 ; python_version>'3.6'",
"torch==1.11.0",
"torchaudio==0.11.0",
"torchvision==0.12.0",
"wandb",
"xgboost",
],
Expand All @@ -124,8 +123,7 @@ def get_extras_require() -> Dict[str, List[str]]:
],
"test": [
"codecov",
"fakeredis[lua]<=1.7.1; python_version<'3.7'",
"fakeredis[lua] ; python_version>='3.7'",
"fakeredis[lua]",
"kaleido",
"pytest",
],
Expand Down Expand Up @@ -157,7 +155,7 @@ def get_extras_require() -> Dict[str, List[str]]:
"py.typed",
]
},
python_requires=">=3.6",
python_requires=">=3.7",
install_requires=get_install_requires(),
extras_require=get_extras_require(),
entry_points={
Expand All @@ -182,7 +180,6 @@ def get_extras_require() -> Dict[str, List[str]]:
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
Loading

0 comments on commit 391a82e

Please sign in to comment.