Upload hfhub.py with huggingface_hub
Browse files
hfhub.py
CHANGED
|
@@ -10,20 +10,18 @@ from huggingface_hub import (
|
|
| 10 |
snapshot_download,
|
| 11 |
)
|
| 12 |
|
| 13 |
-
|
| 14 |
repo_dir = Path("hfhub")
|
| 15 |
token = os.environ["HF_TOKEN"]
|
| 16 |
-
# login(token=token)
|
| 17 |
-
# repo_url = create_repo(repo_id=repo_path, repo_type="model", exist_ok=True)
|
| 18 |
-
# print(repo_url)
|
| 19 |
|
| 20 |
(Path(repo_dir) / "checkpoints").mkdir(parents=True, exist_ok=True)
|
| 21 |
|
| 22 |
hf_api = HfApi(token=token)
|
| 23 |
repo_url = hf_api.create_repo(
|
| 24 |
-
repo_id=
|
| 25 |
)
|
| 26 |
print(repo_url)
|
|
|
|
| 27 |
|
| 28 |
hf_api.upload_file(
|
| 29 |
repo_id=repo_path,
|
|
|
|
| 10 |
snapshot_download,
|
| 11 |
)
|
| 12 |
|
| 13 |
+
repo_name = "test2"
|
| 14 |
repo_dir = Path("hfhub")
|
| 15 |
token = os.environ["HF_TOKEN"]
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
(Path(repo_dir) / "checkpoints").mkdir(parents=True, exist_ok=True)
|
| 18 |
|
| 19 |
hf_api = HfApi(token=token)
|
| 20 |
repo_url = hf_api.create_repo(
|
| 21 |
+
repo_id=repo_name, repo_type="model", exist_ok=True, private=True
|
| 22 |
)
|
| 23 |
print(repo_url)
|
| 24 |
+
repo_path = "/".join(repo_url.split("/")[-2:])
|
| 25 |
|
| 26 |
hf_api.upload_file(
|
| 27 |
repo_id=repo_path,
|