https://pantsbuild.org/ logo
g

green-match-66337

05/23/2022, 10:33 PM
Is there a way to hook in to a build target and run some functionality before/afterwards?
w

witty-crayon-22786

05/23/2022, 11:09 PM
before is possible by adding a dependency on an
experimental_shell_command
: https://www.pantsbuild.org/docs/run-shell-commands … but note that the process will run in a sandbox.
after… currently isn’t possible.
g

green-match-66337

05/23/2022, 11:16 PM
hmmm, trying to restructure after lambda target build as PEX seems to add 400ms cold start based on the structure
w

witty-crayon-22786

05/23/2022, 11:18 PM
ah… sorry. i assumed a particular usecase (testing). you can definitely use an
experimental_shell_command
to consume a
pex_binary
and manipulate it.
so something like:
Copy code
pex_binary(name='a', ..)
experimental_shell_command(name='b', dependencies=['a'], ..)
archive(name='c', dependencies=['b'], ..)
…would allow you to create an archive after manipulating a PEX. but feeding a PEX through a script like this loses type information: it’s no longer a PEX from Pants’ perspective
i’m not familiar with whether lambda keeps environments around, but: in the
venv
execution_mode, latency should be within 50 ms of an existing venv after the first run
This is what I'm thinking of following
Seems the package size in lambda doesnt matter as much as how accessible the packages are
w

witty-crayon-22786

05/23/2022, 11:26 PM
experimental_shell_command
should be roughly equivalent to
genrule
👍 1
but if there is an alternative layout of a PEX that ends up being significantly faster, reporting an issue on https://github.com/pantsbuild/lambdex/ would be appreciated. i’m not aware of why the alternate layout would be faster (the blog post mentions a different, please-specific reason for doing this)
g

green-match-66337

05/23/2022, 11:39 PM
Hard to tell but from what I have seen AWS use some underlying caching mechanism which is why the docker image size doesnt increase cold starts too much for a docker image lambda function. I imagine its the same for Python, so the size matters less and they likely optimize for SAM
h

happy-kitchen-89482

05/24/2022, 5:39 AM
Is that 400ms when compared to a hand-constructed lambda .zip containing all the same requirements etc?
g

green-match-66337

05/24/2022, 5:39 AM
Correct (hand constructed being SAM)
h

happy-kitchen-89482

05/24/2022, 1:32 PM
Hmm probably we should change our implementation to construct lambdas the same way SAM does (using their CLI even) rather than with lambdex
👍 1
2 Views