bupa1018 commited on
Commit
695382d
·
1 Parent(s): 421c944

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -47
app.py CHANGED
@@ -49,53 +49,6 @@ HF_TOKEN = os.environ["HF_Token"]
49
  login(HF_TOKEN)
50
  api = HfApi()
51
 
52
- def load_project_id(json_file):
53
- with open(json_file, 'r') as f:
54
- data = json.load(f)
55
- return data['project_id']
56
-
57
-
58
- def download_gitlab_repo():
59
- print("Start the upload_gitRepository function")
60
- project_id = load_project_id('repository_ids.json')
61
- encoded_project_id = urllib.parse.quote_plus(project_id)
62
-
63
- # Define the URL to download the repository archive
64
- archive_url = f"{GITLAB_API_URL}/projects/{encoded_project_id}/repository/archive.zip"
65
-
66
- # Download the repository archive
67
- response = requests.get(archive_url)
68
- archive_bytes = io.BytesIO(response.content)
69
-
70
- # Retrieve the original file name from the response headers
71
- content_disposition = response.headers.get('content-disposition')
72
- if content_disposition:
73
- filename = content_disposition.split('filename=')[-1].strip('\"')
74
- else:
75
- filename = 'archive.zip' # Fallback to a default name if not found
76
-
77
- # Check if the file already exists in the repository
78
- existing_files = api.list_repo_files(repo_id=HF_SPACE_NAME, repo_type='space')
79
- target_path = f"{DATA_DIR}/{filename}"
80
-
81
- print(f"Target Path: '{target_path}'")
82
- print(f"Existing Files: {[repr(file) for file in existing_files]}")
83
-
84
- if target_path in existing_files:
85
- print(f"File '{target_path}' already exists in the repository. Skipping upload...")
86
- else:
87
- # Upload the ZIP file to the new folder in the Hugging Face space repository
88
- print("Uploading File to directory:")
89
- print(f"Archive Bytes: {repr(archive_bytes.getvalue())[:100]}") # Show a preview of bytes
90
- print(f"Target Path in Repo: '{target_path}'")
91
-
92
- api.upload_file(
93
- path_or_fileobj=archive_bytes,
94
- path_in_repo=target_path,
95
- repo_id=HF_SPACE_NAME,
96
- repo_type='space'
97
- )
98
- print("Upload complete")
99
 
100
 
101
  def split_python_code_into_chunks(texts, file_paths):
 
49
  login(HF_TOKEN)
50
  api = HfApi()
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
 
54
  def split_python_code_into_chunks(texts, file_paths):