Skip to content

Commit

Permalink
Deprecate Compute function data classes
Browse files Browse the repository at this point in the history
Marked the `ComputeFunctionDocument` and `ComputeFunctionMetadata`
classes for deprecation. This reflects an early design adjustment to
better align with the existing Globus Compute SDK.
  • Loading branch information
rjmello committed Oct 23, 2024
1 parent 9030598 commit 7836951
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Deprecated
~~~~~~~~~~

- Deprecated the ``ComputeFunctionDocument`` and ``ComputeFunctionMetadata`` classes.
This change reflects an early design adjustment to better align with the existing
Globus Compute SDK. (:pr:`NUMBER`)
11 changes: 0 additions & 11 deletions docs/services/compute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ Globus Compute
.. listknownscopes:: globus_sdk.scopes.ComputeScopes
:base_name: ComputeClient.scopes

Helper Objects
--------------

.. autoclass:: ComputeFunctionDocument
:members:
:show-inheritance:

.. autoclass:: ComputeFunctionMetadata
:members:
:show-inheritance:

Client Errors
-------------

Expand Down
2 changes: 2 additions & 0 deletions scripts/ensure_exports_are_documented.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
)

DEPRECATED_NAMES = {
"ComputeFunctionDocument",
"ComputeFunctionMetadata",
"TimerAPIError",
"TimerClient",
"TimerScopes",
Expand Down
3 changes: 1 addition & 2 deletions src/globus_sdk/services/compute/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from globus_sdk._types import UUIDLike
from globus_sdk.scopes import ComputeScopes, Scope

from .data import ComputeFunctionDocument
from .errors import ComputeAPIError

log = logging.getLogger(__name__)
Expand All @@ -27,7 +26,7 @@ class ComputeClient(client.BaseClient):

def register_function(
self,
function_data: ComputeFunctionDocument | dict[str, t.Any],
function_data: dict[str, t.Any],
) -> GlobusHTTPResponse:
"""Register a new function.
Expand Down
17 changes: 15 additions & 2 deletions src/globus_sdk/services/compute/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

from globus_sdk import utils
from globus_sdk._types import UUIDLike
from globus_sdk.exc import warn_deprecated
from globus_sdk.utils import MISSING, MissingType


class ComputeFunctionMetadata(utils.PayloadWrapper):
"""A wrapper for function metadata.
"""
.. warning::
This class is deprecated.
A wrapper for function metadata.
:param python_version: The Python version used to serialize the function.
:param sdk_version: The Globus Compute SDK version used to serialize the function.
Expand All @@ -18,13 +24,19 @@ def __init__(
python_version: str | MissingType = MISSING,
sdk_version: str | MissingType = MISSING,
):
warn_deprecated("ComputeFunctionMetadata is deprecated.")
super().__init__()
self["python_version"] = python_version
self["sdk_version"] = sdk_version


class ComputeFunctionDocument(utils.PayloadWrapper):
"""A function registration document.
"""
.. warning::
This class is deprecated.
A function registration document.
:param function_name: The name of the function.
:param function_code: The serialized function source code.
Expand All @@ -44,6 +56,7 @@ def __init__(
group: UUIDLike | MissingType = MISSING,
public: bool = False,
):
warn_deprecated("ComputeFunctionDocument is deprecated.")
super().__init__()
self["function_name"] = function_name
self["function_code"] = function_code
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/services/compute/test_register_function.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import globus_sdk
from globus_sdk._testing import load_response
from globus_sdk.services.compute import ComputeFunctionDocument


def test_register_function(compute_client: globus_sdk.ComputeClient):
meta = load_response(compute_client.register_function).metadata
function_doc = ComputeFunctionDocument(
function_name=meta["function_name"], function_code=meta["function_code"]
)
res = compute_client.register_function(function_doc)
registration_doc = {
"function_name": meta["function_name"],
"function_code": meta["function_code"],
}
res = compute_client.register_function(function_data=registration_doc)
assert res.http_status == 200
assert res.data["function_uuid"] == meta["function_id"]
21 changes: 21 additions & 0 deletions tests/unit/services/compute/test_deprecated_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest

from globus_sdk.exc import RemovedInV4Warning
from globus_sdk.services.compute.data import (
ComputeFunctionDocument,
ComputeFunctionMetadata,
)


def test_compute_function_metadata_deprecated():
with pytest.warns(
RemovedInV4Warning, match="ComputeFunctionMetadata is deprecated."
):
ComputeFunctionMetadata()


def test_compute_function_document_deprecated():
with pytest.warns(
RemovedInV4Warning, match="ComputeFunctionDocument is deprecated."
):
ComputeFunctionDocument(function_name="foo", function_code="bar")

0 comments on commit 7836951

Please sign in to comment.