import os from huggingface_hub import HfApi def create_hf_repo(repo_id: str, repo_type: str = "space", space_sdk: str = "static"): """ Creates a new repository on Hugging Face. """ api = HfApi() print(f"Creating new {repo_type} '{repo_id}'...") api.create_repo( repo_id=repo_id, repo_type=repo_type, space_sdk=space_sdk, exist_ok=True ) return f"Successfully created {repo_type} {repo_id}" def push_files_to_bucket(local_dir: str, repo_id: str, repo_type: str = "dataset"): """ Pushes files from a local directory to a Hugging Face repository. """ api = HfApi() if not os.path.exists(local_dir): raise ValueError(f"Local directory '{local_dir}' does not exist.") print(f"Pushing files from '{local_dir}' to '{repo_type}' '{repo_id}'...") api.upload_folder( folder_path=local_dir, repo_id=repo_id, repo_type=repo_type, commit_message="Syncing files from local MCP agent storage" ) return True