Upload folder using huggingface_hub
Browse files- engine_data.csv +0 -0
- model_building/data_register.py +25 -0
engine_data.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model_building/data_register.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub.utils import RepositoryNotFoundError, HfHubHTTPError
|
| 2 |
+
from huggingface_hub import HfApi, create_repo
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
repo_id = "SharleyK/PredictiveMaintenance"
|
| 7 |
+
repo_type = "dataset"
|
| 8 |
+
|
| 9 |
+
# Initialize API client
|
| 10 |
+
api = HfApi(token=os.getenv("HF_TOKEN"))
|
| 11 |
+
|
| 12 |
+
# Step 1: Check if the space exists
|
| 13 |
+
try:
|
| 14 |
+
api.repo_info(repo_id=repo_id, repo_type=repo_type)
|
| 15 |
+
print(f"Space '{repo_id}' already exists. Using it.")
|
| 16 |
+
except RepositoryNotFoundError:
|
| 17 |
+
print(f"Space '{repo_id}' not found. Creating new space...")
|
| 18 |
+
create_repo(repo_id=repo_id, repo_type=repo_type, private=False)
|
| 19 |
+
print(f"Space '{repo_id}' created.")
|
| 20 |
+
|
| 21 |
+
api.upload_folder(
|
| 22 |
+
folder_path="engine_predictive_maintenance/data",
|
| 23 |
+
repo_id=repo_id,
|
| 24 |
+
repo_type=repo_type,
|
| 25 |
+
)
|