From cb98d3df379ca967a53c8df50ddbeab2d0f49261 Mon Sep 17 00:00:00 2001 From: Burak Turk Date: Fri, 9 May 2025 11:42:32 -0700 Subject: [PATCH] introduce internal torchx macros with n img_root support (#1060) Summary: Pull Request resolved: https://github.com/pytorch/torchx/pull/1060 Reviewed By: kiukchung Differential Revision: D74093902 --- torchx/specs/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/torchx/specs/api.py b/torchx/specs/api.py index 958f51943..a83104991 100644 --- a/torchx/specs/api.py +++ b/torchx/specs/api.py @@ -224,11 +224,15 @@ def _apply_nested(self, d: typing.Dict[str, Any]) -> typing.Dict[str, Any]: v[i] = self.substitute(v[i]) return d + # Overrides the asdict method to generate a dictionary of macro values to be substituted. + def to_dict(self) -> Dict[str, Any]: + return asdict(self) + def substitute(self, arg: str) -> str: """ substitute applies the values to the template arg. """ - return Template(arg).safe_substitute(**asdict(self)) + return Template(arg).safe_substitute(**self.to_dict()) class RetryPolicy(str, Enum):