|
1 | 1 | """Module for connecting to a Pathways server for interactive supercomputing.""" |
2 | 2 |
|
3 | | -from collections.abc import Iterator, Mapping |
| 3 | +from collections.abc import Iterable, Iterator, Mapping |
4 | 4 | import contextlib |
5 | 5 | import dataclasses |
6 | 6 | import gc |
@@ -48,12 +48,14 @@ class ProxyOptions: |
48 | 48 | use_insecure_credentials: bool = False |
49 | 49 |
|
50 | 50 | @classmethod |
51 | | - def from_dict(cls, options: Mapping[str, str] | None) -> "ProxyOptions": |
52 | | - """Creates a ProxyOptions object from a dictionary of options.""" |
53 | | - options = options or {} |
54 | | - use_insecure = ( |
55 | | - options.get("use_insecure_credentials", "false").lower() == "true" |
56 | | - ) |
| 51 | + def from_list(cls, options: Iterable[str] | None) -> "ProxyOptions": |
| 52 | + """Creates a ProxyOptions object from a list of 'key:value' strings.""" |
| 53 | + use_insecure = False |
| 54 | + for option in options or []: |
| 55 | + if ":" in option: |
| 56 | + key, value = option.split(":", 1) |
| 57 | + if key.strip().lower() == "use_insecure_credentials": |
| 58 | + use_insecure = value.strip().lower() == "true" |
57 | 59 | return cls(use_insecure_credentials=use_insecure) |
58 | 60 |
|
59 | 61 |
|
@@ -96,10 +98,12 @@ def _deploy_pathways_proxy_server( |
96 | 98 |
|
97 | 99 | proxy_options = proxy_options or ProxyOptions() |
98 | 100 |
|
99 | | - proxy_env_str = ( |
100 | | - ' - name: IFRT_PROXY_USE_INSECURE_GRPC_CREDENTIALS\n' |
101 | | - ' value: "true"\n' |
102 | | - ) if proxy_options.use_insecure_credentials else "" |
| 101 | + proxy_env_str = "" |
| 102 | + if proxy_options.use_insecure_credentials: |
| 103 | + proxy_env_str = ( |
| 104 | + ' - name: IFRT_PROXY_USE_INSECURE_GRPC_CREDENTIALS\n' |
| 105 | + ' value: "true"\n' |
| 106 | + ) |
103 | 107 |
|
104 | 108 | template = string.Template(yaml_template) |
105 | 109 | substituted_yaml = template.substitute( |
|
0 commit comments