Spaces:
Running
Running
#!/usr/bin/env python3 | |
""" | |
Upload updated files to Hugging Face Space using the API | |
""" | |
from huggingface_hub import HfApi | |
import os | |
def upload_files_to_space(): | |
"""Upload the updated files to the Hugging Face Space""" | |
# Initialize the API | |
api = HfApi() | |
# Space details | |
repo_id = "JoachimVC/gaia-enhanced-agent" | |
repo_type = "space" | |
print(f"Uploading files to {repo_id}...") | |
# Files to upload with their paths | |
files_to_upload = [ | |
("agents/enhanced_unified_agno_agent.py", "agents/enhanced_unified_agno_agent.py"), | |
("utils/simple_answer_formatter.py", "utils/simple_answer_formatter.py"), | |
("app.py", "app.py"), | |
("requirements.txt", "requirements.txt") | |
] | |
try: | |
for local_path, repo_path in files_to_upload: | |
if os.path.exists(local_path): | |
print(f"Uploading {local_path} -> {repo_path}") | |
api.upload_file( | |
path_or_fileobj=local_path, | |
path_in_repo=repo_path, | |
repo_id=repo_id, | |
repo_type=repo_type, | |
commit_message=f"Update {repo_path} with SimpleGAIAAnswerFormatter integration" | |
) | |
print(f"β Successfully uploaded {repo_path}") | |
else: | |
print(f"β File not found: {local_path}") | |
print(f"\nπ All files uploaded successfully to {repo_id}") | |
print(f"π Space should be rebuilding automatically...") | |
except Exception as e: | |
print(f"β Error uploading files: {e}") | |
return False | |
return True | |
if __name__ == "__main__": | |
success = upload_files_to_space() | |
if success: | |
print("\nβ Deployment completed successfully!") | |
else: | |
print("\nβ Deployment failed!") |