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

Commit

Permalink
Deprecate CloudRunJob and VertexAICustomTrainingJob infrastructur…
Browse files Browse the repository at this point in the history
…e blocks (#255)

* Deprecate `CloudRunJob` and `VertexAICustomTrainingJob` infrastructure blocks

* Bump minimum prefect version

* Fixes tests
  • Loading branch information
desertaxle authored Mar 15, 2024
1 parent c7be9eb commit b88d619
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
18 changes: 16 additions & 2 deletions prefect_gcp/aiplatform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"""
<span class="badge-api experimental"/>
DEPRECATION WARNING:
This module is deprecated as of March 2024 and will not be available after September 2024.
It has been replaced by the Vertex AI worker, which offers enhanced functionality and better performance.
For upgrade instructions, see https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.
Integrations with Google AI Platform.
Expand Down Expand Up @@ -50,7 +55,7 @@
)
job.preview()
```
"""
""" # noqa

import datetime
import re
Expand All @@ -60,6 +65,7 @@
from uuid import uuid4

from anyio.abc import TaskStatus
from prefect._internal.compatibility.deprecated import deprecated_class
from prefect.exceptions import InfrastructureNotFound
from prefect.infrastructure import Infrastructure, InfrastructureResult
from prefect.utilities.asyncutils import run_sync_in_worker_thread, sync_compatible
Expand Down Expand Up @@ -107,6 +113,14 @@ class VertexAICustomTrainingJobResult(InfrastructureResult):
"""Result from a Vertex AI custom training job."""


@deprecated_class(
start_date="Mar 2024",
help=(
"Use the Vertex AI worker instead."
" Refer to the upgrade guide for more information:"
" https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/."
),
)
class VertexAICustomTrainingJob(Infrastructure):
"""
Infrastructure block used to run Vertex AI custom training jobs.
Expand Down
18 changes: 16 additions & 2 deletions prefect_gcp/cloud_run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"""
<span class="badge-api experimental"/>
DEPRECATION WARNING:
This module is deprecated as of March 2024 and will not be available after September 2024.
It has been replaced by the Cloud Run and Cloud Run V2 workers, which offer enhanced functionality and better performance.
For upgrade instructions, see https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.
Integrations with Google Cloud Run Job.
Expand All @@ -26,7 +31,7 @@
).run()
```
"""
""" # noqa

from __future__ import annotations

Expand All @@ -42,6 +47,7 @@
from google.api_core.client_options import ClientOptions
from googleapiclient import discovery
from googleapiclient.discovery import Resource
from prefect._internal.compatibility.deprecated import deprecated_class
from prefect.exceptions import InfrastructureNotFound
from prefect.infrastructure.base import Infrastructure, InfrastructureResult
from prefect.utilities.asyncutils import run_sync_in_worker_thread, sync_compatible
Expand Down Expand Up @@ -210,6 +216,14 @@ class CloudRunJobResult(InfrastructureResult):
"""Result from a Cloud Run Job."""


@deprecated_class(
start_date="Mar 2024",
help=(
"Use the Cloud Run or Cloud Run v2 worker instead."
" Refer to the upgrade guide for more information:"
" https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/."
),
)
class CloudRunJob(Infrastructure):
"""
<span class="badge-api experimental"/>
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefect>=2.14.10
prefect>=2.16.4
google-api-python-client>=2.20.0
google-cloud-storage>=2.0.0
tenacity>=8.0.0
Expand Down
36 changes: 36 additions & 0 deletions tests/test_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pytest
from prefect._internal.compatibility.deprecated import PrefectDeprecationWarning

from prefect_gcp.aiplatform import VertexAICustomTrainingJob
from prefect_gcp.cloud_run import CloudRunJob


@pytest.mark.parametrize(
"InfraBlock, kwargs, expected_message",
[
(
CloudRunJob,
{"image": "foo", "region": "us-central1"},
"prefect_gcp.cloud_run.CloudRunJob has been deprecated."
" It will not be available after Sep 2024."
" Use the Cloud Run or Cloud Run v2 worker instead."
" Refer to the upgrade guide for more information",
),
(
VertexAICustomTrainingJob,
{"image": "foo", "region": "us-central1"},
"prefect_gcp.aiplatform.VertexAICustomTrainingJob has been deprecated."
" It will not be available after Sep 2024."
" Use the Vertex AI worker instead."
" Refer to the upgrade guide for more information",
),
],
)
def test_infra_blocks_emit_a_deprecation_warning(
InfraBlock, kwargs, expected_message, gcp_credentials
):
with pytest.warns(PrefectDeprecationWarning, match=expected_message):
if InfraBlock == CloudRunJob:
InfraBlock(**kwargs, credentials=gcp_credentials)
else:
InfraBlock(**kwargs, gcp_credentials=gcp_credentials)

0 comments on commit b88d619

Please sign in to comment.