Skip to content

Commit

Permalink
feat: Relpace funcx with the new globus compute sdk package
Browse files Browse the repository at this point in the history
  • Loading branch information
NickolausDS committed May 5, 2023
1 parent 5139f75 commit 6257742
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
7 changes: 3 additions & 4 deletions gladier/managers/funcx_manager.py
Expand Up @@ -3,8 +3,7 @@

from gladier.base import GladierBaseTool
from gladier.managers.service_manager import ServiceManager
from funcx import FuncXClient
from funcx.serialize import FuncXSerializer
from globus_compute_sdk import serialize, Client

import gladier.utils.funcx_login_manager

Expand Down Expand Up @@ -32,7 +31,7 @@ def funcx_client(self):
authorizers=self.login_manager.get_manager_authorizers()
)

self.__funcx_client = FuncXClient(login_manager=funcx_login_manager)
self.__funcx_client = Client(login_manager=funcx_login_manager)
return self.__funcx_client

@staticmethod
Expand All @@ -52,7 +51,7 @@ def get_funcx_function_checksum(funcx_function):
Get the SHA256 checksum of a funcx function
:return: sha256 hex string of a given funcx function
"""
fxs = FuncXSerializer()
fxs = serialize.ComputeSerializer()
serialized_func = fxs.serialize(funcx_function).encode()
return hashlib.sha256(serialized_func).hexdigest()

Expand Down
2 changes: 1 addition & 1 deletion gladier/tests/test_utilities.py
@@ -1,5 +1,5 @@

from funcx.sdk.login_manager.protocol import LoginManagerProtocol
from globus_compute_sdk.sdk.login_manager.protocol import LoginManagerProtocol
from gladier.utils.funcx_login_manager import FuncXLoginManager


Expand Down
4 changes: 2 additions & 2 deletions gladier/utils/automate.py
@@ -1,6 +1,6 @@
import traceback
import logging
from funcx.serialize import FuncXSerializer
from globus_compute_sdk import serialize

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -44,6 +44,6 @@ def get_details(response, state_name=None):

def deserialize_exception(encoded_exc):
try:
FuncXSerializer().deserialize(encoded_exc).reraise()
serialize.ComputeSerializer().deserialize(encoded_exc).reraise()
except Exception:
return traceback.format_exc()
22 changes: 8 additions & 14 deletions gladier/utils/funcx_login_manager.py
Expand Up @@ -2,9 +2,9 @@

import logging
import globus_sdk
from globus_sdk.scopes import AuthScopes, SearchScopes
from funcx.sdk.web_client import FuncxWebClient
from funcx import FuncXClient
from globus_sdk.scopes import AuthScopes
from globus_compute_sdk.sdk.web_client import WebClient
from globus_compute_sdk import Client

log = logging.getLogger(__name__)

Expand All @@ -16,9 +16,8 @@ class FuncXLoginManager:
https://github.com/funcx-faas/funcX/blob/main/funcx_sdk/funcx/sdk/login_manager/protocol.py#L18
"""
SCOPES = [
FuncXClient.FUNCX_SCOPE,
Client.FUNCX_SCOPE,
AuthScopes.openid,
SearchScopes.all
]

def __init__(self, authorizers: dict[str, globus_sdk.RefreshTokenAuthorizer]):
Expand All @@ -29,18 +28,13 @@ def get_auth_client(self) -> globus_sdk.AuthClient:
authorizer=self.authorizers[AuthScopes.openid]
)

def get_search_client(self) -> globus_sdk.SearchClient:
return globus_sdk.SearchClient(
authorizer=self.authorizers[SearchScopes.all]
)

def get_funcx_web_client(
def get_web_client(
self, *, base_url: str | None = None, app_name: str | None = None
) -> FuncxWebClient:
return FuncxWebClient(
) -> WebClient:
return WebClient(
base_url=base_url,
app_name=app_name,
authorizer=self.authorizers[FuncXClient.FUNCX_SCOPE],
authorizer=self.authorizers[Client.FUNCX_SCOPE],
)

def ensure_logged_in(self):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,4 +1,4 @@
funcx>=1.0.2,<2.0.0
globus-compute-sdk>=2.0.1,<3.0.0
globus-automate-client>=0.13,<0.17
packaging>=21.3
fair-research-login>=0.2.6

0 comments on commit 6257742

Please sign in to comment.