File size: 1,093 Bytes
6dae01f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
33
34
from huggingface_hub.utils import validate_repo_id, HfHubHTTPError,RepositoryNotFoundError
from huggingface_hub import HfApi
from huggingface_hub import create_repo
import os

repo_id = "grkavi0912/engine1"
repo_type = "dataset" # Corrected from "Datasets" to "dataset"
private = False
token = "HFTOKEN" # Placeholder, will be replaced by userdata.get() later
#Initialize API client
api = HfApi(token=os.getenv("HFTOKEN")) # Corrected missing parenthesis and used os.getenv as in original notebook

#step 1:check if the space exists
try:
    api.repo_info(repo_id=repo_id,repo_type=repo_type)
    print(f"Repo {repo_id} already exists")
except RepositoryNotFoundError:
    print(f"Repo {repo_id} not found")
    create_repo(repo_id=repo_id, repo_type=repo_type)
    print(f"Repo {repo_id} created")

#api.upload_folder(
    #folder_path="mlops/data",
    #repo_id=repo_id,
    #repo_type=repo_type,
#)
api.upload_folder(
    folder_path="engine1/data",
    repo_id=repo_id,
    repo_type=repo_type,
    commit_message="Initial dataset upload",
    ignore_patterns=["*.py", "__pycache__/*"],
)