From 2b5c45968e0dd79ceee69815bde67f0b6ac41be2 Mon Sep 17 00:00:00 2001 From: Lei Wang Date: Wed, 4 Sep 2024 14:39:25 -0500 Subject: [PATCH] add high-assurance placeholder option to endpoint configuration --- compute_endpoint/globus_compute_endpoint/cli.py | 13 +++++++++++++ .../endpoint/config/config.py | 3 +++ .../endpoint/config/default_config.py | 1 + .../globus_compute_endpoint/endpoint/endpoint.py | 10 ++++++++++ .../endpoint/endpoint_manager.py | 1 + compute_sdk/globus_compute_sdk/sdk/client.py | 4 ++++ compute_sdk/globus_compute_sdk/sdk/web_client.py | 3 +++ 7 files changed, 35 insertions(+) diff --git a/compute_endpoint/globus_compute_endpoint/cli.py b/compute_endpoint/globus_compute_endpoint/cli.py index b2fe6ecfb..4baeb25e0 100644 --- a/compute_endpoint/globus_compute_endpoint/cli.py +++ b/compute_endpoint/globus_compute_endpoint/cli.py @@ -300,6 +300,12 @@ def version_command(): default=False, help="Configure endpoint as multi-user capable", ) +@click.option( + "--high-assurance", + is_flag=True, + default=False, + help="Configure endpoint as high assurance capable", +) @click.option( "--display-name", help="A human readable display name for the endpoint, if desired", @@ -366,6 +372,7 @@ def configure_endpoint( name: str, endpoint_config: str | None, multi_user: bool, + high_assurance: bool, display_name: str | None, auth_policy: str | None, auth_policy_project_id: str | None, @@ -389,6 +396,11 @@ def configure_endpoint( if multi_user and not _has_multi_user: raise ClickException("multi-user endpoints are not supported on this system") + if high_assurance and not auth_policy and not subscription_id: + raise ClickException( + "high-assurance(HA) endpoints require a HA policy or subscription id" + ) + if ( auth_policy_project_id is not None or auth_policy_display_name != _AUTH_POLICY_DEFAULT_NAME @@ -433,6 +445,7 @@ def configure_endpoint( ep_dir, endpoint_config, multi_user, + high_assurance, display_name, auth_policy, subscription_id, diff --git a/compute_endpoint/globus_compute_endpoint/endpoint/config/config.py b/compute_endpoint/globus_compute_endpoint/endpoint/config/config.py index b5e204c27..ba709bd9b 100644 --- a/compute_endpoint/globus_compute_endpoint/endpoint/config/config.py +++ b/compute_endpoint/globus_compute_endpoint/endpoint/config/config.py @@ -68,6 +68,7 @@ def __init__( heartbeat_period: float | int = 30, environment: str | None = None, local_compute_services: bool = False, + # high_assurance: bool | None = None, debug: bool = False, ): # Misc @@ -75,6 +76,8 @@ def __init__( self.debug = debug is True self.multi_user = multi_user is True + # self.high_assurance = high_assurance is True + # Connection info and tuning self.amqp_port = amqp_port self.heartbeat_period = heartbeat_period diff --git a/compute_endpoint/globus_compute_endpoint/endpoint/config/default_config.py b/compute_endpoint/globus_compute_endpoint/endpoint/config/default_config.py index 8cd39642b..4464715a0 100644 --- a/compute_endpoint/globus_compute_endpoint/endpoint/config/default_config.py +++ b/compute_endpoint/globus_compute_endpoint/endpoint/config/default_config.py @@ -4,6 +4,7 @@ config = UserEndpointConfig( display_name=None, # If None, defaults to the endpoint name + high_assurance=False, executors=[ GlobusComputeEngine( provider=LocalProvider( diff --git a/compute_endpoint/globus_compute_endpoint/endpoint/endpoint.py b/compute_endpoint/globus_compute_endpoint/endpoint/endpoint.py index 99d647911..f26d047c7 100644 --- a/compute_endpoint/globus_compute_endpoint/endpoint/endpoint.py +++ b/compute_endpoint/globus_compute_endpoint/endpoint/endpoint.py @@ -76,6 +76,7 @@ def update_config_file( original_path: pathlib.Path, target_path: pathlib.Path, multi_user: bool, + high_assurance: bool, display_name: str | None, auth_policy: str | None, subscription_id: str | None, @@ -89,6 +90,9 @@ def update_config_file( if auth_policy: config_dict["authentication_policy"] = auth_policy + if high_assurance: + config_dict["high_assurance"] = high_assurance + if multi_user: config_dict["multi_user"] = multi_user config_dict.pop("engine", None) @@ -109,6 +113,7 @@ def init_endpoint_dir( endpoint_dir: pathlib.Path, endpoint_config: pathlib.Path | None = None, multi_user=False, + high_assurance=False, display_name: str | None = None, auth_policy: str | None = None, subscription_id: str | None = None, @@ -143,6 +148,7 @@ def init_endpoint_dir( endpoint_config, config_target_path, multi_user, + high_assurance, display_name, auth_policy, subscription_id, @@ -187,6 +193,7 @@ def configure_endpoint( conf_dir: pathlib.Path, endpoint_config: str | None, multi_user: bool = False, + high_assurance: bool = False, display_name: str | None = None, auth_policy: str | None = None, subscription_id: str | None = None, @@ -202,6 +209,7 @@ def configure_endpoint( conf_dir, templ_conf_path, multi_user, + high_assurance, display_name, auth_policy, subscription_id, @@ -428,6 +436,8 @@ def start_endpoint( allowed_functions=endpoint_config.allowed_functions, auth_policy=endpoint_config.authentication_policy, subscription_id=endpoint_config.subscription_id, + # public=endpoint_config.public, + high_assurance=endpoint_config.high_assurance, ) except GlobusAPIError as e: diff --git a/compute_endpoint/globus_compute_endpoint/endpoint/endpoint_manager.py b/compute_endpoint/globus_compute_endpoint/endpoint/endpoint_manager.py index d87720c2c..dbea2b8c4 100644 --- a/compute_endpoint/globus_compute_endpoint/endpoint/endpoint_manager.py +++ b/compute_endpoint/globus_compute_endpoint/endpoint/endpoint_manager.py @@ -159,6 +159,7 @@ def __init__( auth_policy=config.authentication_policy, subscription_id=config.subscription_id, public=config.public, + high_assurance=config.high_assurance, ) # Mostly to appease mypy, but also a useful text if it ever diff --git a/compute_sdk/globus_compute_sdk/sdk/client.py b/compute_sdk/globus_compute_sdk/sdk/client.py index ac53e2e25..c6834a3a9 100644 --- a/compute_sdk/globus_compute_sdk/sdk/client.py +++ b/compute_sdk/globus_compute_sdk/sdk/client.py @@ -424,6 +424,7 @@ def register_endpoint( auth_policy: UUID_LIKE_T | None = None, subscription_id: UUID_LIKE_T | None = None, public: bool | None = None, + high_assurance: bool | None = None, ): """Register an endpoint with the Globus Compute service. @@ -437,6 +438,8 @@ def register_endpoint( Endpoint metadata multi_user : bool | None Whether the endpoint supports multiple users + high_assurance : bool | None + Whether the endpoint should be high assurance capable display_name : str | None The display name of the endpoint allowed_functions: list[str | UUID] | None @@ -467,6 +470,7 @@ def register_endpoint( auth_policy=auth_policy, subscription_id=subscription_id, public=public, + high_assurance=high_assurance, ) return r.data diff --git a/compute_sdk/globus_compute_sdk/sdk/web_client.py b/compute_sdk/globus_compute_sdk/sdk/web_client.py index d5cfe03f4..8034b23f6 100644 --- a/compute_sdk/globus_compute_sdk/sdk/web_client.py +++ b/compute_sdk/globus_compute_sdk/sdk/web_client.py @@ -191,6 +191,7 @@ def register_endpoint( subscription_id: t.Optional[UUID_LIKE_T] = None, public: t.Optional[bool] = None, additional_fields: t.Optional[t.Dict[str, t.Any]] = None, + high_assurance: t.Optional[bool] = None, ) -> globus_sdk.GlobusHTTPResponse: data: t.Dict[str, t.Any] = {"endpoint_name": endpoint_name} @@ -215,6 +216,8 @@ def register_endpoint( data["subscription_uuid"] = subscription_id if public is not None: data["public"] = public + if high_assurance is not None: + data["high_assurance"] = high_assurance if additional_fields is not None: data.update(additional_fields)