Spaces:
Sleeping
Sleeping
Update download_repo_to_huggingface.py
Browse files
download_repo_to_huggingface.py
CHANGED
@@ -1,14 +1,8 @@
|
|
1 |
-
def download_and_upload_kadiAPY_repo_to_huggingfacespace():
|
2 |
try:
|
3 |
-
# Load the configuration from config.json
|
4 |
-
|
5 |
-
# Extract GitLab project information from the config
|
6 |
-
api_url = config2['gitlab']['api_url']
|
7 |
-
project_id = urllib.parse.quote(config2['gitlab']['project']['id'], safe="")
|
8 |
-
version = config2['gitlab']['project']['version']
|
9 |
-
|
10 |
# Construct the URL for the release's zip file
|
11 |
-
|
|
|
12 |
|
13 |
# Send GET request to download the zip file
|
14 |
response = requests.get(url, stream=True)
|
@@ -27,8 +21,6 @@ def download_and_upload_kadiAPY_repo_to_huggingfacespace():
|
|
27 |
print(f"An error occurred: {e}")
|
28 |
|
29 |
|
30 |
-
|
31 |
-
|
32 |
def extract_and_upload_file(response, api, DATA_DIR, HF_SPACE_NAME):
|
33 |
"""Extracts the archive content and uploads the file."""
|
34 |
archive_bytes = io.BytesIO(response.content)
|
|
|
1 |
+
def download_and_upload_kadiAPY_repo_to_huggingfacespace(api_url, project_id, version):
|
2 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
# Construct the URL for the release's zip file
|
4 |
+
encoded_project_id = urllib.parse.quote(project_id, safe="")
|
5 |
+
url = f"{api_url}/projects/{encoded_project_id}/repository/archive.zip?sha={version}"
|
6 |
|
7 |
# Send GET request to download the zip file
|
8 |
response = requests.get(url, stream=True)
|
|
|
21 |
print(f"An error occurred: {e}")
|
22 |
|
23 |
|
|
|
|
|
24 |
def extract_and_upload_file(response, api, DATA_DIR, HF_SPACE_NAME):
|
25 |
"""Extracts the archive content and uploads the file."""
|
26 |
archive_bytes = io.BytesIO(response.content)
|