Buckets:
| #!/usr/bin/env python3 | |
| """ | |
| Test script to verify the CA10 Knowledge Graphs setup | |
| """ | |
| import os | |
| import sys | |
| def test_imports(): | |
| """Test if all required modules can be imported""" | |
| try: | |
| # Add src to path | |
| sys.path.append(os.path.join(os.path.dirname(__file__), "src")) | |
| # Test core imports | |
| from core.knowledge_graph import KnowledgeGraph, create_sample_kg | |
| from core.scientific_kg import ( | |
| AdvancedScientificKG, | |
| create_advanced_scientific_kg, | |
| ) | |
| from models.embeddings import TransE, DistMult, ComplEx, KGEmbeddingTrainer | |
| print("โ All imports successful!") | |
| return True | |
| except ImportError as e: | |
| print(f"โ Import error: {e}") | |
| return False | |
| def test_directories(): | |
| """Test if all required directories exist""" | |
| required_dirs = [ | |
| "src", | |
| "src/core", | |
| "src/models", | |
| "src/reasoning", | |
| "src/utils", | |
| "logs", | |
| "results", | |
| "visualization", | |
| ] | |
| missing_dirs = [] | |
| for dir_name in required_dirs: | |
| if not os.path.exists(dir_name): | |
| missing_dirs.append(dir_name) | |
| if missing_dirs: | |
| print(f"โ Missing directories: {missing_dirs}") | |
| return False | |
| else: | |
| print("โ All directories exist!") | |
| return True | |
| def test_basic_functionality(): | |
| """Test basic knowledge graph functionality""" | |
| try: | |
| from core.knowledge_graph import create_sample_kg | |
| kg = create_sample_kg() | |
| print( | |
| f"โ Created knowledge graph with {len(kg.entities)} entities and {len(kg.triples)} triples" | |
| ) | |
| # Test a simple query | |
| einstein_triples = kg.query_triples(subject="einstein") | |
| print(f"โ Found {len(einstein_triples)} triples for Einstein") | |
| return True | |
| except Exception as e: | |
| print(f"โ Functionality test failed: {e}") | |
| return False | |
| def main(): | |
| """Run all tests""" | |
| print("๐งช Testing CA10 Knowledge Graphs Setup") | |
| print("=" * 40) | |
| tests = [ | |
| ("Directory Structure", test_directories), | |
| ("Module Imports", test_imports), | |
| ("Basic Functionality", test_basic_functionality), | |
| ] | |
| passed = 0 | |
| total = len(tests) | |
| for test_name, test_func in tests: | |
| print(f"\n๐ {test_name}:") | |
| if test_func(): | |
| passed += 1 | |
| else: | |
| print(f" Test failed!") | |
| print(f"\n๐ Test Results: {passed}/{total} tests passed") | |
| if passed == total: | |
| print("๐ All tests passed! The setup is ready.") | |
| return True | |
| else: | |
| print("โ Some tests failed. Please check the setup.") | |
| return False | |
| if __name__ == "__main__": | |
| success = main() | |
| sys.exit(0 if success else 1) | |
Xet Storage Details
- Size:
- 2.8 kB
- Xet hash:
- f5192d8f7b955f4444c560150972d415af2a1921e99f1d52710f76484a2352a3
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.