@@ -1115,14 +1115,31 @@ def __init__(self, app_handle: "AppHandle") -> None:
1115
1115
1116
1116
def parse_app_handle (app_handle : AppHandle ) -> ParsedAppHandle :
1117
1117
"""
1118
- parses the app handle into ```(scheduler_backend, session_name, and app_id)```
1118
+ Parses the app handle into ```(scheduler_backend, session_name, and app_id)```.
1119
+
1120
+ Example:
1121
+
1122
+ .. doctest::
1123
+
1124
+ assert parse_app_handle("k8s://default/foo_bar") == ("k8s", "default", "foo_bar")
1125
+ assert parse_app_handle("k8s:///foo_bar") == ("k8s", "", "foo_bar")
1126
+
1127
+ Args:
1128
+ app_handle: a URI of the form ``{scheduler}://{session_name}/{app_id}``,
1129
+ where the ``session_name`` is optional. In this case the app handle is
1130
+ of the form ``{scheduler}:///{app_id}`` (notice the triple slashes).
1131
+
1132
+ Returns: A ``Tuple`` of three elements, ``(scheduler, session_name, app_id)``
1133
+ parsed from the app_handle URI str. If the session name is not present then
1134
+ an empty string is returned in its place in the tuple.
1135
+
1119
1136
"""
1120
1137
1121
1138
# parse it manually b/c currently torchx does not
1122
1139
# define allowed characters nor length for session name and app_id
1123
1140
import re
1124
1141
1125
- pattern = r"(?P<scheduler_backend>.+)://(?P<session_name>.+ )/(?P<app_id>.+)"
1142
+ pattern = r"(?P<scheduler_backend>.+)://(?P<session_name>.* )/(?P<app_id>.+)"
1126
1143
match = re .match (pattern , app_handle )
1127
1144
if not match :
1128
1145
raise MalformedAppHandleException (app_handle )
0 commit comments