tahamajs's picture
download
raw
10.8 kB
#!/bin/bash
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m'
PROJECT_NAME="Advanced NeuroSymbolic Geometry Solver"
PYTHON_VERSION="3.9"
VENV_NAME="venv"
REQUIREMENTS_FILE="requirements.txt"
MAIN_SCRIPT="main.py"
CONFIG_FILE="config.yaml"
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo -e "${BLUE}================================${NC}"
echo -e "${BLUE} $1${NC}"
echo -e "${BLUE}================================${NC}"
}
command_exists() {
command -v "$1" >/dev/null 2>&1
}
check_python_version() {
if command_exists python3; then
PYTHON_VER=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
if [ "$(printf '%s\n' "$PYTHON_VERSION" "$PYTHON_VER" | sort -V | head -n1)" = "$PYTHON_VERSION" ]; then
print_status "Python version $PYTHON_VER is compatible"
return 0
else
print_error "Python version $PYTHON_VER is not compatible. Required: $PYTHON_VERSION+"
return 1
fi
else
print_error "Python3 is not installed"
return 1
fi
}
setup_venv() {
print_header "Setting up Virtual Environment"
if [ -d "$VENV_NAME" ]; then
print_warning "Virtual environment already exists"
read -p "Do you want to recreate it? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
print_status "Removing existing virtual environment..."
rm -rf "$VENV_NAME"
else
print_status "Using existing virtual environment"
return 0
fi
fi
print_status "Creating virtual environment..."
python3 -m venv "$VENV_NAME"
print_status "Activating virtual environment..."
source "$VENV_NAME/bin/activate"
print_status "Upgrading pip..."
pip install --upgrade pip
print_status "Virtual environment setup complete"
}
install_dependencies() {
print_header "Installing Dependencies"
if [ ! -f "$REQUIREMENTS_FILE" ]; then
print_error "Requirements file not found: $REQUIREMENTS_FILE"
return 1
fi
print_status "Installing packages from $REQUIREMENTS_FILE..."
pip install -r "$REQUIREMENTS_FILE"
print_status "Installing additional development packages..."
pip install jupyter ipykernel black flake8 mypy pytest
print_status "Dependencies installation complete"
}
setup_environment() {
print_header "Setting up Environment Variables"
if [ -z "$GOOGLE_API_KEY" ]; then
print_warning "GOOGLE_API_KEY environment variable is not set"
print_status "Please set your Google API key:"
echo "export GOOGLE_API_KEY='your_api_key_here'"
echo
read -p "Do you want to set it now? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
read -p "Enter your Google API key: " api_key
export GOOGLE_API_KEY="$api_key"
echo "export GOOGLE_API_KEY='$api_key'" >> ~/.bashrc
print_status "API key set for current session and added to ~/.bashrc"
else
print_warning "Continuing without API key. Some features may not work."
fi
else
print_status "Google API key is set"
fi
export PYTHONPATH="${PYTHONPATH}:$(pwd)/src"
export GEOMETRY_SOLVER_CONFIG="config.yaml"
export GEOMETRY_SOLVER_LOG_LEVEL="INFO"
print_status "Environment variables setup complete"
}
create_directories() {
print_header "Creating Project Directories"
directories=(
"data"
"data/elementary"
"data/high_school"
"data/olympiad"
"data/international"
"results"
"models"
"logs"
"visualizations"
"reports"
".cache"
"src/agents"
"src/ai"
"src/workflows"
"src/core"
"src/neural"
"src/symbolic"
"src/hybrid"
"src/evaluation"
"src/visualization"
"src/utils"
)
for dir in "${directories[@]}"; do
if [ ! -d "$dir" ]; then
print_status "Creating directory: $dir"
mkdir -p "$dir"
else
print_status "Directory already exists: $dir"
fi
done
print_status "Directory structure setup complete"
}
validate_installation() {
print_header "Validating Installation"
print_status "Checking Python packages..."
python3 -c "
import sys
required_packages = [
'numpy', 'torch', 'matplotlib', 'seaborn', 'sympy', 'networkx',
'langchain', 'langgraph', 'google.generativeai', 'transformers'
]
missing_packages = []
for package in required_packages:
try:
__import__(package)
print(f'✅ {package}')
except ImportError:
missing_packages.append(package)
print(f'❌ {package}')
if missing_packages:
print(f'Missing packages: {missing_packages}')
sys.exit(1)
else:
print('All required packages are installed!')
"
print_status "Checking configuration file..."
if [ -f "$CONFIG_FILE" ]; then
print_status "Configuration file found: $CONFIG_FILE"
else
print_error "Configuration file not found: $CONFIG_FILE"
return 1
fi
print_status "Installation validation complete"
}
run_tests() {
print_header "Running Tests"
print_status "Running basic functionality tests..."
python3 -c "
import sys
sys.path.insert(0, 'src')
try:
from src.agents.geometric_agent import GeometricToolkit
from src.ai.gemini_reasoner import GeminiMathematicalReasoner
from src.workflows.langgraph_workflow import AdvancedGeometricWorkflow
print('✅ All advanced components imported successfully')
toolkit = GeometricToolkit()
analysis = toolkit.analyze_problem_structure('In triangle ABC, prove that the sum of angles is 180 degrees')
print(f'✅ Problem analysis working: {analysis[\"difficulty\"]}')
print('✅ All tests passed!')
except Exception as e:
print(f'❌ Test failed: {e}')
sys.exit(1)
"
print_status "Tests completed successfully"
}
run_application() {
print_header "Running Advanced Geometry Solver"
if [ ! -f "$MAIN_SCRIPT" ]; then
print_error "Main script not found: $MAIN_SCRIPT"
return 1
fi
print_status "Starting the application..."
echo
case "${1:-default}" in
"demo")
print_status "Running demo mode..."
python3 "$MAIN_SCRIPT" --demo
;;
"test")
print_status "Running test mode..."
python3 "$MAIN_SCRIPT" --test
;;
"benchmark")
print_status "Running benchmark mode..."
python3 "$MAIN_SCRIPT" --benchmark
;;
"interactive")
print_status "Running interactive mode..."
python3 "$MAIN_SCRIPT" --interactive
;;
*)
print_status "Running default mode..."
python3 "$MAIN_SCRIPT"
;;
esac
}
show_help() {
echo -e "${CYAN}Advanced NeuroSymbolic Olympiad Geometry Solver${NC}"
echo -e "${CYAN}Enhanced with LangChain, LangGraph, and Gemini Integration${NC}"
echo
echo "Usage: $0 [OPTION]"
echo
echo "Options:"
echo " setup - Setup the environment and install dependencies"
echo " install - Install dependencies only"
echo " test - Run tests"
echo " demo - Run demo mode"
echo " benchmark - Run benchmark mode"
echo " interactive - Run interactive mode"
echo " clean - Clean up generated files"
echo " help - Show this help message"
echo
echo "Examples:"
echo " $0 setup # Complete setup"
echo " $0 demo # Run demo"
echo " $0 benchmark # Run benchmarks"
echo " $0 interactive # Interactive mode"
}
cleanup() {
print_header "Cleaning Up"
print_status "Removing generated files..."
rm -rf __pycache__/
rm -rf src/__pycache__/
rm -rf src/*/__pycache__/
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .coverage
rm -rf htmlcov/
print_status "Cleaning logs..."
find logs/ -name "*.log" -mtime +7 -delete 2>/dev/null || true
print_status "Cleaning cache..."
rm -rf .cache/*
print_status "Cleanup complete"
}
show_system_info() {
print_header "System Information"
echo "Operating System: $(uname -s)"
echo "Architecture: $(uname -m)"
echo "Python Version: $(python3 --version 2>/dev/null || echo 'Not installed')"
echo "Pip Version: $(pip --version 2>/dev/null || echo 'Not installed')"
echo "Git Version: $(git --version 2>/dev/null || echo 'Not installed')"
echo "Available Memory: $(free -h 2>/dev/null | grep '^Mem:' | awk '{print $2}' || echo 'Unknown')"
echo "Available Disk Space: $(df -h . 2>/dev/null | tail -1 | awk '{print $4}' || echo 'Unknown')"
echo
}
main() {
print_header "$PROJECT_NAME"
show_system_info
case "${1:-setup}" in
"setup")
print_status "Starting complete setup..."
check_python_version || exit 1
setup_venv
source "$VENV_NAME/bin/activate"
install_dependencies
setup_environment
create_directories
validate_installation
run_tests
print_status "Setup complete! You can now run the application."
echo
echo "To run the application:"
echo " source $VENV_NAME/bin/activate"
echo " $0 demo"
;;
"install")
print_status "Installing dependencies..."
source "$VENV_NAME/bin/activate" 2>/dev/null || setup_venv
install_dependencies
;;
"test")
print_status "Running tests..."
source "$VENV_NAME/bin/activate"
run_tests
;;
"demo"|"benchmark"|"interactive"|"default")
print_status "Running application in ${1:-default} mode..."
source "$VENV_NAME/bin/activate"
run_application "$1"
;;
"clean")
cleanup
;;
"help"|"-h"|"--help")
show_help
;;
*)
print_error "Unknown option: $1"
show_help
exit 1
;;
esac
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi

Xet Storage Details

Size:
10.8 kB
·
Xet hash:
ee35008a526178818925b252502fa10f53b35304cadc92bcb72f101240a5535a

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.