https://pantsbuild.org/ logo
p

plain-carpet-73994

05/17/2021, 12:33 AM
I'm hoping to find a simple way to download a file from the internet and cache it for future runs. Specifically this file is an executable that runs a DB emulator used in some tests. I know I can create an
ExternalTool
and then a custom rule that uses that tool but that seems like a fair amount of work. What I was hoping for is a
target
type like
download_file
that is similar to
ExternalTool
but I can then just use that as a dependency in tests that require the tool. That seems much easier as I'd pretty much just have to specify a URL and be done while
ExternalTool
requires creating a class and a custom rule and then tests that require it can't do a simple
pants test some/thing/needing/emulator/::
because the custom rule wouldn't be
test
- so I think I'd need to create a new target type too and then connect the rule to the target, etc.
Something like https://www.pantsbuild.org/docs/plugins-codegen would also work (I'm "generating" an executable file by downloading it) but again seems like a long way to go. I think what I want is something like
files
that takes a URL, downloads it and caches it.
h

hundreds-father-404

05/17/2021, 1:27 AM
We are also adding in the next 2-3 days a new plugin hook for doing set up before Pytest runs, which you'll be able to hook into so that you can set up the emulator before
e

enough-analyst-54434

05/17/2021, 1:33 AM
IIUC @plain-carpet-73994 explicitly does not want to have to write a rule for this. He wants to just be able to configure it like a files dependency, except remote.
1
👍 1
h

hundreds-father-404

05/17/2021, 1:35 AM
You're right. I read too quickly, sorry. We could implement that via codegen. Not too difficult. The tricky part imo is the nuance of files vs resources and how that should be handled
h

happy-kitchen-89482

05/17/2021, 2:32 PM
Why does this have anything to do with codegen? There is no source file in play afaict
h

hundreds-father-404

05/17/2021, 3:43 PM
We're converting a URL to a source file. Codegen is how you do that currently Somewhat similar to using codegen for relocated_files
2 Views