My plugin is going to need a path on the system to...
# plugins
h
My plugin is going to need a path on the system to gather some credentials. What's the proper way to go about this? Should I place it within the repo root and then do something like
Get(Digest, CreateDigest(...))
?
Seems more like
PathGlobs
was what I was looking for
h
Yeah, that's preferable for it to be in the build root so that Pants's file watcher can kick in
h
I only need to do this once (or whenever the file changes). I saw some interesting notes about caching related to
DigestContents
. Anything I should be aware of when using this?
Wondering if I should split that up into a separate rule so that it only runs again if the file digest changes. Probably not understanding caching, though.
h
saw some interesting notes about caching related to DigestContents
Hm you did? If you use
pants.engine.fs
, then you don't need to reason about caching - it does it for you
h
Yeah, this, specifically
Copy code
Although the contents of the Digest are not memoized across `@rules` or across runs (each
    request for `DigestContents` will load the file content from disk), this API should still
    generally only be used for small inputs, since concurrency might mean that very many `@rule`s
    are holding `DigestContents` simultaneously.
So if the
argv
for a process is determined from the
FileContent
of my
Digest
, would that process behavior still be cached?
h
yeah, caching still will work properly. The input to the
Process
will have changed, so the cache cannot be used
h
Okay, sounds good. So I think the way I'm understanding what I've read/you've explained is that the file contents will still be read into memory every time, but the resultant process won't get rerun unless the contents have actually changed.
That's the behavior I see at least, so that's pretty cool
h
yep, exactly 🙂
do you need
DigestContents
? It's often much faster and memory efficient to use
Digest
h
I have to grab the string token that's inside that file in order to make the actual cli call for my one time configuration step
👍 1
So that's why I was wondering if there would be a benefit to setting up another
@rule
that takes in a digest and spits out a process or something so that I only read in the contents if the digest has changed
h
Got it -- probably not. Pants will reuse the
Digest -> DigestContents
from before and only re-read when the file watcher says you need to
👏 1
h
Thankfully, it's a very small file (800 bytes) so I think I'm on the side of proper usage.