Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -311,21 +311,36 @@ def setup_vectorstore(chunks, model_name):
|
|
311 |
print("Persist directory:", vectorstore._persist_directory)
|
312 |
print("Available methods in vectorstore:", dir(vectorstore))
|
313 |
|
314 |
-
#
|
315 |
-
for root,
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
api.upload_file(
|
321 |
-
path_or_fileobj=
|
322 |
path_in_repo=target_path_in_repo,
|
323 |
repo_id=HF_SPACE_NAME,
|
324 |
repo_type="space"
|
325 |
)
|
326 |
-
print(f"Uploaded {
|
|
|
|
|
327 |
|
328 |
-
print("
|
|
|
329 |
|
330 |
|
331 |
# Setup LLM
|
|
|
311 |
print("Persist directory:", vectorstore._persist_directory)
|
312 |
print("Available methods in vectorstore:", dir(vectorstore))
|
313 |
|
314 |
+
# Get the first subfolder and zip its contents
|
315 |
+
for root, dirs, files in os.walk(temp_dir):
|
316 |
+
if dirs: # Check for subfolders
|
317 |
+
next_subfolder = os.path.join(root, dirs[0]) # Take the first subfolder
|
318 |
+
zip_file_path = os.path.join(temp_dir, "subfolder_archive.zip")
|
319 |
+
|
320 |
+
# Create a zip file
|
321 |
+
with zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED) as zipf:
|
322 |
+
for folder_root, _, folder_files in os.walk(next_subfolder):
|
323 |
+
for file_name in folder_files:
|
324 |
+
file_path = os.path.join(folder_root, file_name)
|
325 |
+
arcname = os.path.relpath(file_path, next_subfolder) # Preserve relative paths
|
326 |
+
zipf.write(file_path, arcname)
|
327 |
+
|
328 |
+
print(f"Created zip file: {zip_file_path}")
|
329 |
+
|
330 |
+
# Upload the zip file
|
331 |
+
target_path_in_repo = "subfolder_archive.zip" # Define the target name in the repository
|
332 |
api.upload_file(
|
333 |
+
path_or_fileobj=zip_file_path,
|
334 |
path_in_repo=target_path_in_repo,
|
335 |
repo_id=HF_SPACE_NAME,
|
336 |
repo_type="space"
|
337 |
)
|
338 |
+
print(f"Uploaded {zip_file_path} as {target_path_in_repo}")
|
339 |
+
|
340 |
+
break # Stop after processing the first subfolder
|
341 |
|
342 |
+
print("Process completed successfully!")
|
343 |
+
|
344 |
|
345 |
|
346 |
# Setup LLM
|