diff --git a/src/prefect/__init__.py b/src/prefect/__init__.py index 8bd40dd9213e..1b0f9933f585 100644 --- a/src/prefect/__init__.py +++ b/src/prefect/__init__.py @@ -57,7 +57,7 @@ import prefect.blocks.system import prefect.infrastructure.process import prefect.infrastructure.kubernetes -import prefect.infrastructure.docker +import prefect.infrastructure.container # Initialize the process-wide profile and registry at import time import prefect.context @@ -102,6 +102,16 @@ "prefect.client.orchestration", start_date="Feb 2023", ) +register_renamed_module( + "prefect.docker", + "prefect.utilities.dockerutils", + start_date="Mar 2023", +) +register_renamed_module( + "prefect.infrastructure.docker", + "prefect.infrastructure.container", + start_date="Mar 2023", +) inject_renamed_module_alias_finder() diff --git a/src/prefect/cli/dev.py b/src/prefect/cli/dev.py index 0f688eac43d7..3858c6d77471 100644 --- a/src/prefect/cli/dev.py +++ b/src/prefect/cli/dev.py @@ -21,7 +21,6 @@ from prefect.cli._utilities import exit_with_error, exit_with_success from prefect.cli.agent import start as start_agent from prefect.cli.root import app -from prefect.docker import get_prefect_image_name, python_version_minor from prefect.server.api.server import create_app from prefect.settings import ( PREFECT_API_URL, @@ -30,6 +29,7 @@ PREFECT_SERVER_API_HOST, PREFECT_SERVER_API_PORT, ) +from prefect.utilities.dockerutils import get_prefect_image_name, python_version_minor from prefect.utilities.filesystem import tmpchdir from prefect.utilities.processutils import run_process diff --git a/src/prefect/cli/kubernetes.py b/src/prefect/cli/kubernetes.py index 54a516095905..32ae2782a482 100644 --- a/src/prefect/cli/kubernetes.py +++ b/src/prefect/cli/kubernetes.py @@ -10,13 +10,13 @@ from prefect._internal.compatibility.deprecated import generate_deprecation_message from prefect.cli._types import PrefectTyper, SettingsOption from prefect.cli.root import app -from prefect.docker import get_prefect_image_name from prefect.infrastructure import KubernetesJob from prefect.settings import ( PREFECT_API_KEY, PREFECT_API_URL, PREFECT_LOGGING_SERVER_LEVEL, ) +from prefect.utilities.dockerutils import get_prefect_image_name kubernetes_app = PrefectTyper( name="kubernetes", diff --git a/src/prefect/infrastructure/__init__.py b/src/prefect/infrastructure/__init__.py index 359bd78e0aed..39f5a1890784 100644 --- a/src/prefect/infrastructure/__init__.py +++ b/src/prefect/infrastructure/__init__.py @@ -1,5 +1,5 @@ from prefect.infrastructure.base import Infrastructure, InfrastructureResult -from prefect.infrastructure.docker import DockerContainer, DockerContainerResult +from prefect.infrastructure.container import DockerContainer, DockerContainerResult from prefect.infrastructure.kubernetes import ( KubernetesClusterConfig, KubernetesImagePullPolicy, diff --git a/src/prefect/infrastructure/docker.py b/src/prefect/infrastructure/container.py similarity index 99% rename from src/prefect/infrastructure/docker.py rename to src/prefect/infrastructure/container.py index 42745a8f0985..9a395be5e09a 100644 --- a/src/prefect/infrastructure/docker.py +++ b/src/prefect/infrastructure/container.py @@ -13,16 +13,16 @@ import prefect from prefect.blocks.core import Block, SecretStr -from prefect.docker import ( - format_outlier_version_name, - get_prefect_image_name, - parse_image_tag, -) from prefect.exceptions import InfrastructureNotAvailable, InfrastructureNotFound from prefect.infrastructure.base import Infrastructure, InfrastructureResult from prefect.settings import PREFECT_API_URL from prefect.utilities.asyncutils import run_sync_in_worker_thread, sync_compatible from prefect.utilities.collections import AutoEnum +from prefect.utilities.dockerutils import ( + format_outlier_version_name, + get_prefect_image_name, + parse_image_tag, +) from prefect.utilities.importtools import lazy_import from prefect.utilities.slugify import slugify diff --git a/src/prefect/infrastructure/kubernetes.py b/src/prefect/infrastructure/kubernetes.py index 8db68587d0bd..a4acd6c2bb77 100644 --- a/src/prefect/infrastructure/kubernetes.py +++ b/src/prefect/infrastructure/kubernetes.py @@ -13,10 +13,10 @@ from typing_extensions import Literal from prefect.blocks.kubernetes import KubernetesClusterConfig -from prefect.docker import get_prefect_image_name from prefect.exceptions import InfrastructureNotAvailable, InfrastructureNotFound from prefect.infrastructure.base import Infrastructure, InfrastructureResult from prefect.utilities.asyncutils import run_sync_in_worker_thread, sync_compatible +from prefect.utilities.dockerutils import get_prefect_image_name from prefect.utilities.hashing import stable_hash from prefect.utilities.importtools import lazy_import from prefect.utilities.pydantic import JsonPatch diff --git a/src/prefect/packaging/docker.py b/src/prefect/packaging/docker.py index f4f3580a1d87..18d719feaf86 100644 --- a/src/prefect/packaging/docker.py +++ b/src/prefect/packaging/docker.py @@ -6,18 +6,18 @@ from pydantic import AnyHttpUrl, root_validator, validator from typing_extensions import Literal -from prefect.docker import ( +from prefect.flows import Flow, load_flow_from_script +from prefect.packaging.base import PackageManifest, Packager +from prefect.packaging.serializers import SourceSerializer +from prefect.software import CondaEnvironment, PythonEnvironment +from prefect.utilities.asyncutils import run_sync_in_worker_thread +from prefect.utilities.dockerutils import ( ImageBuilder, build_image, get_prefect_image_name, push_image, to_run_command, ) -from prefect.flows import Flow, load_flow_from_script -from prefect.packaging.base import PackageManifest, Packager -from prefect.packaging.serializers import SourceSerializer -from prefect.software import CondaEnvironment, PythonEnvironment -from prefect.utilities.asyncutils import run_sync_in_worker_thread from prefect.utilities.slugify import slugify diff --git a/src/prefect/testing/docker.py b/src/prefect/testing/docker.py index 6e0d1ddfd144..d70a1a2e5542 100644 --- a/src/prefect/testing/docker.py +++ b/src/prefect/testing/docker.py @@ -2,7 +2,7 @@ from typing import Generator, List from unittest import mock -from prefect.docker import ImageBuilder +from prefect.utilities.dockerutils import ImageBuilder @contextmanager diff --git a/src/prefect/docker.py b/src/prefect/utilities/dockerutils.py similarity index 100% rename from src/prefect/docker.py rename to src/prefect/utilities/dockerutils.py diff --git a/tests/cli/test_kubernetes_manifest.py b/tests/cli/test_kubernetes_manifest.py index 968c69748c90..c90b80d64930 100644 --- a/tests/cli/test_kubernetes_manifest.py +++ b/tests/cli/test_kubernetes_manifest.py @@ -1,6 +1,5 @@ import yaml -from prefect.docker import get_prefect_image_name from prefect.infrastructure.kubernetes import KubernetesJob from prefect.settings import ( PREFECT_API_KEY, @@ -8,6 +7,7 @@ PREFECT_LOGGING_SERVER_LEVEL, ) from prefect.testing.cli import invoke_and_assert +from prefect.utilities.dockerutils import get_prefect_image_name def test_printing_the_server_manifest_with_no_args(): diff --git a/tests/docker/test_image_builder_assertions.py b/tests/docker/test_image_builder_assertions.py index 93bf97607a43..f87393dd5bbf 100644 --- a/tests/docker/test_image_builder_assertions.py +++ b/tests/docker/test_image_builder_assertions.py @@ -2,8 +2,8 @@ import pytest -from prefect.docker import ImageBuilder from prefect.testing.docker import capture_builders +from prefect.utilities.dockerutils import ImageBuilder @pytest.fixture diff --git a/tests/docker/test_image_builds.py b/tests/docker/test_image_builds.py index a6ef47d68646..bb2dace4075c 100644 --- a/tests/docker/test_image_builds.py +++ b/tests/docker/test_image_builds.py @@ -7,7 +7,7 @@ from _pytest.capture import CaptureFixture import prefect -from prefect.docker import ( +from prefect.utilities.dockerutils import ( BuildError, ImageBuilder, build_image, diff --git a/tests/docker/test_image_parsing.py b/tests/docker/test_image_parsing.py index 037bd48dcdcb..249f2190106b 100644 --- a/tests/docker/test_image_parsing.py +++ b/tests/docker/test_image_parsing.py @@ -1,7 +1,7 @@ import packaging.version import pytest -from prefect.docker import format_outlier_version_name, parse_image_tag +from prefect.utilities.dockerutils import format_outlier_version_name, parse_image_tag @pytest.mark.parametrize( diff --git a/tests/docker/test_registry_pushes.py b/tests/docker/test_registry_pushes.py index 13a7e1d68147..7dd35b90a345 100644 --- a/tests/docker/test_registry_pushes.py +++ b/tests/docker/test_registry_pushes.py @@ -7,7 +7,12 @@ import pytest from _pytest.capture import CaptureFixture -from prefect.docker import ImageBuilder, PushError, push_image, silence_docker_warnings +from prefect.utilities.dockerutils import ( + ImageBuilder, + PushError, + push_image, + silence_docker_warnings, +) from prefect.utilities.slugify import slugify with silence_docker_warnings(): diff --git a/tests/fixtures/docker.py b/tests/fixtures/docker.py index 489fabd132d8..b6c8c64e1ae5 100644 --- a/tests/fixtures/docker.py +++ b/tests/fixtures/docker.py @@ -7,13 +7,13 @@ import prefect from prefect.cli.dev import dev_app -from prefect.docker import ( +from prefect.infrastructure.container import CONTAINER_LABELS +from prefect.utilities.dockerutils import ( IMAGE_LABELS, docker_client, get_prefect_image_name, silence_docker_warnings, ) -from prefect.infrastructure.docker import CONTAINER_LABELS with silence_docker_warnings(): from docker import DockerClient diff --git a/tests/infrastructure/test_base.py b/tests/infrastructure/test_base.py index 7eaabb3a5d40..9794584a03e1 100644 --- a/tests/infrastructure/test_base.py +++ b/tests/infrastructure/test_base.py @@ -7,7 +7,6 @@ import prefect from prefect import engine -from prefect.docker import get_prefect_image_name from prefect.infrastructure import ( DockerContainer, Infrastructure, @@ -16,6 +15,7 @@ ) from prefect.infrastructure.base import MIN_COMPAT_PREFECT_VERSION from prefect.server.schemas.core import Deployment +from prefect.utilities.dockerutils import get_prefect_image_name @pytest.fixture diff --git a/tests/infrastructure/test_docker_container.py b/tests/infrastructure/test_docker_container.py index 606c97d3a187..03e416f1194c 100644 --- a/tests/infrastructure/test_docker_container.py +++ b/tests/infrastructure/test_docker_container.py @@ -7,15 +7,15 @@ import docker import pytest -from prefect.docker import get_prefect_image_name from prefect.exceptions import InfrastructureNotAvailable, InfrastructureNotFound -from prefect.infrastructure.docker import ( +from prefect.infrastructure.container import ( CONTAINER_LABELS, DockerContainer, DockerRegistry, ImagePullPolicy, ) from prefect.testing.utilities import assert_does_not_warn +from prefect.utilities.dockerutils import get_prefect_image_name if TYPE_CHECKING: from docker import DockerClient diff --git a/tests/packaging/test_docker_packager.py b/tests/packaging/test_docker_packager.py index 99d8f4759a3e..205882bc07c5 100644 --- a/tests/packaging/test_docker_packager.py +++ b/tests/packaging/test_docker_packager.py @@ -7,11 +7,14 @@ import pytest -from prefect.docker import get_prefect_image_name, silence_docker_warnings from prefect.packaging.docker import DockerPackageManifest, DockerPackager from prefect.software.conda import CondaEnvironment from prefect.software.python import PythonEnvironment from prefect.utilities.callables import parameter_schema +from prefect.utilities.dockerutils import ( + get_prefect_image_name, + silence_docker_warnings, +) from . import howdy diff --git a/tests/utilities/test_importtools.py b/tests/utilities/test_importtools.py index 629709b4425e..76c1531e4534 100644 --- a/tests/utilities/test_importtools.py +++ b/tests/utilities/test_importtools.py @@ -9,8 +9,8 @@ import prefect from prefect import __development_base_path__ -from prefect.docker import docker_client from prefect.exceptions import ScriptError +from prefect.utilities.dockerutils import docker_client from prefect.utilities.filesystem import tmpchdir from prefect.utilities.importtools import ( from_qualified_name,