-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_test.py
More file actions
66 lines (49 loc) · 1.67 KB
/
Copy pathsimple_test.py
File metadata and controls
66 lines (49 loc) · 1.67 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Create loader
# Get first example
# Try different ways to access
from src.models.emotion_detection.dataset_loader import create_goemotions_loader
import traceback
# Add src to path
#!/usr/bin/env python3
from pathlib import Path
import logging
import sys
import traceback
"""
Simple test to understand the dataset object type.
"""
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src"))
def main():
logging.info("🔍 Simple test...")
try:
loader = create_goemotions_loader()
datasets = loader.prepare_datasets()
train_data = datasets["train"]
first_example = train_data[0]
logging.info("✅ Type of first_example: {type(first_example)}")
logging.info("✅ Dir of first_example: {dir(first_example)}")
try:
logging.info("✅ As dict: {dict(first_example)}")
except:
logging.info("❌ Cannot convert to dict")
try:
logging.info("✅ Keys: {first_example.keys()}")
except:
logging.info("❌ No keys method")
try:
logging.info("✅ Labels: {first_example['labels']}")
except Exception as e:
logging.info("❌ Cannot access labels: {e}")
try:
logging.info("✅ Labels attr: {getattr(first_example, 'labels', 'No labels attr')}")
except Exception as e:
logging.info("❌ Cannot get labels attr: {e}")
return True
except Exception as e:
logging.info("❌ Error: {e}")
traceback.print_exc()
return False
if __name__ == "__main__":
success = main()
if not success:
sys.exit(1)