import os from huggingface_hub import HfApi # Initialize the Hugging Face API api = HfApi() # Repository details - using the agentica-org namespace as requested repo_id = "agentica-org/DeepSWE-Preview-FP8" # Using the organization namespace local_dir = "/home/op/DeepSWE-Preview-FP8" # Files to upload (excluding serving scripts) files_to_upload = [ "README.md", "added_tokens.json", "chat_template.jinja", "config.json", "generation_config.json", "merges.txt", "model-00001-of-00007.safetensors", "model-00002-of-00007.safetensors", "model-00003-of-00007.safetensors", "model-00004-of-00007.safetensors", "model-00005-of-00007.safetensors", "model-00006-of-00007.safetensors", "model-00007-of-00007.safetensors", "model.safetensors.index.json", "special_tokens_map.json", "tokenizer_config.json", "tokenizer.json", "vocab.json" ] def upload_model(): print(f"Creating repository {repo_id}...") # Create the repository if it doesn't exist try: api.create_repo(repo_id=repo_id, repo_type="model", private=False, exist_ok=True) print(f"Repository {repo_id} created or already exists.") except Exception as e: print(f"Error creating repository: {e}") return # Upload files print("Uploading files...") for file_name in files_to_upload: file_path = os.path.join(local_dir, file_name) if os.path.exists(file_path): try: print(f"Uploading {file_name}...") api.upload_file( path_or_fileobj=file_path, path_in_repo=file_name, repo_id=repo_id, repo_type="model" ) print(f"Uploaded {file_name}") except Exception as e: print(f"Error uploading {file_name}: {e}") else: print(f"File not found: {file_path}") print("Upload completed!") print(f"Model uploaded to: https://huggingface.co/{repo_id}") if __name__ == "__main__": upload_model()