File size: 3,777 Bytes
7a87926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python3
"""
Basic smoke test - checks code structure without requiring full dependencies.
"""

import importlib.util
import sys
from pathlib import Path

# Fix: Go up 3 levels to reach project root from scripts/tests/smoke_test_basic.py
project_root = Path(__file__).parent.parent.parent
sys.path.insert(0, str(project_root))


def test_imports():
    """Test that all modules can be imported."""
    print("=" * 60)
    print("YLFF Basic Smoke Test - Module Structure")
    print("=" * 60)

    modules_to_test = [
        "ylff",
        "ylff.services.ba_validator",
        "ylff.services.data_pipeline",
        "ylff.services.ylff_training",
        "ylff.models",
        "ylff.services.evaluate",
        "ylff.cli",
    ]

    results = {}
    for module_name in modules_to_test:
        try:
            spec = importlib.util.find_spec(module_name)
            if spec is None:
                results[module_name] = ("FAIL", "Module not found")
            else:
                importlib.import_module(module_name)  # noqa: F841
                results[module_name] = ("OK", f"Found at {spec.origin}")
        except Exception as e:
            results[module_name] = ("FAIL", str(e))

    print("\nModule Import Results:")
    print("-" * 60)
    all_ok = True
    for module_name, (status, msg) in results.items():
        status_symbol = "βœ“" if status == "OK" else "βœ—"
        print(f"{status_symbol} {module_name:30s} - {msg}")
        if status != "OK":
            all_ok = False

    print("\n" + "=" * 60)
    if all_ok:
        print("βœ“ All modules can be imported")
    else:
        print("βœ— Some modules failed to import")
    print("=" * 60)

    return all_ok


def test_file_structure():
    """Test that expected files exist."""
    print("\n" + "=" * 60)
    print("File Structure Check")
    print("=" * 60)

    # Updated to match actual project structure
    expected_files = [
        "ylff/__init__.py",
        "ylff/services/ba_validator.py",
        "ylff/services/data_pipeline.py",
        "ylff/services/ylff_training.py",
        "ylff/models/__init__.py",
        "ylff/services/evaluate.py",
        "ylff/cli.py",
        "configs/ba_config.yaml",
        "configs/dinov2_train_config.yaml",
        "README.md",
    ]

    all_ok = True
    for file_path in expected_files:
        full_path = project_root / file_path
        exists = full_path.exists()
        status_symbol = "βœ“" if exists else "βœ—"
        print(f"{status_symbol} {file_path}")
        if not exists:
            all_ok = False

    print("\n" + "=" * 60)
    if all_ok:
        print("βœ“ All expected files exist")
    else:
        print("βœ— Some files are missing")
    print("=" * 60)

    return all_ok


def main():
    """Run basic smoke tests."""
    results = []

    results.append(("Module Imports", test_imports()))
    results.append(("File Structure", test_file_structure()))
    
    # Removed Test Data check as assets are not strictly required for code smoke testing

    print("\n" + "=" * 60)
    print("Summary")
    print("=" * 60)

    all_passed = True
    for test_name, passed in results:
        status = "βœ“ PASS" if passed else "βœ— FAIL"
        print(f"{status} - {test_name}")
        if not passed:
            all_passed = False

    print("=" * 60)

    if all_passed:
        print("\nβœ“ Basic smoke test passed!")
        print("\nNext steps:")
        print("  1. Install dependencies: pip install -e .")
        print("  2. Install BA dependencies: ./scripts/bin/setup_ba_pipeline.sh")
        print("  3. Run full smoke test: python scripts/smoke_test.py")
        return 0
    else:
        print("\nβœ— Some tests failed")
        return 1


if __name__ == "__main__":
    sys.exit(main())