Skip to content

Commit

Permalink
Refactor internal imports of prefect_client (PrefectHQ#13751)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaazzam authored Jun 3, 2024
1 parent 703495a commit 899689a
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 22 deletions.
3 changes: 2 additions & 1 deletion flows/flow_results.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import anyio

from prefect import flow, get_client
from prefect import flow
from prefect.client.orchestration import get_client


@flow(persist_result=True)
Expand Down
3 changes: 2 additions & 1 deletion flows/task_results.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import anyio

from prefect import flow, get_client, task
from prefect import flow, task
from prefect.client.orchestration import get_client


@task(persist_result=True)
Expand Down
2 changes: 1 addition & 1 deletion scripts/wait-for-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import anyio

from prefect import get_client
from prefect.client.orchestration import get_client

DEFAULT_TIMEOUT_SECONDS = 120

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
from pydantic import Field, SecretStr
from slugify import slugify

from prefect import get_client
from prefect.client.orchestration import get_client
from prefect.client.schemas import FlowRun
from prefect.exceptions import InfrastructureNotAvailable, InfrastructureNotFound
from prefect.server.schemas.core import Flow
Expand Down Expand Up @@ -371,9 +371,11 @@ def _get_arm_environment(self):
env = {**self._base_environment(), **self.env}

azure_env = [
{"name": key, "secureValue": value}
if key in ENV_SECRETS
else {"name": key, "value": value}
(
{"name": key, "secureValue": value}
if key in ENV_SECRETS
else {"name": key, "value": value}
)
for key, value in env.items()
]
return azure_env
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/cli/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from rich.pretty import Pretty
from rich.table import Table

from prefect import get_client
from prefect.cli._types import PrefectTyper
from prefect.cli._utilities import exit_with_error, exit_with_success
from prefect.cli.root import app, is_interactive
from prefect.client.orchestration import get_client
from prefect.client.schemas.filters import ArtifactFilter, ArtifactFilterKey
from prefect.client.schemas.sorting import ArtifactCollectionSort, ArtifactSort
from prefect.exceptions import ObjectNotFound
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/cli/global_concurrency_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from rich.pretty import Pretty
from rich.table import Table

from prefect import get_client
from prefect.cli._types import PrefectTyper
from prefect.cli._utilities import exit_with_error, exit_with_success
from prefect.cli.root import app, is_interactive
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import (
GlobalConcurrencyLimitCreate,
GlobalConcurrencyLimitUpdate,
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/cli/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from rich.table import Table
from typing_extensions import Annotated

from prefect import get_client
from prefect.cli._types import PrefectTyper
from prefect.cli._utilities import exit_with_error, exit_with_success
from prefect.cli.root import app, is_interactive
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import VariableCreate, VariableUpdate
from prefect.exceptions import ObjectNotFound

Expand Down
3 changes: 2 additions & 1 deletion src/prefect/cli/work_pool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Command line interface for working with work queues.
"""

import json
import textwrap

Expand All @@ -9,7 +10,6 @@
from rich.pretty import Pretty
from rich.table import Table

from prefect import get_client
from prefect.cli._prompts import prompt_select_from_table
from prefect.cli._types import PrefectTyper
from prefect.cli._utilities import (
Expand All @@ -18,6 +18,7 @@
)
from prefect.cli.root import app, is_interactive
from prefect.client.collections import get_collections_metadata_client
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import WorkPoolCreate, WorkPoolUpdate
from prefect.exceptions import ObjectAlreadyExists, ObjectNotFound
from prefect.infrastructure.provisioners import (
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/cli/work_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from rich.pretty import Pretty
from rich.table import Table

from prefect import get_client
from prefect.cli._types import PrefectTyper
from prefect.cli._utilities import exit_with_error, exit_with_success
from prefect.cli.root import app, is_interactive
from prefect.client.orchestration import get_client
from prefect.client.schemas.filters import WorkPoolFilter, WorkPoolFilterId
from prefect.client.schemas.objects import DEFAULT_AGENT_WORK_POOL_NAME
from prefect.exceptions import ObjectAlreadyExists, ObjectNotFound
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/concurrency/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# pendulum < 3
from pendulum.period import Period as Interval # type: ignore

from prefect import get_client
from prefect.client.orchestration import get_client
from prefect.client.schemas.responses import MinimalConcurrencyLimitResponse
from prefect.utilities.timeout import timeout_async

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/concurrency/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import httpx
from starlette import status

from prefect import get_client
from prefect._internal.concurrency import logger
from prefect._internal.concurrency.services import QueueService
from prefect.client.orchestration import get_client

if TYPE_CHECKING:
from prefect.client.orchestration import PrefectClient
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/flow_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from sniffio import AsyncLibraryNotFoundError
from typing_extensions import ParamSpec

from prefect import Task, get_client
from prefect import Task
from prefect._internal.concurrency.api import create_call, from_sync
from prefect.client.orchestration import SyncPrefectClient
from prefect.client.orchestration import SyncPrefectClient, get_client
from prefect.client.schemas import FlowRun, TaskRun
from prefect.client.schemas.filters import FlowRunFilter
from prefect.client.schemas.sorting import FlowRunSort
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/flow_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def wait_for_flow_run(
```python
import asyncio
from prefect import get_client
from prefect.client.orchestration import get_client
from prefect.flow_runs import wait_for_flow_run
async def main():
Expand All @@ -94,7 +94,7 @@ async def main():
```python
import asyncio
from prefect import get_client
from prefect.client.orchestration import get_client
from prefect.flow_runs import wait_for_flow_run
async def main(num_runs: int):
Expand Down
3 changes: 2 additions & 1 deletion src/prefect/task_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import anyio.abc
from websockets.exceptions import InvalidStatusCode

from prefect import Task, get_client
from prefect import Task
from prefect._internal.concurrency.api import create_call, from_sync
from prefect.client.orchestration import get_client
from prefect.client.schemas.objects import TaskRun
from prefect.client.subscriptions import Subscription
from prefect.exceptions import Abort, PrefectHTTPStatusError
Expand Down
2 changes: 1 addition & 1 deletion tests/blocks/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import prefect
from prefect.blocks.core import Block, InvalidBlockRegistration
from prefect.blocks.system import JSON, Secret
from prefect.client import PrefectClient
from prefect.client.orchestration import PrefectClient
from prefect.exceptions import PrefectHTTPStatusError
from prefect.server import models
from prefect.server.schemas.actions import BlockDocumentCreate
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from prefect.blocks import system
from prefect.client import PrefectClient
from prefect.client.orchestration import PrefectClient
from prefect.exceptions import ObjectNotFound
from prefect.server import models
from prefect.settings import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from httpx import HTTPStatusError, Request, Response

from prefect import get_client
from prefect.client.orchestration import get_client
from prefect.concurrency.services import ConcurrencySlotAcquisitionService


Expand Down

0 comments on commit 899689a

Please sign in to comment.