Skip to content

Commit

Permalink
Handle args for customized entrypoint
Browse files Browse the repository at this point in the history
Differential Revision: D69964149

Pull Request resolved: #1011
  • Loading branch information
hstonec authored Feb 21, 2025
1 parent 48c2a85 commit a6cef12
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions torchx/components/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,26 @@ def sh(
entrypoint: the entrypoint to use for the command (defaults to sh)
"""

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

if entrypoint is not None:
resolved_entrypoint = entrypoint
resolved_args = escaped_args
else:
resolved_entrypoint = "sh"
resolved_args = ["-c", " ".join(escaped_args)]

return specs.AppDef(
name="sh",
roles=[
specs.Role(
name="sh",
image=image,
entrypoint=entrypoint or "sh",
args=["-c", escaped_args],
entrypoint=resolved_entrypoint,
args=resolved_args,
num_replicas=num_replicas,
resource=specs.resource(cpu=cpu, gpu=gpu, memMB=memMB, h=h),
env=env,
Expand Down

0 comments on commit a6cef12

Please sign in to comment.