Skip to content

Add cli for @huggingface/hub #1412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
86956a3
add create-branch
coyotte508 Apr 30, 2025
b175cf4
add delete-branch
coyotte508 Apr 30, 2025
80faefb
cli file
coyotte508 Apr 30, 2025
c3cc59b
Merge remote-tracking branch 'origin/main' into cli
coyotte508 May 6, 2025
28f1050
document cli & name it to 'hfx'
coyotte508 May 6, 2025
e886d54
Update packages/hub/package.json
coyotte508 May 6, 2025
dda33e7
fix TS
coyotte508 May 6, 2025
0de8bea
switch back to hfx for now @julien-c, see slack
coyotte508 May 6, 2025
13569ac
fix repo param in url
coyotte508 May 6, 2025
618bbce
fixup! fix repo param in url
coyotte508 May 6, 2025
d982af9
hfjs
coyotte508 May 6, 2025
ef81d23
fixup! hfjs
coyotte508 May 6, 2025
f9a5747
doc
coyotte508 May 6, 2025
fa31248
remove all shorthands (except 'q')
coyotte508 May 6, 2025
3533e2e
Merge remote-tracking branch 'origin/main' into cli
coyotte508 May 6, 2025
0fa9af7
cli fixes
coyotte508 May 6, 2025
23498e0
cli fixes
coyotte508 May 6, 2025
f735cfa
fixup! cli fixes
coyotte508 May 6, 2025
f831b3c
add hidden hub-url CLI param
coyotte508 May 6, 2025
3aacda1
fix uploading to new rev not from empty
coyotte508 May 6, 2025
ec619f3
Merge remote-tracking branch 'origin/main' into cli
coyotte508 May 7, 2025
04d7fdd
Merge branch 'main' into cli
coyotte508 May 7, 2025
4aefa05
Also support pathInRepo positional arg
coyotte508 May 7, 2025
03e615d
Add create-branch to the cli
coyotte508 May 7, 2025
0dec5a0
token param too
coyotte508 May 7, 2025
3b84137
better usage text
coyotte508 May 7, 2025
43aae04
Add --force param to create-branch
coyotte508 May 7, 2025
e25930e
fixup! Add --force param to create-branch
coyotte508 May 7, 2025
be57754
more detailed usage
coyotte508 May 7, 2025
8f96728
update repo name description
coyotte508 May 7, 2025
0be6a40
add delete-branch and version commands
coyotte508 May 13, 2025
ea0e2bc
add repoExists function
coyotte508 May 13, 2025
f6e9893
create repo when it does not exist
coyotte508 May 13, 2025
4a8e319
Update default commit message
coyotte508 May 13, 2025
468dc2c
create-branch => branch create and delete-branch => branch delete
coyotte508 May 14, 2025
a597f08
fixup! create-branch => branch create and delete-branch => branch delete
coyotte508 May 14, 2025
e0ad6f3
also upgrade typescriptt dep of doc-internal
coyotte508 May 14, 2025
a4a5a8d
always display full stack trace
coyotte508 May 14, 2025
220dbec
Merge branch 'main' into cli
coyotte508 May 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"tshy": "^3.0.2",
"tsup": "^6.7.0",
"tsx": "^4.7.0",
"typescript": "^5.4.2",
"typescript": "^5.8.3",
"vite": "^5.0.2",
"vitest": "^0.34.6",
"webdriverio": "^8.6.7"
Expand Down
18 changes: 9 additions & 9 deletions packages/doc-internal/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions packages/hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,35 @@ for await (const fileInfo of hub.listFiles({repo})) {
await hub.deleteRepo({ repo, accessToken: "hf_..." });
```

## CLI usage

You can use `@huggingface/hub` in CLI mode to upload files and folders to your repo.

```console
npx @huggingface/hub upload coyotte508/test-model .
npx @huggingface/hub upload datasets/coyotte508/test-dataset .
# Same thing
npx @huggingface/hub upload --repo-type dataset coyotte508/test-dataset .
# Upload new data with 0 history in a separate branch
npx @huggingface/hub create-branch coyotte508/test-model release --empty
npx @huggingface/hub upload coyotte508/test-model . --revision release

npx @huggingface/hub --help
npx @huggingface/hub upload --help
```

You can also instal globally with `npm install -g @huggingface/hub`. Then you can do:

```console
hfjs upload coyotte508/test-model .

hfjs create-branch --repo-type dataset coyotte508/test-dataset release --empty
hfjs upload --repo-type dataset coyotte508/test-dataset . --revision release

hfjs --help
hfjs upload --help
```

## OAuth Login

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