3d_model / scripts /tests /smoke_test_basic.py
Azan
Clean deployment build (Squashed)
7a87926
#!/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())