Is there a way to hook in to a build target and ru...
# general
g
Is there a way to hook in to a build target and run some functionality before/afterwards?
w
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
hmmm, trying to restructure after lambda target build as PEX seems to add 400ms cold start based on the structure
w
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
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
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
Is that 400ms when compared to a hand-constructed lambda .zip containing all the same requirements etc?
g
Correct (hand constructed being SAM)
h
Hmm probably we should change our implementation to construct lambdas the same way SAM does (using their CLI even) rather than with lambdex
👍 1