Spaces:
Runtime error
Runtime error
Commit
•
f8207e5
1
Parent(s):
963c322
chore: Update data_loader.py with Hugging Face Hub integration
Browse files- data_loader.py +16 -0
data_loader.py
CHANGED
@@ -3,8 +3,24 @@ from datetime import datetime
|
|
3 |
from typing import Any, Dict, List
|
4 |
|
5 |
import pandas as pd
|
|
|
|
|
|
|
6 |
from tqdm.auto import tqdm
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def has_card_data(dataset):
|
10 |
return hasattr(dataset, "card_data")
|
|
|
3 |
from typing import Any, Dict, List
|
4 |
|
5 |
import pandas as pd
|
6 |
+
from dotenv import load_dotenv
|
7 |
+
from huggingface_hub import HfApi
|
8 |
+
from huggingface_hub.utils import logging
|
9 |
from tqdm.auto import tqdm
|
10 |
|
11 |
+
load_dotenv()
|
12 |
+
|
13 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
14 |
+
assert HF_TOKEN is not None, "You need to set HF_TOKEN in your environment variables"
|
15 |
+
USER_AGENT = os.getenv("USER_AGENT")
|
16 |
+
assert (
|
17 |
+
USER_AGENT is not None
|
18 |
+
), "You need to set USER_AGENT in your environment variables"
|
19 |
+
|
20 |
+
logger = logging.get_logger(__name__)
|
21 |
+
|
22 |
+
api = HfApi(token=HF_TOKEN)
|
23 |
+
|
24 |
|
25 |
def has_card_data(dataset):
|
26 |
return hasattr(dataset, "card_data")
|