Skip to content

Commit

Permalink
add unit test for PR #921
Browse files Browse the repository at this point in the history
Differential Revision: D58713685

Pull Request resolved: #923
  • Loading branch information
jason-b-akers committed Jun 18, 2024
1 parent 5058b6b commit 7bfa26d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions torchx/schedulers/test/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
AppDryRunInfo,
CfgVal,
InvalidRunConfigException,
macros,
NULL_RESOURCE,
Resource,
Role,
Expand Down Expand Up @@ -114,6 +115,28 @@ def test_submit_workspace(self) -> None:
scheduler_mock.submit(app, cfg, workspace="some_workspace")
self.assertEqual(app.roles[0].image, "some_workspace")

def test_metadata_macro_substitute(self) -> None:
role = Role(
name="sleep",
image="",
entrypoint="foo.sh",
metadata={
"bridge": {
"tier": "${app_id}",
},
"packages": ["foo", "package_${app_id}"],
},
)
values = macros.Values(
img_root="",
app_id="test_app",
replica_id=str(1),
rank0_env="TORCHX_RANK0_HOST",
)
replica_role = values.apply(role)
self.assertEqual(replica_role.metadata["bridge"]["tier"], "test_app")
self.assertEqual(replica_role.metadata["packages"], ["foo", "package_test_app"])

def test_invalid_dryrun_cfg(self) -> None:
scheduler_mock = SchedulerTest.MockScheduler("test_session")
app_mock = MagicMock()
Expand Down

0 comments on commit 7bfa26d

Please sign in to comment.