Skip to content

Commit

Permalink
feat(sdk): add official support for python 3.11 and drop support for …
Browse files Browse the repository at this point in the history
…python 3.6 (wandb#4386)

Co-authored-by: Katia Patkin <[email protected]>
  • Loading branch information
dmitryduev and kptkin authored Aug 1, 2023
1 parent 8f000c4 commit 4f0354c
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 61 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ workflows:
matrix:
parameters:
python_version_major: [3]
python_version_minor: [7, 8, 9, 10]
python_version_minor: [7, 8, 9, 10, 11]
name: "protobuf-compatability-py<<matrix.python_version_major>><<matrix.python_version_minor>>"
requires:
- "slack-notify-on-start"
Expand Down Expand Up @@ -1357,7 +1357,7 @@ workflows:
matrix:
parameters:
python_version_major: [3]
python_version_minor: [7, 8, 9, 10]
python_version_minor: [7, 8, 9, 10, 11]
name: "system-linux-py<<matrix.python_version_major>><<matrix.python_version_minor>>"
toxenv: "py<<matrix.python_version_major>><<matrix.python_version_minor>>,cover-linux-circle"
coverage_dir: "py<<matrix.python_version_major>><<matrix.python_version_minor>>"
Expand All @@ -1371,7 +1371,7 @@ workflows:
matrix:
parameters:
python_version_major: [3]
python_version_minor: [7, 8, 9, 10]
python_version_minor: [7, 8, 9, 10, 11]
name: "unit-linux-mock_server-py<<matrix.python_version_major>><<matrix.python_version_minor>>"
toxenv: "py<<matrix.python_version_major>><<matrix.python_version_minor>>,cover-linux-circle"
coverage_dir: "py<<matrix.python_version_major>><<matrix.python_version_minor>>"
Expand All @@ -1385,7 +1385,7 @@ workflows:
matrix:
parameters:
python_version_major: [3]
python_version_minor: [7, 8, 9, 10]
python_version_minor: [7, 8, 9, 10, 11]
name: "unit-linux-py<<matrix.python_version_major>><<matrix.python_version_minor>>"
toxenv: "py<<matrix.python_version_major>><<matrix.python_version_minor>>,cover-linux-circle"
coverage_dir: "py<<matrix.python_version_major>><<matrix.python_version_minor>>"
Expand Down
4 changes: 2 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ codecov:
# To calculate after_n_builds use
# ./tools/coverage-tool.py jobs | wc -l
# also change comment block after_n_builds just below
after_n_builds: 53
after_n_builds: 56
wait_for_ci: no

comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: no
after_n_builds: 53
after_n_builds: 56

ignore:
- "wandb/vendor"
Expand Down
15 changes: 6 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
]
readme = "package_readme.md"
license = { file = "LICENSE"}
requires-python = ">=3.6"
requires-python = ">=3.7"
dependencies = [
"Click>=7.1,!=8.0.0", # click 8.0.0 is broken
"GitPython>=1.0.0,!=3.1.29", # CVE-2022-24439
Expand All @@ -28,7 +28,6 @@ dependencies = [
"setproctitle",
"setuptools",
"appdirs>=1.4.3",
"dataclasses; python_version < '3.7'",
"typing_extensions; python_version < '3.10'",
]
classifiers = [
Expand All @@ -38,11 +37,11 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"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 :: Only",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down Expand Up @@ -101,9 +100,7 @@ launch = [
"typing_extensions",
]
models = ["cloudpickle"]
async = [
"httpx>=0.22.0", # 0.23.0 dropped Python 3.6; we can upgrade once we drop it too
]
async = ["httpx>=0.23.0"]
perf = ["orjson"]

[tool.setuptools]
Expand Down Expand Up @@ -142,7 +139,7 @@ norecursedirs = [

[tool.black]
line-length = 88
target-version = ['py36', 'py37', 'py38', 'py39', 'py310', 'py311']
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
include = '\.pyi?$'
exclude = '''
wandb/vendor/
Expand All @@ -166,8 +163,8 @@ ignore = [
"E501",
"D1", # Allow missing docstrings.
"D417", # Don't require descriptions for all arguments.
"UP022", # Only valid for Python 3.7+
"UP036", # Only valid for Python 3.7+
"UP022",
"UP036",
]
target-version = "py37"

Expand Down
8 changes: 1 addition & 7 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ nbclient

scikit-learn
tensorflow>=1.15.2; sys_platform != 'darwin'
tensorflow>=1.15.2; python_version > '3.6' and sys_platform == 'darwin' and platform.machine != 'arm64'
tensorflow>=1.15.2; sys_platform == 'darwin' and platform.machine != 'arm64'
tensorflow-macos; python_version > '3.7' and python_version < '3.11' and sys_platform == 'darwin' and platform.machine == 'arm64'
tensorboard
torch
Expand All @@ -51,9 +51,3 @@ google-cloud-aiplatform
.[launch]
.[sweeps]; sys_platform != 'darwin' or (sys_platform == 'darwin' and platform.machine != 'arm64')
.[azure]






4 changes: 1 addition & 3 deletions tests/pytest_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import shutil
import sys
import unittest.mock
from pathlib import Path
from queue import Queue
Expand Down Expand Up @@ -52,8 +51,7 @@ def copy_asset_fn(path: StrPath, dst: Optional[StrPath] = None) -> Path:

@pytest.fixture(scope="function", autouse=True)
def filesystem_isolate(tmp_path):
# Click>=8 implements temp_dir argument which depends on python>=3.7
kwargs = dict(temp_dir=tmp_path) if sys.version_info >= (3, 7) else {}
kwargs = dict(temp_dir=tmp_path)
with CliRunner().isolated_filesystem(**kwargs):
yield

Expand Down
6 changes: 1 addition & 5 deletions tests/pytest_tests/unit_tests/test_wandb_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@

if sys.version_info >= (3, 8):
from typing import get_type_hints
elif sys.version_info >= (3, 7):
from typing_extensions import get_type_hints
else:

def get_type_hints(obj):
return obj.__annotations__
from typing_extensions import get_type_hints


Property = wandb_settings.Property
Expand Down
3 changes: 1 addition & 2 deletions tests/pytest_tests/unit_tests_old/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def __getitem__(self, worker_id):


def get_temp_dir_kwargs(tmp_path):
# Click>=8 implements temp_dir argument which depends on python>=3.7
return dict(temp_dir=tmp_path) if sys.version_info >= (3, 7) else {}
return dict(temp_dir=tmp_path)


def test_cleanup(*args, **kwargs):
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ passenv=
USERNAME
CI_PYTEST_SPLIT_ARGS

[testenv:{,notebooks-}py{37,38,39,310}]
[testenv:{,notebooks-}py{37,38,39,310,311}]
install_command=
; pytorch installations on non-darwin need the `-f`
pip install --timeout 600 --extra-index-url https://download.pytorch.org/whl/cpu {opts} {packages}
Expand Down Expand Up @@ -155,7 +155,7 @@ deps=
scikit-learn
xgboost>=1.3.0

[testenv:func-{,grpc-,docs-,noml-,}py{37,38,39,310}]
[testenv:func-{,grpc-,docs-,noml-,}py{37,38,39,310,311}]
install_command=pip install --extra-index-url https://download.pytorch.org/whl/cpu {opts} {packages}
deps =
yea-wandb=={env:YEA_WANDB_VERSION}
Expand Down Expand Up @@ -193,7 +193,7 @@ commands_pre=
commands=
yea {env:CI_PYTEST_SPLIT_ARGS:} --strict --shard mitm --mitm run {posargs:--all}

[testenv:func-{llm,kfp}-py{37,38,39,310}]
[testenv:func-{llm,kfp}-py{37,38,39,310,311}]
install_command=pip install --extra-index-url https://download.pytorch.org/whl/cpu {opts} {packages}
deps=
yea-wandb=={env:YEA_WANDB_VERSION}
Expand All @@ -216,7 +216,7 @@ commands=
llm: yea {env:CI_PYTEST_SPLIT_ARGS:} --strict --shard llm run {posargs:--all}
kfp: yea {env:CI_PYTEST_SPLIT_ARGS:} --strict -p wandb:mockserver-bind=0.0.0.0 -p wandb:mockserver-host=__auto__ --shard kfp run {posargs:--all}

[testenv:standalone-{local,cpu,gpu,tpu}-py{37,38,39,310}]
[testenv:standalone-{local,cpu,gpu,tpu}-py{37,38,39,310,311}]
install_command=pip install --extra-index-url https://download.pytorch.org/whl/cpu {opts} {packages}
setenv=
{[base]setenv}
Expand All @@ -238,7 +238,7 @@ commands=
!{local}: yea --debug --strict -p wandb:mockserver-relay=true -p wandb:mockserver-relay-remote-base-url=https://api.wandb.ai --shard standalone-{env:SHARD:cpu} run {posargs:--all}
local: yea --debug --strict -p wandb:mockserver-bind=0.0.0.0 -p wandb:mockserver-host=__auto__ -p wandb:mockserver-relay=true -p wandb:mockserver-relay-remote-base-url=http://localhost:5000 --shard standalone-cpu run {posargs:--all}

[testenv:regression-{yolov5,huggingface,keras,tensorflow,pytorch,wandb-sdk-standalone,wandb-sdk-examples,wandb-sdk-other,s3,sagemaker}-py{37,38,39,310}]
[testenv:regression-{yolov5,huggingface,keras,tensorflow,pytorch,wandb-sdk-standalone,wandb-sdk-examples,wandb-sdk-other,s3,sagemaker}-py{37,38,39,310,311}]
install_command=pip install --extra-index-url https://download.pytorch.org/whl/cpu {opts} {packages}
deps=
pyyaml
Expand Down
16 changes: 3 additions & 13 deletions wandb/sdk/lib/_settings_toposort_generate.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import inspect
import sys
from typing import Any, Dict, List, Optional, Set, Tuple
from typing import Dict, List, Set, Tuple

from wandb.errors import UsageError
from wandb.sdk.wandb_settings import Settings

if sys.version_info >= (3, 8):
from typing import get_args, get_origin, get_type_hints
elif sys.version_info >= (3, 7):
from typing_extensions import get_args, get_origin, get_type_hints
from typing import get_type_hints
else:

def get_args(obj: Any) -> Optional[Any]:
return obj.__args__ if hasattr(obj, "__args__") else None

def get_origin(obj: Any) -> Optional[Any]:
return obj.__origin__ if hasattr(obj, "__origin__") else None

def get_type_hints(obj: Any) -> Dict[str, Any]:
return dict(obj.__annotations__) if hasattr(obj, "__annotations__") else dict()
from typing_extensions import get_type_hints


template = """
Expand Down
12 changes: 1 addition & 11 deletions wandb/sdk/wandb_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,8 @@

if sys.version_info >= (3, 8):
from typing import get_args, get_origin, get_type_hints
elif sys.version_info >= (3, 7):
from typing_extensions import get_args, get_origin, get_type_hints
else:

def get_args(obj: Any) -> Optional[Any]:
return obj.__args__ if hasattr(obj, "__args__") else None

def get_origin(obj: Any) -> Optional[Any]:
return obj.__origin__ if hasattr(obj, "__origin__") else None

def get_type_hints(obj: Any) -> Dict[str, Any]:
return dict(obj.__annotations__) if hasattr(obj, "__annotations__") else dict()
from typing_extensions import get_args, get_origin, get_type_hints


class SettingsPreprocessingError(UsageError):
Expand Down

0 comments on commit 4f0354c

Please sign in to comment.