so, um, perhaps a silly question... I setup some ...
# general
f
so, um, perhaps a silly question... I setup some shell directories with
shell_command
targets. How do I actually invoke them?
pants run
apparently only works with
run_shell_command
but I wanted to use the outputs in downstream
shell_command
targets.
do I just setup a
run_shell_command
of something trivial and set the `shell_command`s as dependencies?
The docs cover how to do shell linting and formatting, but not actually execute the scripts.
w
I made this example repo a while back while testing something super specific. Maybe it can help? https://github.com/sureshjoshi/pants-shell-command-example
f
ok, yeah. so make it a dependency of something that does work with
pants run
. I'll give that a try.
w
👍
At least, that's an attempt just to make sure it does what you think it should do. Then, can work on stripping out the cruft. I rarely work with
shell_command
and
run_shell_command
but there are proper usages that I just need to re-familiarize myself with. I almost exclusively use
adhoc_tool
when doing anything non trivial
f
I'm working on some scalability testing... a coworker cooked up a stress test with a bunch of bazel genrules and so I'm trying to port it to pants.
and
shell_command
seems like the most direct mapping
w
ahh, gotcha.
In that case, you might want a better approach than what I suggested - which included wrapping stuff into a pex
https://www.pantsbuild.org/prerelease/docs/ad-hoc-tools/integrating-new-tools-without-plugins Probably better for your use case. github.com/pantsbuild/example-adhoc I think our docs around shell/adhoc need to be beefed up too - I'm always digging through my codebase to remember how they work
f
Yeah, I'm reading
shell_command.py
right now. 🙂
w
I actually don't have history on why there isn't a
pants run shell_source_target
f
experimental_wrap_as_
also seems really useful for the other stuff I've been working on.
The docs would be way more useful if the
monospace
formatted words were all links. It talks about setting up as
system_binary
target, but I don't know where it documents the fields in said target.
w
Yeah, I noticed that while doing a doc review recently. I thought they were, at some point, links
f
Are the stress tests better invoked as tests via the
test
goal?
If so, then you may want to look at
test_shell_command
.
f
Probably not. It's just a "how long does it take to deal with a 12k node graph"
so I've got my
run_shell_command()
and named it
go
with an
execution_dependencies
referencing my
adhoc_tool
. When I invoke
pants -ldebug run :go
I can see that it does happily run the
adhoc_tool
. Yay. But the output file from the
adhoc_tool
isn't showing up in the sandbox for the
run_shell_command
. Boo.
f
For context, what are you building?
f
just trying to run
md5sum
on the source files and the outputs generated by previous dependency steps
f
run_shell_command
runs interactively and not in a sandbox. Was the code trying to find the output in
{chroot}/foo
(for a file named
foo)
or in the current directory?
f
cwd. I don't know how to find the chroot of the previous invocation (which I guess is the root of the problem?). I'm only using
run_shell_command
because I can easily invoke it with
pants run
. Is there a better want to invoke an
adhoc_tool
?
f
Here's an example of using the
{chroot}
replacement to get access to dependencies in `run_shell_command`: https://github.com/shoalsoft/pants-go-workspace-example/blob/636cb17718ae0818619971a628b98e4b663ceb43/pants-macros/golang.py#L36
f
ooo... thanks! I'll be looking at that right after lunch. 🙂
f
Also, if you are just debugging
adhoc_tool
and
shell_command
targets, then the
export-codegen
goal might be useful.
> just trying to run
md5sum
on the source files and the outputs generated by previous dependency steps The
:go
target name made me think for a moment you might be trying to build Go code (in which case I had some examples).
(versus just being an action-oriented name)
f
ah ha! now it's working! Is
{chroot}
documented anywhere?