Anyway to avoid a specific target from being cache...
# general
g
Anyway to avoid a specific target from being cached? đŸ§”
Copy code
pex_binary(
    name="nltk",
    entry_point="nltk.downloader",
    dependencies=[":poetry#nltk"],
)

adhoc_tool(
    name="generate_nltk_data",
    runnable=":nltk",
    args=[
        "-d",
        "nltk_data",
        "punkt",
    ],
    output_directories=["nltk_data/"],
)
This downloads data from the internet and I want it to be fresh with each build. How can I avoid it being cached?
b
I don’t think that’s supported well in build files; there might be feature requests for it. A custom plugin might be what’s required unless you can tolerate a hack like: set an environment variable to
$(date)
and refer to that env variable in some way in the target (one way to set it would be via `.pants.bootstrap`; https://www.pantsbuild.org/2.20/docs/using-pants/key-concepts/options#pantsbootstrap-file)
g
bummer. Is there a way to wire in a fake dependency based on something like $(date)?
oh, I totally could just use another adhoc_tool that writes date to a file and add that as a dep.
b
That one will be cached too 🙃
g
ohhhh hah
riiight.
b
I think something like
extra_env_vars=[”HACK_INVALIDATE_OFTEN”]
with that env var set via the bootstrap file above might work
g
I'll give that a shot. Thanks
c
oh nice, env var for a date like-string would be good for: https://github.com/pantsbuild/pants/discussions/20368
👍 1