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):