File size: 738 Bytes
afa505f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from huggingface_hub.utils import RepositoryNotFoundError, HfHubHTTPError
from huggingface_hub import HfApi, create_repo
import os
repo_id = "SharleyK/TourismPackagePrediction"
repo_type = "dataset"
# Initialize API client
api = HfApi(token=os.getenv("HF_TOKEN"))
# Step 1: Check if the space exists
try:
api.repo_info(repo_id=repo_id, repo_type=repo_type)
print(f"Space '{repo_id}' already exists. Using it.")
except RepositoryNotFoundError:
print(f"Space '{repo_id}' not found. Creating new space...")
create_repo(repo_id=repo_id, repo_type=repo_type, private=False)
print(f"Space '{repo_id}' created.")
api.upload_folder(
folder_path="tourism_project/data",
repo_id=repo_id,
repo_type=repo_type,
)
|