Add zip files for three data packages #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I haven't done this before so this is me figuring things out.
The goal is to do something similar to what happens in
inm-icf-utilities, where uncurl special remote handles the urls for the raw archived files, and then have the "archivist" special remote handle the connection between the archive file and its extracted files. I don't understand what I just wrote on a technical level (yet), but conceptually it makes sense.Looking at the example of https://github.com/psychoinformatics-de/inm-icf-utilities/blob/main/bin/deposit_visit_dataset, here are some comments that seem relevant:
Archive download URLs:
I started by running the following locally:
Next step is to use
datalad addurlsto add the archive URLs, but this needs some exploring first...Add zip files for three data packages via uncurlto Add zip files for three data packagesSome quick notes from office hour:
The following works:
This new file is registered with uncurl, as can be seen from:
Looking at the zip-file content:
Some info:
inm-icf-utilities: https://github.com/psychoinformatics-de/inm-icf-utilities/blob/main/bin/deposit_visit_dataset#L147-L158datalad addurlsdocs: https://docs.datalad.org/en/stable/generated/man/datalad-addurls.htmlNext steps:
git annex addurlfor all source archives, with --file flag to save to particular filenameaddurlwithdl+archive:<archive-key>#path=<path-in-archive>&size=<size-in-bytes>&atype=<archive-type>We discussed this in the office hour today. This is a summary.
download zip files recording URLs
Yes, the next step is to use
datalad addurlsto download the zip files and associate them with URLs. The addurls command is good for downloading things in batches. In its most basic form, it would need a simple csv file with URLs and file names -- see examples in its manpage. Alternatively,git annex addurl ----file=name urlcan be used to download the zip files one by one.Because the uncurl special remote is enabled, it will claim the http(s) URLs. One major feature of uncurl is its reconfiguration mechanism, where we can define matching patterns and substitutions as configuration options (this may become useful in the hypothetical situation when content moves and base URL or path changes). We do not need to define these configurations upfront. Had uncurl not been enabled, the URLs would have been claimed by git-annex's built in web remote.
record availability of files in archives
The second step is to enable another special remote, archivist, and use it to register file availability in the archives. Again, this is done by associating URLs with files using the
datalad urlsswiss army knife of the command. The format of the archivist URL is:dl+archive:<archive-key>#path=<path-in-archive>&size=<size-in-bytes>where the archive-key is the git-annex key of the zip file (i.e. the zip file is identified by its annex key, not by its path in the worktree).I know of two public places where examples can be found: here in inm-icf utils and here in trr remix of these utils. See the documentation for addurls options - it really helps.
The best way to get the required properties for addurls is probably
datalad ls-file-collection, which can iterate over zipfiles and provide both paths and sizes. JSON output format and some jq magic on the command line, or some Python scripting will be needed. Note that (due to different starting points) the INM-ICF version creates the annex keys for the files, while the trr remix attaches URLs to already extracted and saved files -- addurls is flexible in that regard.As a side note, the online documentation for the archivist special remote is missing (see datalad-next issue 774); the documentation can be found in source code of
datalad_next.annexremotes.archivist.ArchivistRemoteand (for URL patterns specifically)datalad_next.types.archivist.ArchivistLocator.I cloned the dataset and the archivist + uncurl setup looks to be done as intended, with two caveats (copying from the group chat):
For archivist, Datalad-next already has the tools to do handle zip files, but it doesn't want to use them -- https://github.com/datalad/datalad-next/pull/776
For uncurl, the zip files generated by edirepository are not reproducible due to the manifest containing the date:
Re-downloading the archive twice, unzipping, and diffing the directories:
I don't know what would be the recommended approach. The URLs are certainly valuable. One thing to consider: git annex addurl can be done with
--fastor--relaxed, but I think git-annex might try to migrate to a checksum-based backend (plus - storing a copy in forgejo implies a checksum) so this likely isn't a solution (although - it would be theoretically sufficient to reproducibly get the files other than the manifest).