mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 11:41:02 +02:00
Test infra
This commit is contained in:
parent
98872c5247
commit
4ff85cd6bd
3 changed files with 150 additions and 0 deletions
74
check_imports.py
Executable file
74
check_imports.py
Executable file
|
|
@ -0,0 +1,74 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Check if TrustGraph imports work correctly for testing
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
def check_import(module_name, description):
|
||||||
|
"""Try to import a module and report the result"""
|
||||||
|
try:
|
||||||
|
__import__(module_name)
|
||||||
|
print(f"✅ {description}: {module_name}")
|
||||||
|
return True
|
||||||
|
except ImportError as e:
|
||||||
|
print(f"❌ {description}: {module_name}")
|
||||||
|
print(f" Error: {e}")
|
||||||
|
return False
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ {description}: {module_name}")
|
||||||
|
print(f" Unexpected error: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Checking TrustGraph imports for testing...")
|
||||||
|
print("=" * 50)
|
||||||
|
|
||||||
|
imports_to_check = [
|
||||||
|
("trustgraph", "Base trustgraph package"),
|
||||||
|
("trustgraph.base", "Base classes"),
|
||||||
|
("trustgraph.base.llm_service", "LLM service base class"),
|
||||||
|
("trustgraph.schema", "Schema definitions"),
|
||||||
|
("trustgraph.exceptions", "Exception classes"),
|
||||||
|
("trustgraph.model", "Model package"),
|
||||||
|
("trustgraph.model.text_completion", "Text completion package"),
|
||||||
|
("trustgraph.model.text_completion.vertexai", "VertexAI package"),
|
||||||
|
]
|
||||||
|
|
||||||
|
success_count = 0
|
||||||
|
total_count = len(imports_to_check)
|
||||||
|
|
||||||
|
for module_name, description in imports_to_check:
|
||||||
|
if check_import(module_name, description):
|
||||||
|
success_count += 1
|
||||||
|
print()
|
||||||
|
|
||||||
|
print("=" * 50)
|
||||||
|
print(f"Import Check Results: {success_count}/{total_count} successful")
|
||||||
|
|
||||||
|
if success_count == total_count:
|
||||||
|
print("✅ All imports successful! Tests should work.")
|
||||||
|
else:
|
||||||
|
print("❌ Some imports failed. Please install missing packages.")
|
||||||
|
print("\nTo fix, run:")
|
||||||
|
print(" ./install_packages.sh")
|
||||||
|
print("or install packages manually:")
|
||||||
|
print(" cd trustgraph-base && pip install -e . && cd ..")
|
||||||
|
print(" cd trustgraph-vertexai && pip install -e . && cd ..")
|
||||||
|
print(" cd trustgraph-flow && pip install -e . && cd ..")
|
||||||
|
|
||||||
|
# Test the specific import used in the test
|
||||||
|
print("\n" + "=" * 50)
|
||||||
|
print("Testing specific import from test file...")
|
||||||
|
try:
|
||||||
|
from trustgraph.model.text_completion.vertexai.llm import Processor
|
||||||
|
from trustgraph.schema import TextCompletionRequest, TextCompletionResponse, Error
|
||||||
|
from trustgraph.base import LlmResult
|
||||||
|
print("✅ Test imports successful!")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Test imports failed: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
28
install_packages.sh
Executable file
28
install_packages.sh
Executable file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Install TrustGraph packages for testing
|
||||||
|
|
||||||
|
echo "Installing TrustGraph packages..."
|
||||||
|
|
||||||
|
# Install base package first (required by others)
|
||||||
|
cd trustgraph-base
|
||||||
|
pip install -e .
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Install base package first (required by others)
|
||||||
|
cd trustgraph-cli
|
||||||
|
pip install -e .
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Install vertexai package (depends on base)
|
||||||
|
cd trustgraph-vertexai
|
||||||
|
pip install -e .
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Install flow package (for additional components)
|
||||||
|
cd trustgraph-flow
|
||||||
|
pip install -e .
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo "Package installation complete!"
|
||||||
|
echo "Verify installation:"
|
||||||
|
#python -c "import trustgraph.model.text_completion.vertexai.llm; print('VertexAI import successful')"
|
||||||
48
run_tests.sh
Executable file
48
run_tests.sh
Executable file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Test runner script for TrustGraph
|
||||||
|
|
||||||
|
echo "TrustGraph Test Runner"
|
||||||
|
echo "===================="
|
||||||
|
|
||||||
|
# Check if we're in the right directory
|
||||||
|
if [ ! -f "install_packages.sh" ]; then
|
||||||
|
echo "❌ Error: Please run this script from the project root directory"
|
||||||
|
echo " Expected files: install_packages.sh, check_imports.py"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Step 1: Check current imports
|
||||||
|
echo "Step 1: Checking current imports..."
|
||||||
|
python check_imports.py
|
||||||
|
|
||||||
|
# Step 2: Install packages if needed
|
||||||
|
echo ""
|
||||||
|
echo "Step 2: Installing TrustGraph packages..."
|
||||||
|
echo "This may take a moment..."
|
||||||
|
./install_packages.sh
|
||||||
|
|
||||||
|
# Step 3: Check imports again
|
||||||
|
echo ""
|
||||||
|
echo "Step 3: Verifying imports after installation..."
|
||||||
|
python check_imports.py
|
||||||
|
|
||||||
|
# Step 4: Install test dependencies
|
||||||
|
echo ""
|
||||||
|
echo "Step 4: Installing test dependencies..."
|
||||||
|
cd tests/
|
||||||
|
pip install -r requirements.txt
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Step 5: Run the tests
|
||||||
|
echo ""
|
||||||
|
echo "Step 5: Running VertexAI tests..."
|
||||||
|
echo "Command: pytest tests/unit/test_text_completion/test_vertexai_processor.py -v"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Set Python path just in case
|
||||||
|
export PYTHONPATH=$PWD:$PYTHONPATH
|
||||||
|
|
||||||
|
pytest tests/unit/test_text_completion/test_vertexai_processor.py -v
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Test run complete!"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue