From 95c6276d0ca8d67b5bd1721ea5446d9e7e5112d8 Mon Sep 17 00:00:00 2001 From: Alexander Streed Date: Wed, 9 Oct 2024 13:08:21 -0500 Subject: [PATCH] Add check for `prefect-client` version in prefect-client workflow (#15624) --- .github/workflows/markdown-tests.yaml | 2 +- .github/workflows/prefect-client.yaml | 23 +++++++++++++++++++++-- client/setup.py | 7 ++----- setup.cfg | 2 +- src/prefect/_version.py | 2 +- src/prefect/utilities/dockerutils.py | 5 +++-- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/markdown-tests.yaml b/.github/workflows/markdown-tests.yaml index 7a75a126c2e6..495dfa0a1bbb 100644 --- a/.github/workflows/markdown-tests.yaml +++ b/.github/workflows/markdown-tests.yaml @@ -95,7 +95,7 @@ jobs: - name: Start server run: | - prefect server start& + PREFECT_HOME=$(pwd) prefect server start& PREFECT_API_URL="http://127.0.0.1:4200/api" ./scripts/wait-for-server.py - name: Run tests diff --git a/.github/workflows/prefect-client.yaml b/.github/workflows/prefect-client.yaml index fbeda01bd71f..550f00096717 100644 --- a/.github/workflows/prefect-client.yaml +++ b/.github/workflows/prefect-client.yaml @@ -10,6 +10,7 @@ on: - requirements.txt - requirements-client.txt - setup.cfg + - .github/workflows/prefect-client.yaml push: branches: - main @@ -19,6 +20,7 @@ on: - requirements.txt - requirements-client.txt - setup.cfg + - .github/workflows/prefect-client.yaml workflow_call: inputs: upload-artifacts: @@ -64,6 +66,13 @@ jobs: run: pip install dist/*.tar.gz working-directory: ${{ env.TMPDIR }} + - name: Get the version of built `prefect-client` + run: | + prefect_client_version=$(python -c "import prefect; print(prefect.__version__)") + echo "prefect_client_version=$prefect_client_version" >> $GITHUB_OUTPUT + working-directory: ${{ env.TMPDIR }} + id: prefect_client_version + - name: Run the smoke test flow using the built client run: python client/client_flow.py working-directory: ${{ env.TMPDIR }} @@ -74,8 +83,18 @@ jobs: - name: Install prefect from source run: pip install . - - name: (DEBUG) Check that prefect and prefect-client are installed - run: pip list | grep prefect + - name: Get the version of built `prefect` + run: | + prefect_version=$(prefect --version) + echo "prefect_version=$prefect_version" >> $GITHUB_OUTPUT + id: prefect_version + + - name: Verify that the built `prefect` and `prefect-client` versions are the same + run: | + if [ "${{ steps.prefect_version.outputs.prefect_version }}" != "${{ steps.prefect_client_version.outputs.prefect_client_version }}" ]; then + echo "The built versions of prefect and prefect-client are not the same." + exit 1 + fi - name: Run the smoke test flow again with prefect and prefect-client installed run: python client/client_flow.py diff --git a/client/setup.py b/client/setup.py index 8a55783fe15d..9eb0ddebf7c4 100644 --- a/client/setup.py +++ b/client/setup.py @@ -3,10 +3,6 @@ install_requires = open("requirements-client.txt").read().strip().split("\n") -# grab and use the first three version digits (the generated tag) -_version = versioneer.get_version().split(".") -client_version = ".".join(_version[:3]).split("+")[0] - setup( # Package metadata name="prefect-client", @@ -23,7 +19,8 @@ long_description=open("README.md").read(), long_description_content_type="text/markdown", # Versioning - version=client_version, + version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), # Package setup packages=find_packages(where="src"), package_dir={"": "src"}, diff --git a/setup.cfg b/setup.cfg index be0b6511b648..da3ce4accb64 100644 --- a/setup.cfg +++ b/setup.cfg @@ -84,7 +84,7 @@ ignore_missing_imports = True [versioneer] VCS = git -style = pep440 +style = pep440-pre versionfile_source = src/prefect/_version.py versionfile_build = prefect/_version.py version_regex = ^(\d+\.\d+\.\d+(?:[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*)?)$ diff --git a/src/prefect/_version.py b/src/prefect/_version.py index ec20917e8f2b..74560778d3d6 100644 --- a/src/prefect/_version.py +++ b/src/prefect/_version.py @@ -49,7 +49,7 @@ def get_config() -> VersioneerConfig: # _version.py cfg = VersioneerConfig() cfg.VCS = "git" - cfg.style = "pep440" + cfg.style = "pep440-pre" cfg.tag_prefix = "" cfg.parentdir_prefix = "" cfg.versionfile_source = "src/prefect/_version.py" diff --git a/src/prefect/utilities/dockerutils.py b/src/prefect/utilities/dockerutils.py index 16663e3ec7ac..721b93eee4bf 100644 --- a/src/prefect/utilities/dockerutils.py +++ b/src/prefect/utilities/dockerutils.py @@ -22,6 +22,7 @@ from urllib.parse import urlsplit import pendulum +from packaging.version import Version from typing_extensions import Self import prefect @@ -55,8 +56,8 @@ def get_prefect_image_name( minor level e.g. '3.9'. flavor: An optional alternative image flavor to build, like 'conda' """ - parsed_version = (prefect_version or prefect.__version__).split("+") - is_prod_build = len(parsed_version) == 1 + parsed_version = Version(prefect_version or prefect.__version__) + is_prod_build = parsed_version.post is None prefect_version = ( parsed_version[0] if is_prod_build