fast-nail-55400
12/01/2020, 3:55 AMDigest
? I see AddPrefix
and RemovePrefix
for adding and removing directory prefixes but nothing to change the filename of a file in a Digest
.fast-nail-55400
12/01/2020, 3:57 AMProcess
execution use a constant filename which is then changed to the user’s requested output filename (as part of a package
goal run).fast-nail-55400
12/01/2020, 3:58 AMDigest
directly but that seems to require loading the file into memory in order to use FileContent
. Is there any way to just reference the file’s fingerprint/size?hundreds-father-404
12/01/2020, 4:00 AMDigestContents
, then use CreateDigest
. That will be much slower than we wantfast-nail-55400
12/01/2020, 4:01 AMProcess
but that is not hermeticfast-nail-55400
12/01/2020, 4:02 AMFileContent
to take a union of bytes
or a digest would solve the issuefast-nail-55400
12/01/2020, 4:02 AMbytes
leaves indirect referenceshundreds-father-404
12/01/2020, 4:03 AMor a digest would solve the issueI think that would need to be a
FileDigest
, not directory digest. You can’t guarantee a directory digest has only one file
Note that FileDigest
is almost never used in Python land, only for DownloadURL
hundreds-father-404
12/01/2020, 4:04 AMrelocated_files
, but I don’t this will work because it only changes the path prefix and you want to change the file name. https://www.pantsbuild.org/docs/resources#relocated_files
pathlib.Path
might have some inspiration - challenge is finding how to represent it for an arbitrary set of filesfast-nail-55400
12/01/2020, 4:08 AMFileContent
fast-nail-55400
12/01/2020, 4:10 AMYou can’t guarantee a directory digest has only one fileI can if it is the result of a
Process
run and only one file was to be captured. (Ignoring the case of no file captured, but my plugin’s code should check for that case any way.)fast-nail-55400
12/01/2020, 4:11 AMhundreds-father-404
12/01/2020, 4:11 AMYou can’t guarantee a directory digest has only one file
well a generic “rename” intrinsic may be unnecessary for my use case if I can just reference a file’s digest in FileContentWhich would require a new intrinsic like
Get(FileDigests, Digest)
(note the plural)
Then, await Get(Digest, CreateDigest([FileContent(new_path, digest) for digest in file_digests]))
fast-nail-55400
12/01/2020, 4:12 AMFileDigests
would provide tuples of (filename, digest) in a fieldhundreds-father-404
12/01/2020, 4:12 AMfast-nail-55400
12/01/2020, 4:12 AMhundreds-father-404
12/01/2020, 4:12 AMCollection[FileDigest]
, but yeah, then you have the problem of not knowing the file namefast-nail-55400
12/01/2020, 4:13 AMdict
at all vs Collection[Type]?hundreds-father-404
12/01/2020, 4:13 AMTuple[Tuple[k, v], …]
fast-nail-55400
12/01/2020, 4:14 AMSnapshot
with a file_digests
field?fast-nail-55400
12/01/2020, 4:14 AMhundreds-father-404
12/01/2020, 4:14 AMfast-nail-55400
12/01/2020, 4:15 AMhundreds-father-404
12/01/2020, 4:16 AMor dict[str, digest]This sounds reasonable to me for
await Get(FileDigests, Digest)
.
I do have a slight hesitation to elevate the concept of FileDigest
, as right now plugin authors have no idea it exists unless they use DownloadURL
. Now we have One More Concept
But it may prove worth it, and still you could probably ignore it in most caseshundreds-father-404
12/01/2020, 4:17 AMFileDigest
is helpful in the first place. Atm, it sounds like only to be an input to FileContent
in a CreateDigest
requestfast-nail-55400
12/01/2020, 4:32 AMDigest
returned from packaging rules so that the output filename does not need to be given to the Process
that generates an artifactfast-nail-55400
12/01/2020, 4:32 AMfast-nail-55400
12/01/2020, 4:33 AMfast-nail-55400
12/01/2020, 4:33 AMCreateDigest