Skip to content

Commit

Permalink
Add support for Python 3.11 (#7304)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Guidry <chris.g@prefect.io>
  • Loading branch information
zanieb and chrisguidry authored Oct 27, 2022
1 parent 59e12c3 commit a7bd9ca
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 7 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/python-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Python tests

# Note: Conda support for 3.11 is pending. See https://github.com/ContinuumIO/anaconda-issues/issues/13082

env:
# enable colored output
# https://github.com/pytest-dev/pytest/issues/7443
Expand Down Expand Up @@ -47,6 +49,7 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
pytest-options:
- "--exclude-services"
- "--only-services"
Expand Down Expand Up @@ -117,7 +120,8 @@ jobs:
docker run --rm prefecthq/prefect:dev-python${{ matrix.python-version }} prefect version
- name: Build Conda flavored test image
if: ${{ matrix.build-docker-images }}
# Not yet supported for 3.11, see note at top
if: ${{ matrix.build-docker-images && matrix.python-version != '3.11' }}
uses: docker/build-push-action@v3
with:
context: .
Expand All @@ -132,7 +136,8 @@ jobs:
# cache-to: type=gha,mode=max

- name: Test Conda flavored Docker image
if: ${{ matrix.build-docker-images }}
# Not yet supported for 3.11, see note at top
if: ${{ matrix.build-docker-images && matrix.python-version != '3.11' }}
run: |
docker load --input /tmp/image-conda.tar
docker run --rm prefecthq/prefect:dev-python${{ matrix.python-version }}-conda prefect version
Expand Down Expand Up @@ -161,6 +166,7 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
pytest-options:
- "--exclude-services"

Expand Down
23 changes: 22 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Release prefect

# Note: Conda support for 3.11 is pending. See https://github.com/ContinuumIO/anaconda-issues/issues/13082

on:
push:
tags:
Expand Down Expand Up @@ -61,6 +63,7 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- "3.11"

steps:
# Not needed until we want multiarchecture builds
Expand Down Expand Up @@ -122,6 +125,8 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
# Not yet supported, see note at top
# - "3.11"

steps:
# Not needed until we want multiarchecture builds
Expand Down Expand Up @@ -270,6 +275,12 @@ jobs:
name: release-image-${{ github.sha }}-3.10
path: /tmp/3.10/

- name: Download image artifacts for Python 3.11
uses: actions/download-artifact@v3
with:
name: release-image-${{ github.sha }}-3.11
path: /tmp/3.11/

- name: Download conda image artifacts for Python 3.7
uses: actions/download-artifact@v3
with:
Expand All @@ -294,16 +305,26 @@ jobs:
name: release-image-${{ github.sha }}-3.10-conda
path: /tmp/3.10/

# Not yet available, see note at top
# - name: Download conda image artifacts for Python 3.11
# uses: actions/download-artifact@v3
# with:
# name: release-image-${{ github.sha }}-3.11-conda
# path: /tmp/3.11/

- name: Load images
run: |
docker load --input /tmp/3.7/image.tar
docker load --input /tmp/3.8/image.tar
docker load --input /tmp/3.9/image.tar
docker load --input /tmp/3.10/image.tar
docker load --input /tmp/3.11/image.tar
docker load --input /tmp/3.7/image-conda.tar
docker load --input /tmp/3.8/image-conda.tar
docker load --input /tmp/3.9/image-conda.tar
docker load --input /tmp/3.10/image-conda.tar
docker load --input /tmp/3.10/image-conda.
# Not yet available, see note at top
# docker load --input /tmp/3.11/image-conda.tar
- name: Login to DockerHub
uses: docker/login-action@v2
Expand Down
7 changes: 6 additions & 1 deletion docs/concepts/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Additionally, we have "convenience" tags which are updated with each release to

For example, when release `2.1.1` is published:

1. Images with the release packaged are built for each supported Python version (3.7, 3.8, 3.9, 3.10) with both standard Python and Conda.
1. Images with the release packaged are built for each supported Python version (3.7, 3.8, 3.9, 3.10, 3.11) with both standard Python and Conda.
2. These images are tagged with the full description, e.g. `prefect:2.1.1-python3.7` and `prefect:2.1.1-python3.7-conda`.
3. For users that want more specific pins, these images are also tagged with the SHA of the git commit of the release, e.g. `sha-88a7ff17a3435ec33c95c0323b8f05d7b9f3f6d2-python3.7`
4. For users that want to be on the latest `2.1.x` release, receiving patch updates, we update a tag without the patch version to this release, e.g. `prefect.2.1-python3.7`.
Expand All @@ -284,14 +284,17 @@ Standard Python images are based on the official Python `slim` images, e.g. `pyt
| Tag | Prefect Version | Python Version |
| --------------------- | :-------------------------: | -------------: |
| 2-latest | most recent v2 PyPi version | 3.10 |
| 2-python3.11 | most recent v2 PyPi version | 3.11 |
| 2-python3.10 | most recent v2 PyPi version | 3.10 |
| 2-python3.9 | most recent v2 PyPi version | 3.9 |
| 2-python3.8 | most recent v2 PyPi version | 3.8 |
| 2-python3.7 | most recent v2 PyPi version | 3.7 |
| 2.X-python3.11 | 2.X | 3.11 |
| 2.X-python3.10 | 2.X | 3.10 |
| 2.X-python3.9 | 2.X | 3.9 |
| 2.X-python3.8 | 2.X | 3.8 |
| 2.X-python3.7 | 2.X | 3.7 |
| sha-&lt;hash&gt;-python3.11 | &lt;hash&gt; | 3.11 |
| sha-&lt;hash&gt;-python3.10 | &lt;hash&gt; | 3.10 |
| sha-&lt;hash&gt;-python3.9 | &lt;hash&gt; | 3.9 |
| sha-&lt;hash&gt;-python3.8 | &lt;hash&gt; | 3.8 |
Expand All @@ -302,6 +305,8 @@ Standard Python images are based on the official Python `slim` images, e.g. `pyt

Conda flavored images are based on `continuumio/miniconda3`. Prefect is installed into a conda environment named `prefect`.

Note, Conda support for Python 3.11 is not available so we cannot build an image yet.

| Tag | Prefect Version | Python Version |
| --------------------------- | :-------------------------: | -------------: |
| 2-latest-conda | most recent v2 PyPi version | 3.10 |
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ filterwarnings =
ignore:distutils Version classes are deprecated:DeprecationWarning
# distutils is deprecated, but we are using it directly in prefect/filesystems.py
ignore:The distutils package is deprecated:DeprecationWarning
# apprise<=1.1.0 has not been updated to use the new locale functions in Python 3.11
ignore:Use setlocale:DeprecationWarning
[isort]
skip = __init__.py
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries",
],
)
4 changes: 2 additions & 2 deletions src/prefect/orion/schemas/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def __repr__(self) -> str:

display = dict(
message=repr(self.message),
type=self.type,
type=str(self.type.value),
result=repr(result),
)

Expand All @@ -186,7 +186,7 @@ def __str__(self) -> str:
display_message = f"{self.message!r}" if self.message else ""

display_type = (
f", type={self.type}"
f", type={self.type.value}"
if self.type.value.lower() != self.name.lower()
else ""
)
Expand Down
6 changes: 5 additions & 1 deletion tests/test_flows.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import enum
import inspect
import sys
import time
from typing import List
from unittest.mock import MagicMock
Expand Down Expand Up @@ -787,6 +788,9 @@ def test_timeout_does_not_wait_for_completion_for_sync_flows(self, tmp_path):
continue until the next instruction is reached. `time.sleep` will return then
the thread will be interrupted.
"""
if sys.version_info[1] == 11:
pytest.xfail("The engine returns _after_ sleep finishes in Python 3.11")

canary_file = tmp_path / "canary"

@flow(timeout_seconds=0.1)
Expand All @@ -795,7 +799,7 @@ def my_flow():
canary_file.touch()

t0 = time.perf_counter()
state = my_flow._run()
state = my_flow(return_state=True)
t1 = time.perf_counter()

assert state.is_failed()
Expand Down

0 comments on commit a7bd9ca

Please sign in to comment.