Skip to content

Commit ad0f961

Browse files
coyotte508julien-c
andauthored
Add cli for @huggingface/hub (#1412)
cc @Wauplin @hanouticelina for viz Internal context: https://huggingface.slack.com/archives/C0256NXF0A2/p1745930278721439?thread_ts=1741697907.530409&cid=C0256NXF0A2 Also add `createBranch` and `deleteBranch` functions Follow up to #1398 eg: ```console npm install -g @huggingface/hub export HF_TOKEN=... # Upload current dir to coyotte508/test-model in a new empty "build" branch hfjs create-branch coyotte508/test-model build --empty hfjs upload coyotte508/test-model --revision build ``` ## Testing go into `packages/hub` run `pnpm install` and run `sudo npm link` - then you can use `hfjs` or just do `node dist/cli.js upload ...` --------- Co-authored-by: Julien Chaumond <julien@huggingface.co>
1 parent 3a3868f commit ad0f961

17 files changed

+1079
-66
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"tshy": "^3.0.2",
2727
"tsup": "^6.7.0",
2828
"tsx": "^4.7.0",
29-
"typescript": "^5.4.2",
29+
"typescript": "^5.8.3",
3030
"vite": "^5.0.2",
3131
"vitest": "^0.34.6",
3232
"webdriverio": "^8.6.7"

packages/doc-internal/pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/hub/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,35 @@ for await (const fileInfo of hub.listFiles({repo})) {
9393
await hub.deleteRepo({ repo, accessToken: "hf_..." });
9494
```
9595

96+
## CLI usage
97+
98+
You can use `@huggingface/hub` in CLI mode to upload files and folders to your repo.
99+
100+
```console
101+
npx @huggingface/hub upload coyotte508/test-model .
102+
npx @huggingface/hub upload datasets/coyotte508/test-dataset .
103+
# Same thing
104+
npx @huggingface/hub upload --repo-type dataset coyotte508/test-dataset .
105+
# Upload new data with 0 history in a separate branch
106+
npx @huggingface/hub create-branch coyotte508/test-model release --empty
107+
npx @huggingface/hub upload coyotte508/test-model . --revision release
108+
109+
npx @huggingface/hub --help
110+
npx @huggingface/hub upload --help
111+
```
112+
113+
You can also instal globally with `npm install -g @huggingface/hub`. Then you can do:
114+
115+
```console
116+
hfjs upload coyotte508/test-model .
117+
118+
hfjs create-branch --repo-type dataset coyotte508/test-dataset release --empty
119+
hfjs upload --repo-type dataset coyotte508/test-dataset . --revision release
120+
121+
hfjs --help
122+
hfjs upload --help
123+
```
124+
96125
## OAuth Login
97126

98127
It's possible to login using OAuth (["Sign in with HF"](https://huggingface.co/docs/hub/oauth)).

0 commit comments

Comments
 (0)