Commit
•
41daa3d
1
Parent(s):
54fa454
Removing old repo
Browse files
utilities/readme_update.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import os
|
2 |
from datetime import datetime
|
|
|
|
|
3 |
|
4 |
import pytz
|
5 |
from huggingface_hub import HfApi, Repository
|
@@ -24,6 +26,9 @@ def update_dataset_readme(dataset_name: str, subreddit: str, new_rows: int) -> N
|
|
24 |
# Initialize HfApi
|
25 |
api = HfApi()
|
26 |
|
|
|
|
|
|
|
27 |
# Clone the repository locally
|
28 |
repo = Repository(local_repo_path, clone_from=dataset_name, repo_type='dataset', use_auth_token=hf_token)
|
29 |
|
@@ -39,7 +44,8 @@ def update_dataset_readme(dataset_name: str, subreddit: str, new_rows: int) -> N
|
|
39 |
file.write(new_readme)
|
40 |
|
41 |
# Push the changes
|
42 |
-
repo.push_to_hub(blocking=True, commit_message=f'Pushing {new_rows}')
|
|
|
43 |
|
44 |
def append_to_readme(subreddit: str, new_rows: int, old_readme: str) -> str:
|
45 |
"""
|
@@ -82,4 +88,4 @@ To opt-out of this dataset please make a request in the community tab
|
|
82 |
else:
|
83 |
new_readme = old_readme + "\n\n" + GENERATED_BELOW_MARKER + "\n\n" + readme_text + "\n"
|
84 |
|
85 |
-
return new_readme
|
|
|
1 |
import os
|
2 |
from datetime import datetime
|
3 |
+
from pathlib import Path
|
4 |
+
from shutil import rmtree
|
5 |
|
6 |
import pytz
|
7 |
from huggingface_hub import HfApi, Repository
|
|
|
26 |
# Initialize HfApi
|
27 |
api = HfApi()
|
28 |
|
29 |
+
if Path(local_repo_path).exists():
|
30 |
+
rmtree(local_repo_path)
|
31 |
+
|
32 |
# Clone the repository locally
|
33 |
repo = Repository(local_repo_path, clone_from=dataset_name, repo_type='dataset', use_auth_token=hf_token)
|
34 |
|
|
|
44 |
file.write(new_readme)
|
45 |
|
46 |
# Push the changes
|
47 |
+
repo.push_to_hub(blocking=True, commit_message=f'Pushing {new_rows} new rows')
|
48 |
+
|
49 |
|
50 |
def append_to_readme(subreddit: str, new_rows: int, old_readme: str) -> str:
|
51 |
"""
|
|
|
88 |
else:
|
89 |
new_readme = old_readme + "\n\n" + GENERATED_BELOW_MARKER + "\n\n" + readme_text + "\n"
|
90 |
|
91 |
+
return new_readme
|