Skip to content

Add application metadata to the describe API's return value #1066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion torchx/runner/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def describe(self, app_handle: AppHandle) -> Optional[AppDef]:
if not app:
desc = scheduler.describe(app_id)
if desc:
app = AppDef(name=app_id, roles=desc.roles)
app = AppDef(name=app_id, roles=desc.roles, metadata=desc.metadata)
return app

def log_lines(
Expand Down
3 changes: 2 additions & 1 deletion torchx/runner/test/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,15 @@ def build_workspace_and_update_role(

def test_describe(self, _) -> None:
with self.get_runner() as runner:
metadata = {"a": "b", "c": "d"}
role = Role(
name="sleep",
image=str(self.tmpdir),
resource=resource.SMALL,
entrypoint="sleep",
args=["60"],
)
app = AppDef("sleeper", roles=[role])
app = AppDef("sleeper", roles=[role], metadata=metadata)

app_handle = runner.run(app, scheduler="local_dir", cfg=self.cfg)
self.assertEqual(app, runner.describe(app_handle))
Expand Down
3 changes: 2 additions & 1 deletion torchx/schedulers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DescribeAppResponse:
the status and description of the application as known by the scheduler.
For some schedulers implementations this response object has necessary
and sufficient information to recreate an ``AppDef`` object. For these types
of schedulers, the user can re-``run()`` the recreted application. Otherwise
of schedulers, the user can re-``run()`` the recreated application. Otherwise
the user can only call non-creating methods (e.g. ``wait()``, ``status()``,
etc).

Expand All @@ -61,6 +61,7 @@ class DescribeAppResponse:
msg: str = NONE
structured_error_msg: str = NONE
ui_url: Optional[str] = None
metadata: dict[str, str] = field(default_factory=dict)

roles_statuses: List[RoleStatus] = field(default_factory=list)
roles: List[Role] = field(default_factory=list)
Expand Down
Loading