https://pantsbuild.org/ logo
#general
Title
# general
f

fresh-cat-90827

02/04/2022, 11:15 PM
usability question. I am curious how much information about PEX that Pants run would be available to get from the system
ps
call.
When running a Python script from the sources directly like this:
Copy code
$ ./pants run project/bar.py -- --input="baz"
This is what one can see in local
ps ww
on a MacOS device:
Copy code
44762 s010  S+     0:00.51 /usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/Resources/Python.app/Contents/MacOS/Python /Users/user-name/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.1_py39/bin/pants --pants-bin-name=./pants --pants-version=2.7.1 run project/bar.py -- --input=baz
However, once a PEX file is produced via the
package
command and then run:
Copy code
$ python3 dist/project/bar.pex --input="baz"
you don’t see much any longer on `ps ww`:
Copy code
46131 s010  S+     0:00.78 /usr/bin/python3 /Users/user-name/.pex/unzipped_pexes/e9eb91dcb789973ca601f8bfb4401555f188d841 --input=baz
One can inspect the
/Users/user-name/.pex/unzipped_pexes/e9eb91dcb789973ca601f8bfb4401555f188d841/PEX-INFO
file’s
entry_point
property to see what module is being run, but this is not visible from the
ps
output. The use case is that at a given point of time there may be multiple PEX files running, and it would be handy to see which ones are running from the
ps
output (or somehow else). Any ideas?
h

happy-kitchen-89482

02/04/2022, 11:45 PM
In that first example I can only see the
pants
process itself, not your running binary's process, is that intentional?
f

fresh-cat-90827

02/06/2022, 10:18 PM
sorry if I misunderstand, but the
ps
only gives me only one process that Pants started; there are no other processes related to the Pants
run
command execution
h

happy-kitchen-89482

02/07/2022, 1:28 AM
So in your first example, I see the
./pants
process itself, but I don't see the process that was invoked by
./pants run
So you're comparing two very different things
f

fresh-cat-90827

02/07/2022, 7:33 AM
oh I am sorry for being confusing! You are absolutely right, calling
./pants run
and running a
.pex
file with Python are two very different things. I mentioned both to illustrate how helpful
./pants run
process metadata is and how little is known about running
.pex
file. I was just wondering whether when running
$ python3 dist/project/bar.pex --input="baz"
the pex is capable of leaking some metadata about itself into the process details. Perhaps @enough-analyst-54434 would know given it’s PEX related?
h

happy-kitchen-89482

02/07/2022, 4:04 PM
My bad, I think I'm not understanding the question 🙂 In your first case, there are two processes - pants itself, and the process it runs for you. When I run an example, I see both:
Copy code
501 52424  1023   0  8:00AM ttys000    0:00.53 /Users/benjyw/.cache/pants/setup/bootstrap-Darwin-x86_64/2.10.0.dev3_py38/bin/python /Users/benjyw/.cache/pants/setup/bootstrap-Darwin-x86_64/2.10.0.dev3_py38/bin/pants --pants-bin-name=./pants --pants-version=2.10.0.dev3 run project/bar.py -- --input=baz
  501 52458 16356   0  8:00AM ??         0:00.43 /Users/benjyw/.pyenv/versions/3.8.12/bin/python3.8 /Users/benjyw/.cache/pants/named_caches/pex_root/unzipped_pexes/2312ebcec214434cf2349791389503f03e1033a7 --input=baz
and the second one looks very much like the standalone case when you package and then run the packaged binary outside Pants.
The output of
ps
is basically the command line that the process was run with
So I don't think there's a way to augment that with metadata
Except that we could maybe give the unzipped pex a less obscure name
so instead of
unzipped_pexes/2312ebcec214434cf2349791389503f03e1033a7
we could possibly unpack it to
unzipped_pexes/2312ebcec214434cf2349791389503f03e1033a7/bar.pex
Would that help?
f

fresh-cat-90827

02/07/2022, 5:08 PM
Yes, this makes perfect sense. Unpacking into a human readable directory would be splendid. We have a few long running tasks and it would be handy to see if any of them are running by doing ps and grep. Low priority work of course!
4 Views