Skip to content

Commit 7c67d59

Browse files
authored
Add application metadata to the describe API's return value
Differential Revision: D74438626 Pull Request resolved: #1066
1 parent d51a0de commit 7c67d59

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

torchx/runner/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def describe(self, app_handle: AppHandle) -> Optional[AppDef]:
597597
if not app:
598598
desc = scheduler.describe(app_id)
599599
if desc:
600-
app = AppDef(name=app_id, roles=desc.roles)
600+
app = AppDef(name=app_id, roles=desc.roles, metadata=desc.metadata)
601601
return app
602602

603603
def log_lines(

torchx/runner/test/api_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,15 @@ def build_workspace_and_update_role(
440440

441441
def test_describe(self, _) -> None:
442442
with self.get_runner() as runner:
443+
metadata = {"a": "b", "c": "d"}
443444
role = Role(
444445
name="sleep",
445446
image=str(self.tmpdir),
446447
resource=resource.SMALL,
447448
entrypoint="sleep",
448449
args=["60"],
449450
)
450-
app = AppDef("sleeper", roles=[role])
451+
app = AppDef("sleeper", roles=[role], metadata=metadata)
451452

452453
app_handle = runner.run(app, scheduler="local_dir", cfg=self.cfg)
453454
self.assertEqual(app, runner.describe(app_handle))

torchx/schedulers/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class DescribeAppResponse:
4343
the status and description of the application as known by the scheduler.
4444
For some schedulers implementations this response object has necessary
4545
and sufficient information to recreate an ``AppDef`` object. For these types
46-
of schedulers, the user can re-``run()`` the recreted application. Otherwise
46+
of schedulers, the user can re-``run()`` the recreated application. Otherwise
4747
the user can only call non-creating methods (e.g. ``wait()``, ``status()``,
4848
etc).
4949
@@ -61,6 +61,7 @@ class DescribeAppResponse:
6161
msg: str = NONE
6262
structured_error_msg: str = NONE
6363
ui_url: Optional[str] = None
64+
metadata: dict[str, str] = field(default_factory=dict)
6465

6566
roles_statuses: List[RoleStatus] = field(default_factory=list)
6667
roles: List[Role] = field(default_factory=list)

0 commit comments

Comments
 (0)