@@ -1115,14 +1115,31 @@ def __init__(self, app_handle: "AppHandle") -> None:
11151115
11161116def parse_app_handle (app_handle : AppHandle ) -> ParsedAppHandle :
11171117 """
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+
11191136 """
11201137
11211138 # parse it manually b/c currently torchx does not
11221139 # define allowed characters nor length for session name and app_id
11231140 import re
11241141
1125- pattern = r"(?P<scheduler_backend>.+)://(?P<session_name>.+ )/(?P<app_id>.+)"
1142+ pattern = r"(?P<scheduler_backend>.+)://(?P<session_name>.* )/(?P<app_id>.+)"
11261143 match = re .match (pattern , app_handle )
11271144 if not match :
11281145 raise MalformedAppHandleException (app_handle )
0 commit comments