future-oxygen-10553
04/20/2023, 3:18 PMIterable[str]
, which from my experience with subprocess.run
means it should be ["arg1", "arg2"]
, but this results in an error from Pex that the args should be a single string. I presume this behavior is intentional, but then does the pex_binary.args
need to be an iterable? Could it just be a single string? If it needs to be an iterable for typing, I can try to update the docsenough-analyst-54434
04/20/2023, 4:20 PMjsirois@Gill-Windows:~ $ pex --inject-args Hello --inject-args Nay --inject-args "Moo, Moo" cowsay -c cowsay -o cowsay.pex
jsirois@Gill-Windows:~ $ ./cowsay.pex
__________________
| Hello Nay Moo, Moo |
==================
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
jsirois@Gill-Windows:~ $ pex-tools cowsay.pex info -i2 | jq .inject_args
[
"Hello",
"Nay",
"Moo,",
"Moo"
]
So you can both pass multiple --inject-args
and Pex shlex.split
s each arg you inject.
jsirois@Gill-Windows:~ $ pex --inject-args Hello --inject-args Nay --inject-args '"Moo, Moo"' cowsay -c cowsay -o cowsay.pex
jsirois@Gill-Windows:~ $ ./cowsay.pex
__________________
| Hello Nay Moo, Moo |
==================
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
jsirois@Gill-Windows:~ $ pex-tools cowsay.pex info -i2 | jq .inject_args
[
"Hello",
"Nay",
"Moo, Moo"
]
future-oxygen-10553
04/20/2023, 4:44 PM--inject-args
parts for the pex?enough-analyst-54434
04/20/2023, 4:46 PMfuture-oxygen-10553
04/20/2023, 4:47 PM--inject-args
for pex either, so TILcurved-television-6568
04/21/2023, 1:19 AM--inject-args
to pex: https://github.com/pantsbuild/pants/blob/1aca34961105f98c2dd63addd37f9e5cfc49ee9b/src/python/pants/backend/python/util_rules/pex.py#L586-L587curved-television-6568
04/21/2023, 1:20 AMbut this results in an error from Pex that the args should be a single string.are you able to show the error message and actual BUILD file target? (redacted if need be)
future-oxygen-10553
04/21/2023, 2:27 PMpex_binary(
name="inference-server",
layout="packed",
include_tools=True,
dependencies=["./ackbar/inference_server"],
platforms=["linux_x86_64-cp-310-cp310"],
script="uvicorn",
args=["<http://ackbar.inference_server.app:app|ackbar.inference_server.app:app>", "--host", "0.0.0.0", "--port", "8080"],
)
Error:
pants package src:inference-server
08:26:57.83 [INFO] Initializing scheduler...
08:26:59.05 [INFO] Scheduler initialized.
08:27:00.98 [INFO] Completed: Building 2 requirements for src/inference-server.pex from the 3rdparty/python-lock.txt resolve: fastapi<0.96.0,>=0.95.1, uvicorn[standard]>=0.21.1
08:27:00.99 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
ProcessExecutionFailure: Process 'Building 2 requirements for src/inference-server.pex from the 3rdparty/python-lock.txt resolve: fastapi<0.96.0,>=0.95.1, uvicorn[standard]>=0.21.1' failed with exit code 2.
stdout:
stderr:
usage: pex [-o OUTPUT.PEX] [options] [-- arg1 arg2 ...]
pex builds a PEX (Python Executable) file based on the given specifications: sources, requirements, their dependencies and other options.
Command-line options can be provided in one or more files by prefixing the filenames with an @ symbol. These files must contain one argument per line.
pex: error: argument --inject-args: expected one argument
Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
future-oxygen-10553
04/21/2023, 2:28 PMcurved-television-6568
04/21/2023, 2:37 PMstr(injected_arg)
ought to have been repr(injected_arg)
Try this as work-around:
args=["<http://ackbar.inference_server.app:app|ackbar.inference_server.app:app>", "'--host'", "0.0.0.0", "'--port'", "8080"],
i.e. quote the --
optionscurved-television-6568
04/21/2023, 2:39 PMpex --inject-args <http://ackbar.inference_server.app:app|ackbar.inference_server.app:app> --inject-args --host --inject-args 0.0.0.0 ...
and there it’s clear pex will see --host
as a pex arg, not the value for inject-args.future-oxygen-10553
04/21/2023, 2:44 PMcurved-television-6568
04/21/2023, 2:45 PMcurved-television-6568
04/21/2023, 2:51 PM