|
Download docs/retrieval.md from Battam/terminal-data-pointers: direct link, hf CLI and curl.
- Browser
- Download file 2.38 kB
-
https://huggingface.co/datasets/Battam/terminal-data-pointers/resolve/main/docs/retrieval.md
- Command line
-
hf download hf://datasets/Battam/terminal-data-pointers/docs/retrieval.md
-
curl -L -o retrieval.md https://huggingface.co/datasets/Battam/terminal-data-pointers/resolve/main/docs/retrieval.md
2.38 kB
Retrieving and verifying files
The catalog holds no file content. To use a file, download it from the address in its pointer and check it against the size and hashes the pointer gives. The fields are described in fields.md.
Steps
- Choose an address:
uri, or one fromalt_uris, which serve the same bytes.s3://addresses usually have a public https address inalt_uris.hf://datasets/<repo>@<revision>/<path>stands forhttps://huggingface.co/datasets/<repo>/resolve/<revision>/<path>. - If
access.needs_authsays that a login, a guestbook or a form is needed, follow the source's procedure first. - If the pointer has
range, request only those bytes with the HTTP headerRange: bytes=<offset>-<offset + length - 1>. The file is that byte range ofuri, for example one record inside a WARC file, andsize_bytesequalslength. - Compare the number of bytes with
size_bytes, unless it isnull(the source does not publish the size). - Compute the hashes named in
hashesand compare every value;hash_scopesays what they cover (below). Treat a mismatch as a failure; do not substitute another file. - If
hashesis empty (hash_sourceiscomputed_on_fetch), the source publishes no hash: compute your own after download and keep it with the file.
What the hashes cover (hash_scope)
file(the default when the field is absent): the bytes you downloaded, that is the whole file, or the byte range when the pointer hasrange.http_payload: the range is one gzip-compressed WARC record. Decompress it, remove the WARC and HTTP headers, undo chunked transfer encoding, and hash the HTTP response body.size_bytesstays the compressed length of the record.api_body:urireturns JSON from an API. Hash the UTF-8 bytes of the field named insource_meta.api_body_field(a dotted path in which numbers index lists;items.0.bodywhen absent), not the whole response.
Files inside archives
A pointer with parent_pointer_id and member_path is a file inside an archive that has its own pointer: retrieve and verify the archive, then extract member_path.
Source notes and the manifests themselves
Each collection.json adds notes for its source under fetch and notes. Its shards list gives the sha256 of every part file of the batch, so the downloaded manifests can be checked too.