Skip to content

Commit

Permalink
feat: Compute functions now use globus_group on client for functions
Browse files Browse the repository at this point in the history
If a globus_group was defined for a Gladier Client, those will be applied
on function registration to defined functions
  • Loading branch information
NickolausDS committed May 15, 2024
1 parent 6c341f2 commit da6005d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 3 additions & 1 deletion gladier/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def __init__(
if not self.flows_manager.flow_title:
self.flows_manager.flow_title = f"{self.__class__.__name__} flow"

self.compute_manager = ComputeManager(auto_registration=auto_registration)
self.compute_manager = ComputeManager(
auto_registration=auto_registration, group=self.globus_group
)
self.storage.update()

for man in (self.flows_manager, self.compute_manager):
Expand Down
9 changes: 6 additions & 3 deletions gladier/managers/compute_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@


class ComputeManager(ServiceManager):
def __init__(self, auto_registration: bool = True, **kwargs):
def __init__(self, auto_registration: bool = True, group: str = None, **kwargs):
super().__init__(**kwargs)
self.auto_registration = auto_registration
self.group = group

def get_scopes(self):
return gladier.managers.compute_login_manager.ComputeLoginManager.SCOPES
Expand Down Expand Up @@ -126,5 +127,7 @@ def validate_function(self, tool: GladierBaseTool, function):

def register_function(self, tool: GladierBaseTool, function):
"""Register the functions with Globus Compute."""
log.info(f"{tool.__class__.__name__}: registering function {function.__name__}")
return self.compute_client.register_function(function)
log.info(
f"{tool.__class__.__name__}: registering function {function.__name__} with group {self.group}"
)
return self.compute_client.register_function(function, group=self.group)
17 changes: 16 additions & 1 deletion gladier/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from gladier.tests.test_data.gladier_mocks import MockGladierClient
from unittest.mock import Mock
from gladier.tests.test_data.gladier_mocks import MockGladierClient, mock_func


def test_get_input(logged_in):
Expand Down Expand Up @@ -54,3 +55,17 @@ def test_pub_config_overrides_priv(logged_in, storage, mock_secrets_config):
def test_run_flow(logged_in):
cli = MockGladierClient()
cli.run_flow()


def test_propagated_group_uuid(monkeypatch, logged_in):
class MockGladierClientShared(MockGladierClient):
globus_group = "my-globus-group"

gladier_tools = ["gladier.tests.test_data.gladier_mocks.GeneratedTool"]

cli = MockGladierClientShared()
monkeypatch.setattr(cli.compute_manager.compute_client, "register_function", Mock())
cli.run_flow()
cli.compute_manager.compute_client.register_function.assert_called_with(
mock_func, group="my-globus-group"
)

0 comments on commit da6005d

Please sign in to comment.