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
  • Loading branch information
desertaxle committed Mar 14, 2024
1 parent c7be9eb commit 354cc29
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 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
29 changes: 29 additions & 0 deletions tests/test_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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, expected_message",
[
(
CloudRunJob,
"prefect_gcp.cloud_run.CloudRunJob 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",
),
(
VertexAICustomTrainingJob,
"prefect_gcp.aiplaform.VertexAICustomTrainingJob 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",
),
],
)
def test_infra_blocks_emit_a_deprecation_warning(InfraBlock, expected_message):
with pytest.warns(PrefectDeprecationWarning, match=expected_message):
InfraBlock()

0 comments on commit 354cc29

Please sign in to comment.