Skip to content

Commit

Permalink
Rename docker modules to avoid conflict (#8788)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored May 25, 2023
1 parent c21522c commit 8d1c4cc
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 29 deletions.
12 changes: 11 additions & 1 deletion src/prefect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion src/prefect/cli/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/cli/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/infrastructure/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/infrastructure/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/prefect/packaging/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/prefect/testing/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/cli/test_kubernetes_manifest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import yaml

from prefect.docker import get_prefect_image_name
from prefect.infrastructure.kubernetes import KubernetesJob
from prefect.settings import (
PREFECT_API_KEY,
PREFECT_API_URL,
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():
Expand Down
2 changes: 1 addition & 1 deletion tests/docker/test_image_builder_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/docker/test_image_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from _pytest.capture import CaptureFixture

import prefect
from prefect.docker import (
from prefect.utilities.dockerutils import (
BuildError,
ImageBuilder,
build_image,
Expand Down
2 changes: 1 addition & 1 deletion tests/docker/test_image_parsing.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
7 changes: 6 additions & 1 deletion tests/docker/test_registry_pushes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/infrastructure/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import prefect
from prefect import engine
from prefect.docker import get_prefect_image_name
from prefect.infrastructure import (
DockerContainer,
Infrastructure,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/infrastructure/test_docker_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tests/packaging/test_docker_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/test_importtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8d1c4cc

Please sign in to comment.