Skip to content

Commit

Permalink
Separate MultiUser configuration
Browse files Browse the repository at this point in the history
To date, we've been comingling the MEP and UEP configurations in `Config`.  At
this time, the two implementations are starting to diverge in their overlap, so
bite the bullet and be clear about the differences.  This implementation uses
`BaseConfig` for the shared attributes, maintains `Config` for backward
compatability, and introduces `UserEndpointConfig` for the user endpoint and
`ManagerEndpointConfig` for the endpoint manager configuration.

The core of the changes start in `endpoint/config/config.py`, where
`UserEndpointConfig` (for UEPs) and `ManagerEndpointConfig` (for MEPs) are
defined.  These are backed up by requisite changes to the Pydantic model in
`config/model.py`,  Just about every other change is in support of the
now-distinct configuration classes.

Notes:
 - test coverage has increased around the configurations
 - the YAML facade shouldn't change at all from the user perspective.  This is
   an internal organization detail

[sc-37362]
  • Loading branch information
khk-globus committed Nov 9, 2024
1 parent f35d3b4 commit f12b50b
Show file tree
Hide file tree
Showing 26 changed files with 845 additions and 445 deletions.
3 changes: 2 additions & 1 deletion compute_endpoint/globus_compute_endpoint/boot_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import textwrap

from click import ClickException
from globus_compute_endpoint.endpoint.config import UserEndpointConfig
from globus_compute_endpoint.endpoint.config.utils import get_config
from globus_compute_endpoint.endpoint.endpoint import Endpoint
from globus_sdk import GlobusApp
Expand Down Expand Up @@ -49,7 +50,7 @@ def enable_on_boot(ep_dir: pathlib.Path, app: GlobusApp):
ep_name = ep_dir.name

config = get_config(ep_dir)
if not config.multi_user:
if isinstance(config, UserEndpointConfig): # aka: not multi_user
if config.detach_endpoint:
# config.py takes priority if it exists
if (ep_dir / "config.py").is_file():
Expand Down
21 changes: 12 additions & 9 deletions compute_endpoint/globus_compute_endpoint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
from click import ClickException
from click_option_group import optgroup
from globus_compute_endpoint.boot_persistence import disable_on_boot, enable_on_boot
from globus_compute_endpoint.endpoint.config import Config
from globus_compute_endpoint.endpoint.config import (
ManagerEndpointConfig,
UserEndpointConfig,
)
from globus_compute_endpoint.endpoint.config.utils import get_config, load_config_yaml
from globus_compute_endpoint.endpoint.endpoint import Endpoint
from globus_compute_endpoint.endpoint.utils import (
Expand Down Expand Up @@ -90,7 +93,7 @@ def get_globus_app_with_scopes() -> GlobusApp:
return app


def get_cli_endpoint(conf: Config) -> Endpoint:
def get_cli_endpoint(conf: UserEndpointConfig) -> Endpoint:
# this getter creates an Endpoint object from the CommandState
# it takes its various configurable values from the current CommandState
# as a result, any number of CLI options may be used to tweak the CommandState
Expand Down Expand Up @@ -673,20 +676,20 @@ def _do_start_endpoint(
log.critical(msg)
raise

if die_with_parent:
# The endpoint cannot die with its parent if it
# doesn't have one :)
ep_config.detach_endpoint = False
log.debug("The --die-with-parent flag has set detach_endpoint to False")

if ep_config.multi_user:
if isinstance(ep_config, ManagerEndpointConfig):
if not _has_multi_user:
raise ClickException(
"multi-user endpoints are not supported on this system"
)
epm = EndpointManager(ep_dir, endpoint_uuid, ep_config, reg_info)
epm.start()
else:
assert isinstance(ep_config, UserEndpointConfig)
if die_with_parent:
# The endpoint cannot die with its parent if it doesn't have one :)
ep_config.detach_endpoint = False
log.debug("The --die-with-parent flag has set detach_endpoint to False")

get_cli_endpoint(ep_config).start_endpoint(
ep_dir,
endpoint_uuid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
from .config import Config # noqa: F401
from .config import ( # noqa: F401
BaseConfig,
Config,
ManagerEndpointConfig,
UserEndpointConfig,
)
from .model import ( # noqa: F401
BaseConfigModel,
ManagerEndpointConfigModel,
UserEndpointConfigModel,
)
Loading

0 comments on commit f12b50b

Please sign in to comment.