diff --git a/pathwaysutils/experimental/shared_pathways_service/isc_pathways.py b/pathwaysutils/experimental/shared_pathways_service/isc_pathways.py index c6d2806..edd5715 100644 --- a/pathwaysutils/experimental/shared_pathways_service/isc_pathways.py +++ b/pathwaysutils/experimental/shared_pathways_service/isc_pathways.py @@ -1,6 +1,6 @@ """Module for connecting to a Pathways server for interactive supercomputing.""" -from collections.abc import Iterator, Mapping +from collections.abc import Iterable, Iterator, Mapping import contextlib import dataclasses import gc @@ -48,12 +48,14 @@ class ProxyOptions: use_insecure_credentials: bool = False @classmethod - def from_dict(cls, options: Mapping[str, str] | None) -> "ProxyOptions": - """Creates a ProxyOptions object from a dictionary of options.""" - options = options or {} - use_insecure = ( - options.get("use_insecure_credentials", "false").lower() == "true" - ) + def from_list(cls, options: Iterable[str] | None) -> "ProxyOptions": + """Creates a ProxyOptions object from a list of 'key:value' strings.""" + use_insecure = False + for option in options or []: + if ":" in option: + key, value = option.split(":", 1) + if key.strip().lower() == "use_insecure_credentials": + use_insecure = value.strip().lower() == "true" return cls(use_insecure_credentials=use_insecure) @@ -96,10 +98,12 @@ def _deploy_pathways_proxy_server( proxy_options = proxy_options or ProxyOptions() - proxy_env_str = ( - ' - name: IFRT_PROXY_USE_INSECURE_GRPC_CREDENTIALS\n' - ' value: "true"\n' - ) if proxy_options.use_insecure_credentials else "" + proxy_env_str = "" + if proxy_options.use_insecure_credentials: + proxy_env_str = ( + ' - name: IFRT_PROXY_USE_INSECURE_GRPC_CREDENTIALS\n' + ' value: "true"\n' + ) template = string.Template(yaml_template) substituted_yaml = template.substitute( diff --git a/pathwaysutils/experimental/shared_pathways_service/run_connect_example.py b/pathwaysutils/experimental/shared_pathways_service/run_connect_example.py index 01c71ea..db63c28 100644 --- a/pathwaysutils/experimental/shared_pathways_service/run_connect_example.py +++ b/pathwaysutils/experimental/shared_pathways_service/run_connect_example.py @@ -9,8 +9,6 @@ from pathwaysutils.experimental.shared_pathways_service import isc_pathways -from google3.pyglib.flags.contrib import dict_flag - FLAGS = flags.FLAGS flags.DEFINE_string("cluster", None, "The name of the GKE cluster.") @@ -37,7 +35,7 @@ None, "The proxy server image to use. If not provided, a default will be used.", ) -dict_flag.DEFINE_dict( +flags.DEFINE_list( "proxy_options", None, "Configuration options for the Pathways proxy. Specify entries in the form" @@ -57,7 +55,7 @@ def main(argv: Sequence[str]) -> None: if len(argv) > 1: raise app.UsageError("Too many command-line arguments.") - proxy_options = isc_pathways.ProxyOptions.from_dict(FLAGS.proxy_options) + proxy_options = isc_pathways.ProxyOptions.from_list(FLAGS.proxy_options) with isc_pathways.connect( cluster=FLAGS.cluster,