diff --git a/torchx/schedulers/test/api_test.py b/torchx/schedulers/test/api_test.py index 7f8ecf8a..26013e36 100644 --- a/torchx/schedulers/test/api_test.py +++ b/torchx/schedulers/test/api_test.py @@ -26,6 +26,7 @@ AppDryRunInfo, CfgVal, InvalidRunConfigException, + macros, NULL_RESOURCE, Resource, Role, @@ -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()