Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Rename the module so we can import/register it; fix command-line form…
Browse files Browse the repository at this point in the history
…atting
  • Loading branch information
chrisguidry committed Sep 15, 2023
1 parent 4b006db commit 46f195b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
15 changes: 8 additions & 7 deletions prefect_gcp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from . import _version
from prefect._internal.compatibility.deprecated import (
register_renamed_module,
)

from .bigquery import BigQueryWarehouse # noqa
from . import _version
from .aiplatform import VertexAICustomTrainingJob # noqa
from .cloud_storage import GcsBucket # noqa
from .bigquery import BigQueryWarehouse # noqa
from .cloud_run import CloudRunJob # noqa
from .secret_manager import GcpSecret # noqa
from .cloud_storage import GcsBucket # noqa
from .credentials import GcpCredentials # noqa
from .secret_manager import GcpSecret # noqa
from .vertex_worker import VertexAIWorker # noqa
from .worker import CloudRunWorker # noqa
from prefect._internal.compatibility.deprecated import (
register_renamed_module,
)

register_renamed_module(
"prefect_gcp.projects", "prefect_gcp.deployments", start_date="Jun 2023"
Expand Down
13 changes: 11 additions & 2 deletions prefect_gcp/vertex-worker.py → prefect_gcp/vertex_worker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import shlex
import datetime
import re
import time
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, MutableSequence
from uuid import uuid4

import anyio
Expand Down Expand Up @@ -299,6 +300,13 @@ def job_name(self) -> str:
job_name = f"{repo_name}-{unique_suffix}"
return job_name

def command_as_list(self) -> MutableSequence[str]:
if not self.command:
return ["python", "-m", "prefect.engine"]

return shlex.split(self.command)



class VertexAIWorkerResult(BaseWorkerResult):
"""Contains information about the final state of a completed process"""
Expand Down Expand Up @@ -397,9 +405,10 @@ def _build_job_spec(
**configuration.env,
}.items()
]

container_spec = ContainerSpec(
image_uri=configuration.image,
command=configuration.command,
command=configuration.command_as_list(),
args=[],
env=env_list,
)
Expand Down

0 comments on commit 46f195b

Please sign in to comment.