|
|
|
|
|
""" |
|
|
Basic smoke test - checks code structure without requiring full dependencies. |
|
|
""" |
|
|
|
|
|
import importlib.util |
|
|
import sys |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
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) |
|
|
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) |
|
|
|
|
|
|
|
|
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())) |
|
|
|
|
|
|
|
|
|
|
|
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()) |
|
|
|