broad-processor-92400
10/21/2022, 1:23 AMexperimental_shell_command
capturing the schema as a file
2. Run the doc generator on the schema to create a .html file: install (via NPM) the doc generator and run it on the output of above, all via experimental_shell_command
3. Package the .html file into an archive: relocated_files
+ archive
This mostly works, except I'm finding step 1 is... weird. The targets I'm using are, something like:
# path/to/dir/BUILD
pex_binary(name="print-schema", ...)
experimental_shell_command(
name="schema",
command="../../../path.to.dir/print-schema.pex > schema.graphql",
dependencies=[":print-schema"],
tools=["python3.9", "bash"],
outputs=["schema.graphql"],
)
Questions:
1. Is it possible to have experiemental_shell_command
run an in-repo Python file directly, pulling in appropriate internal and external dependencies? It'd be nifty to not need to set up the PEX file if we didn't need to
2. Is tools=["python3.9", ...]
the right way to pull in Python to run the PEX? I have a feeling that it'll just be just pulling in whatever python3.9
executable happens to be on PATH (if there is one), rather than the interpreter Pants has gone to great efforts to choose for 'normal' `run`/`test` etc. of Python targets?
3. Is there a better way to refer to the root of the repo/find the dependency pulled into the experiemental_shell_command
, beyond just ..
the right number of times?happy-kitchen-89482
10/21/2022, 3:57 PMexperimental_shell_command
so this is a helpful use-casehappy-kitchen-89482
10/21/2022, 3:58 PMhappy-kitchen-89482
10/21/2022, 3:58 PMbroad-processor-92400
10/21/2022, 8:00 PMpython script/print-schema.py > schema.graphql # step 1
npx spectaql config.yaml # step 2
zip … # step 3
A (codegen?) plug-in sounds like it might indeed handle step 1 smoothly, but I'm not sure I could sell my team (or even myself) on replacing a single one-off line of shell with dozens-to-hundreds of lines of Python. Based on https://www.pantsbuild.org/docs/plugins-overview, we might also be signing up for additional maintenance/upgrade burden due to lack of stability (which, to be clear, I totally support: stable and powerful APIs are nice as a consumer but a pain as a maintainer 😅 ).broad-processor-92400
10/26/2022, 2:05 AMexperimental_shell_command
can act as an ad-hoc codegen plugin.
I noticed https://github.com/pantsbuild/pants/issues/17345 too, and I think it makes this work less well too: changes to the PEX file in 1 that don't affect the schema end up rerunning step 2 anyway.happy-kitchen-89482
10/26/2022, 7:30 AMexperimental_shell_command
broad-processor-92400
10/31/2022, 6:24 AM{chroot}
is substituted (🎉)happy-kitchen-89482
10/31/2022, 4:48 PM