Skip to content

Handle args for customized entrypoint #1011

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

Merged
merged 1 commit into from
Feb 21, 2025
Merged
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
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
Loading