Skip to content

Commit a6cef12

Browse files
authored
Handle args for customized entrypoint
Differential Revision: D69964149 Pull Request resolved: #1011
1 parent 48c2a85 commit a6cef12

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

torchx/components/utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,26 @@ def sh(
104104
entrypoint: the entrypoint to use for the command (defaults to sh)
105105
"""
106106

107-
escaped_args = " ".join(shlex.quote(arg) for arg in args)
107+
escaped_args = [shlex.quote(arg) for arg in args]
108108
if env is None:
109109
env = {}
110110
env.setdefault("LOGLEVEL", os.getenv("LOGLEVEL", "WARNING"))
111111

112+
if entrypoint is not None:
113+
resolved_entrypoint = entrypoint
114+
resolved_args = escaped_args
115+
else:
116+
resolved_entrypoint = "sh"
117+
resolved_args = ["-c", " ".join(escaped_args)]
118+
112119
return specs.AppDef(
113120
name="sh",
114121
roles=[
115122
specs.Role(
116123
name="sh",
117124
image=image,
118-
entrypoint=entrypoint or "sh",
119-
args=["-c", escaped_args],
125+
entrypoint=resolved_entrypoint,
126+
args=resolved_args,
120127
num_replicas=num_replicas,
121128
resource=specs.resource(cpu=cpu, gpu=gpu, memMB=memMB, h=h),
122129
env=env,

0 commit comments

Comments
 (0)