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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 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
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
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