Skip to content

Commit 7b68a2b

Browse files
committed
Update LauncherProtocol
1 parent 1983c97 commit 7b68a2b

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/ansys/tools/common/launcher/interface.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222

2323
"""Interface definitions for implementing a local product launcher.
2424
25-
A plugin for the local product launcher must implement the :class:`LauncherProtocol`
25+
A plugin for the Local Product Launcher must implement the :class:`LauncherProtocol`
2626
class and register it.
2727
"""
2828

2929
from enum import Enum, auto
30-
from types import MappingProxyType
3130
from typing import Any, ClassVar, Protocol, TypeVar, runtime_checkable
3231

32+
from .grpc_transport import TransportOptionsType
33+
3334
__all__ = [
3435
"DataclassProtocol",
3536
"FALLBACK_LAUNCH_MODE_NAME",
@@ -109,7 +110,7 @@ class LauncherProtocol(Protocol[LAUNCHER_CONFIG_T]):
109110
must be an instance of ``CONFIG_MODEL``.
110111
"""
111112

112-
CONFIG_MODEL: ClassVar[type[LAUNCHER_CONFIG_T]]
113+
CONFIG_MODEL: type[LAUNCHER_CONFIG_T]
113114
"""Defines the configuration options for the launcher.
114115
115116
The configuration options that this launcher accepts, specified
@@ -118,7 +119,7 @@ class LauncherProtocol(Protocol[LAUNCHER_CONFIG_T]):
118119
used in the configuration CLI, if available.
119120
"""
120121

121-
SERVER_SPEC: ClassVar[dict[str, ServerType]] = MappingProxyType({})
122+
SERVER_SPEC: dict[str, ServerType]
122123
"""Defines the server types that are started.
123124
124125
Examples
@@ -129,12 +130,7 @@ class LauncherProtocol(Protocol[LAUNCHER_CONFIG_T]):
129130
130131
.. code:: python
131132
132-
SERVER_SPEC = MappingProxyType(
133-
{
134-
"MAIN": ServerType.GENERIC,
135-
"FILE_TRANSFER": ServerType.GRPC,
136-
}
137-
)
133+
SERVER_SPEC = {"MAIN": ServerType.GENERIC, "FILE_TRANSFER": ServerType.GRPC}
138134
139135
The :attr:`.ProductInstance.urls` attribute then has keys
140136
``{"MAIN", "FILE_TRANSFER"}``, whereas the
@@ -191,3 +187,20 @@ def urls(self) -> dict[str, str]:
191187
>>> launcher.urls
192188
{"MAIN": "http://127.0.0.1:8080", "FILE_TRANSFER": "grpc://127.0.0.1:50051"}
193189
"""
190+
if any(val == ServerType.GENERIC for val in self.SERVER_SPEC.values()):
191+
raise NotImplementedError("LauncherProtocol.urls must be implemented if any generic servers are started.")
192+
return {}
193+
194+
@property
195+
def transport_options(self) -> dict[str, TransportOptionsType]:
196+
"""Dictionary of transport options for the gRPC servers started.
197+
198+
The keys of the returned dictionary must correspond to the keys
199+
defined in the :attr:`.LauncherProtocol.SERVER_SPEC` attribute
200+
which have the value :attr:`ServerType.GRPC`.
201+
"""
202+
if any(val == ServerType.GRPC for val in self.SERVER_SPEC.values()):
203+
raise NotImplementedError(
204+
"LauncherProtocol.transport_options must be implemented if any gRPC servers are started."
205+
)
206+
return {}

0 commit comments

Comments
 (0)