docs: teach Hugging Face Write token setup for Community PRs
Browse files
README.md
CHANGED
|
@@ -38,6 +38,35 @@ Notebook: [Example Data](https://github.com/electronmicroscopy/quantem.widget/bl
|
|
| 38 |
Anyone with a Hugging Face account can add data. We follow a pull request
|
| 39 |
process. Do not use `quantem.widget.io.upload`.
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
A PR is the data file(s) plus one `meta.json`. Example already on the hub
|
| 42 |
(2 files):
|
| 43 |
|
|
@@ -93,13 +122,12 @@ Processed float data uses `"float32"`. Read both values from the file
|
|
| 93 |
```
|
| 94 |
|
| 95 |
`source` is microscope, facility, and original file. `date` is acquisition
|
| 96 |
-
day (`YYYY-MM-DD`). `permission.received` must be `true`. `from` is who granted the
|
| 97 |
-
instrument (one name or several). `permission.date` is when that
|
| 98 |
-
granted.
|
| 99 |
|
| 100 |
```bash
|
| 101 |
python templates/check_meta.py ./gold-512-bin4
|
| 102 |
-
hf auth login
|
| 103 |
hf upload bobleesj/quantem-data ./gold-512-bin4 \
|
| 104 |
widget-tutorials/show4dstem/gold-512-bin4/full \
|
| 105 |
--repo-type dataset --create-pr
|
|
|
|
| 38 |
Anyone with a Hugging Face account can add data. We follow a pull request
|
| 39 |
process. Do not use `quantem.widget.io.upload`.
|
| 40 |
|
| 41 |
+
Downloads need no token. Opening a pull request does. Create an account,
|
| 42 |
+
then a token at
|
| 43 |
+
[huggingface.co/settings/tokens](https://huggingface.co/settings/tokens).
|
| 44 |
+
Use a **Write** token (classic). A **Read** token can download; it cannot
|
| 45 |
+
open a PR. A fine-grained token also works if `--create-pr` is allowed on
|
| 46 |
+
a public dataset. You do not need collaborator access to this repo.
|
| 47 |
+
|
| 48 |
+
```bash
|
| 49 |
+
pip install huggingface_hub # skip if `hf` is already on PATH
|
| 50 |
+
hf auth login
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
Paste the token. The prompt hides it. When asked `Add token as git
|
| 54 |
+
credential? [y/N]`, answer `n`. `hf upload` reads
|
| 55 |
+
`~/.cache/huggingface/token`. You do not need a git credential helper.
|
| 56 |
+
Ignore any hint to run `git config --global credential.helper store`.
|
| 57 |
+
|
| 58 |
+
```bash
|
| 59 |
+
hf auth whoami
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
That should print your username. If you already logged in with a Read
|
| 63 |
+
token, run `hf auth login --force` and paste a Write token. If
|
| 64 |
+
`--create-pr` returns 403 after a valid login, the token is Read or the
|
| 65 |
+
fine-grained scopes omit Community PRs; make a Write token and login
|
| 66 |
+
again. On SSH (no browser on that machine), paste a token. Do not use the
|
| 67 |
+
browser login unless the browser and `hf` run on the same machine. Do not
|
| 68 |
+
commit the token.
|
| 69 |
+
|
| 70 |
A PR is the data file(s) plus one `meta.json`. Example already on the hub
|
| 71 |
(2 files):
|
| 72 |
|
|
|
|
| 122 |
```
|
| 123 |
|
| 124 |
`source` is microscope, facility, and original file. `date` is acquisition
|
| 125 |
+
day (`YYYY-MM-DD`). `permission.received` must be `true`. `from` is who granted the share (one name or several). `collectors` is who
|
| 126 |
+
used the instrument (one name or several). `permission.date` is when that
|
| 127 |
+
share was granted.
|
| 128 |
|
| 129 |
```bash
|
| 130 |
python templates/check_meta.py ./gold-512-bin4
|
|
|
|
| 131 |
hf upload bobleesj/quantem-data ./gold-512-bin4 \
|
| 132 |
widget-tutorials/show4dstem/gold-512-bin4/full \
|
| 133 |
--repo-type dataset --create-pr
|