Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.13 #8904

Merged
merged 23 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
environment: [mindeps, "3.10", "3.11", "3.12"]
environment: [mindeps, "3.10", "3.11", "3.12", "3.13"]
label: [default]
extra_packages: [null]
# Cherry-pick test modules to split the overall runtime roughly in half
Expand All @@ -40,6 +40,8 @@ jobs:
environment: "3.10"
- os: macos-latest
environment: "3.11"
- os: macos-latest
environment: "3.13"

- os: windows-latest
environment: mindeps
Expand Down Expand Up @@ -242,7 +244,7 @@ jobs:
set -o pipefail
mkdir reports

pytest distributed \
python -m pytest distributed \
-m "not avoid_ci and ${{ matrix.partition }}" --runslow \
--leaks=fds,processes,threads \
--junitxml reports/pytest.xml -o junit_suite_name=$TEST_ID \
Expand Down
56 changes: 56 additions & 0 deletions continuous_integration/environment-3.13.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: dask-distributed-313
channels:
- conda-forge
dependencies:
- python=3.13
- packaging
- pip
- asyncssh
- bokeh>3
- click
- cloudpickle
- coverage
- dask # overridden by git tip below
- filesystem-spec # overridden by git tip below
- gilknocker
- h5py
- ipykernel
- ipywidgets
- jinja2
- jupyter-server-proxy
- jupyterlab
- locket
- msgpack-python
- netcdf4
- paramiko
- pre-commit
- prometheus_client
- psutil
- pyarrow
- pytest
- pytest-cov
- pytest-faulthandler
- pytest-repeat
- pytest-rerunfailures
- pytest-timeout
- requests
- s3fs # overridden by git tip below
- scikit-learn
- scipy
- sortedcollections
- tblib
- toolz
# - tornado # Using pip below until 6.4.2 is on conda-forge
- zict # overridden by git tip below
- zstandard
# Temporary fix for https://github.com/pypa/setuptools/issues/4496
- setuptools < 71
- pip:
- git+https://github.com/dask/dask
- git+https://github.com/dask/dask-expr
- git+https://github.com/dask/zict
# Revert after https://github.com/dask/distributed/issues/8614 is fixed
# - git+https://github.com/dask/s3fs
# - git+https://github.com/fsspec/filesystem_spec
- keras
- tornado>=6.4.2
1 change: 1 addition & 0 deletions distributed/dashboard/tests/test_scheduler_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ async def test_https_support(c, s, a, b):

ctx = ssl.create_default_context()
ctx.load_verify_locations(get_cert("tls-ca-cert.pem"))
ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT

http_client = AsyncHTTPClient()
response = await http_client.fetch(
Expand Down
2 changes: 2 additions & 0 deletions distributed/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def _get_tls_context(self, tls, purpose):
# IP addresses rather than hostnames
ctx.check_hostname = False

ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone ahead and turned this new VERIFY_X509_STRICT flag off here (it was previously off by default in older versions of Python but was flipped on by default in Python 3.13). This seems not ideal, but also not that bad given that's what we've always done prior to Python 3.13. @jacobtomlinson (or anyone else) let me know if you have a better suggestion, I'm not verify familiar with our TLS security code paths.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using https://github.com/python-trio/trustme to generate the certificates used for testing on the fly would get this to pass (as it sets the appropriate flags on the certificates and generally keeps these flags up to date)

of course, distributed users would also need to configure their certificates to meet these stronger security standards


if tls.get("ciphers"):
ctx.set_ciphers(tls.get("ciphers"))

Expand Down
4 changes: 4 additions & 0 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,10 @@ async def test_upload_file_no_extension(c, s, a, b):
await c.upload_file(fn)


@pytest.mark.skipif(
sys.version_info >= (3, 13),
reason="Upstream issue in CPython. See https://github.com/dask/distributed/issues/8708 and https://github.com/python/cpython/issues/121342.",
)
@gen_cluster(client=True)
async def test_upload_file_zip(c, s, a, b):
def g():
Expand Down
4 changes: 2 additions & 2 deletions distributed/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import pytest

from distributed import metrics
from distributed.compatibility import WINDOWS
from distributed.utils import offload
from distributed.utils_test import gen_test

Expand All @@ -30,7 +29,8 @@ def test_wall_clock(name):

@pytest.mark.slow
@pytest.mark.skipif(
not WINDOWS, reason="WindowsTime doesn't work with high accuracy base timer"
not isinstance(metrics.time, metrics._WindowsTime),
reason="WindowsTime doesn't work with high accuracy base timer",
)
def test_monotonic():
t = metrics._WindowsTime(time.monotonic, is_monotonic=True, resync_every=0.1).time
Expand Down
8 changes: 5 additions & 3 deletions distributed/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
)
from distributed.deploy import SpecCluster
from distributed.diagnostics.plugin import WorkerPlugin
from distributed.metrics import context_meter, time
from distributed.metrics import _WindowsTime, context_meter, time
from distributed.nanny import Nanny
from distributed.node import ServerNode
from distributed.proctitle import enable_proctitle_on_children
Expand Down Expand Up @@ -1541,6 +1541,7 @@ def get_server_ssl_context(
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH, cafile=get_cert(ca_file))
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_REQUIRED
ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT
ctx.load_cert_chain(get_cert(certfile), get_cert(keyfile))
return ctx

Expand All @@ -1551,6 +1552,7 @@ def get_client_ssl_context(
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=get_cert(ca_file))
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_REQUIRED
ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT
ctx.load_cert_chain(get_cert(certfile), get_cert(keyfile))
return ctx

Expand Down Expand Up @@ -2605,14 +2607,14 @@ def no_time_resync():
"""Temporarily disable the automatic resync of distributed.metrics._WindowsTime
which, every 10 minutes, can cause time() to go backwards a few milliseconds.

On Linux and MacOSX, this fixture is a no-op.
On Linux, MacOSX, and Windows with Python 3.13+ this fixture is a no-op.

See also
--------
NoSchedulerDelayWorker
padded_time
"""
if WINDOWS:
if isinstance(time, _WindowsTime):
time() # Initialize or refresh delta
bak = time.__self__.next_resync
time.__self__.next_resync = float("inf")
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering",
"Topic :: System :: Distributed Computing",
]
Expand Down
Loading