tahamajs's picture
download
raw
8.36 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_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_DIR="$PROJECT_ROOT/src"
EXAMPLES_DIR="$PROJECT_ROOT/examples"
TESTS_DIR="$PROJECT_ROOT/tests"
RESULTS_DIR="$PROJECT_ROOT/results"
VISUALIZATIONS_DIR="$PROJECT_ROOT/visualizations"
mkdir -p "$RESULTS_DIR/logs"
mkdir -p "$RESULTS_DIR/data"
mkdir -p "$RESULTS_DIR/plots"
mkdir -p "$VISUALIZATIONS_DIR"
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo -e "${PURPLE}================================${NC}"
echo -e "${PURPLE}$1${NC}"
echo -e "${PURPLE}================================${NC}"
}
check_python() {
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
else
print_error "Python is not installed or not in PATH"
exit 1
fi
print_success "Using Python: $($PYTHON_CMD --version)"
}
install_dependencies() {
print_header "Installing Dependencies"
if [ -f "$PROJECT_ROOT/requirements.txt" ]; then
print_status "Installing requirements from requirements.txt"
$PYTHON_CMD -m pip install -r "$PROJECT_ROOT/requirements.txt"
print_success "Dependencies installed successfully"
else
print_warning "requirements.txt not found, skipping dependency installation"
fi
}
run_tests() {
print_header "Running Unit Tests"
if [ -d "$TESTS_DIR" ] && [ -f "$TESTS_DIR/test_tot.py" ]; then
print_status "Running Tree of Thought unit tests..."
cd "$PROJECT_ROOT"
$PYTHON_CMD -m pytest "$TESTS_DIR/test_tot.py" -v --tb=short
if [ $? -eq 0 ]; then
print_success "All tests passed!"
else
print_error "Some tests failed!"
return 1
fi
else
print_warning "Test directory or test file not found, skipping tests"
fi
}
run_examples() {
print_header "Running Examples and Demonstrations"
if [ -d "$EXAMPLES_DIR" ] && [ -f "$EXAMPLES_DIR/demo.py" ]; then
print_status "Running Tree of Thought examples..."
cd "$PROJECT_ROOT"
export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH"
$PYTHON_CMD "$EXAMPLES_DIR/demo.py"
if [ $? -eq 0 ]; then
print_success "Examples completed successfully!"
else
print_error "Examples failed!"
return 1
fi
else
print_warning "Examples directory or demo file not found, skipping examples"
fi
}
run_notebook() {
print_header "Running Jupyter Notebook"
if [ -f "$PROJECT_ROOT/CA12.ipynb" ]; then
print_status "Converting and running Jupyter notebook..."
cd "$PROJECT_ROOT"
$PYTHON_CMD -m jupyter nbconvert --to python --execute CA12.ipynb --output-dir="$RESULTS_DIR"
if [ $? -eq 0 ]; then
print_success "Notebook executed successfully!"
else
print_error "Notebook execution failed!"
return 1
fi
else
print_warning "CA12.ipynb not found, skipping notebook execution"
fi
}
generate_report() {
print_header "Generating Comprehensive Report"
cd "$PROJECT_ROOT"
REPORT_FILE="$RESULTS_DIR/comprehensive_report.md"
cat > "$REPORT_FILE" << EOF
- **Date**: $(date)
- **Python Version**: $($PYTHON_CMD --version)
- **Project Root**: $PROJECT_ROOT
\`\`\`
$(tree -I '__pycache__|*.pyc|*.pyo|.git' -L 3)
\`\`\`
- **Tests**: $(if [ -d "$TESTS_DIR" ]; then echo "Available"; else echo "Not found"; fi)
- **Examples**: $(if [ -d "$EXAMPLES_DIR" ]; then echo "Available"; else echo "Not found"; fi)
- **Notebook**: $(if [ -f "$PROJECT_ROOT/CA12.ipynb" ]; then echo "Available"; else echo "Not found"; fi)
- **Visualizations**: $(if [ -d "$VISUALIZATIONS_DIR" ]; then echo "Generated in $VISUALIZATIONS_DIR"; else echo "Not generated"; fi)
$(find "$RESULTS_DIR" -type f -name "*.png" -o -name "*.html" -o -name "*.json" | head -20)
1. Review generated visualizations in $VISUALIZATIONS_DIR
2. Check execution logs in $RESULTS_DIR/logs
3. Analyze performance data in $RESULTS_DIR/data
4. Run specific examples or tests as needed
EOF
print_success "Comprehensive report generated: $REPORT_FILE"
}
cleanup() {
print_header "Cleaning Up"
find "$PROJECT_ROOT" -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find "$PROJECT_ROOT" -type f -name "*.pyc" -delete 2>/dev/null || true
find "$PROJECT_ROOT" -type f -name "*.pyo" -delete 2>/dev/null || true
print_success "Cleanup completed"
}
show_help() {
echo "Tree of Thought - Complete Execution Script"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -h, --help Show this help message"
echo " -t, --test Run only tests"
echo " -e, --examples Run only examples"
echo " -n, --notebook Run only notebook"
echo " -i, --install Install dependencies only"
echo " -c, --clean Clean up temporary files"
echo " -a, --all Run everything (default)"
echo " --no-cleanup Skip cleanup step"
echo ""
echo "Examples:"
echo " $0 # Run everything"
echo " $0 --test # Run only tests"
echo " $0 --examples # Run only examples"
echo " $0 --install # Install dependencies only"
}
main() {
print_header "Tree of Thought - Complete Execution"
print_status "Starting comprehensive Tree of Thought execution..."
RUN_TESTS=true
RUN_EXAMPLES=true
RUN_NOTEBOOK=true
INSTALL_DEPS=true
CLEANUP_FILES=true
while [[ $
case $1 in
-h|--help)
show_help
exit 0
;;
-t|--test)
RUN_TESTS=true
RUN_EXAMPLES=false
RUN_NOTEBOOK=false
INSTALL_DEPS=false
;;
-e|--examples)
RUN_TESTS=false
RUN_EXAMPLES=true
RUN_NOTEBOOK=false
INSTALL_DEPS=false
;;
-n|--notebook)
RUN_TESTS=false
RUN_EXAMPLES=false
RUN_NOTEBOOK=true
INSTALL_DEPS=false
;;
-i|--install)
RUN_TESTS=false
RUN_EXAMPLES=false
RUN_NOTEBOOK=false
INSTALL_DEPS=true
;;
-c|--clean)
RUN_TESTS=false
RUN_EXAMPLES=false
RUN_NOTEBOOK=false
INSTALL_DEPS=false
CLEANUP_FILES=true
;;
-a|--all)
RUN_TESTS=true
RUN_EXAMPLES=true
RUN_NOTEBOOK=true
INSTALL_DEPS=true
;;
--no-cleanup)
CLEANUP_FILES=false
;;
*)
print_error "Unknown option: $1"
show_help
exit 1
;;
esac
shift
done
check_python
if [ "$INSTALL_DEPS" = true ]; then
install_dependencies
fi
if [ "$RUN_TESTS" = true ]; then
run_tests
fi
if [ "$RUN_EXAMPLES" = true ]; then
run_examples
fi
if [ "$RUN_NOTEBOOK" = true ]; then
run_notebook
fi
generate_report
if [ "$CLEANUP_FILES" = true ]; then
cleanup
fi
print_header "Execution Complete"
print_success "Tree of Thought execution completed successfully!"
print_status "Check the following directories for results:"
echo " - Visualizations: $VISUALIZATIONS_DIR"
echo " - Results: $RESULTS_DIR"
echo " - Logs: $RESULTS_DIR/logs"
echo " - Data: $RESULTS_DIR/data"
echo " - Plots: $RESULTS_DIR/plots"
}
main "$@"

Xet Storage Details

Size:
8.36 kB
·
Xet hash:
b132ccb9f556870b37318e898a7055eef330fcbf53f2892ea7d1fcece356f0a1

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