Skip to content
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

Convert arg to str for template substitution #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 src/nemo_run/core/execution/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def substitute(self, arg: str) -> str:
"""
substitute applies the values to the template arg.
"""
return Template(arg).safe_substitute(**asdict(self))
return Template(str(arg)).safe_substitute(**asdict(self))


@runtime_checkable
Expand Down
5 changes: 4 additions & 1 deletion test/core/execution/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import fiddle as fdl
import pytest
from torchx.specs import Role

from nemo_run.config import Config
from nemo_run.core.execution.base import (
Executor,
Expand All @@ -25,7 +27,6 @@
Torchrun,
)
from nemo_run.core.execution.slurm import SlurmExecutor
from torchx.specs import Role


class TestExecutorMacros:
Expand Down Expand Up @@ -59,6 +60,8 @@ def test_substitute(self):
assert macros.substitute("${head_node_ip_var}") == "192.168.0.1"
assert macros.substitute("${nproc_per_node_var}") == "4"

assert macros.substitute(1) == "1"

def test_group_host(self):
macros = SlurmExecutor(account="a").macro_values()
assert macros
Expand Down
Loading