@@ -896,8 +896,20 @@ tasks:
896896 cmds :
897897 - echo "Running application tests against MLflow on localhost:{{.PORT}}..."
898898 - |
899- echo "Installing Python dependencies from requirements.txt..."
900- pip3 install -r {{.TESTS_DIR}}/requirements.txt
899+ # Check if running inside a virtual environment already
900+ if [ -z "$VIRTUAL_ENV" ]; then
901+ echo "Installing Python dependencies directly..."
902+ # Try to use binary wheels whenever possible
903+ python -m pip install --upgrade pip wheel setuptools
904+ # Install the required packages directly
905+ python -m pip install mlflow numpy pandas scikit-learn pytest requests || {
906+ echo "❌ Failed to install dependencies. Trying with --only-binary approach..."
907+ # Try installing packages that commonly have build issues with binary-only
908+ python -m pip install --only-binary=numpy,pandas,pyarrow,scikit-learn mlflow numpy pandas scikit-learn pytest requests
909+ }
910+ else
911+ echo "Running in virtual environment $VIRTUAL_ENV, skipping dependency installation"
912+ fi
901913
902914 echo "Running MLflow application tests"
903915 python {{.TESTS_DIR}}/mlflow_test.py localhost:{{.PORT}} \
@@ -913,6 +925,98 @@ tasks:
913925 - echo "All tests completed successfully"
914926 - task : cleanup:port:forward
915927
928+ # Alternative test task with venv
929+ run:tests:app:venv :
930+ desc : Run application tests using a virtual environment for better isolation
931+ cmds :
932+ - echo "Running application tests in a virtual environment..."
933+ - |
934+ # Set up test env directory
935+ TEST_ENV_DIR="{{.TESTS_DIR}}/.venv"
936+
937+ # Clean up any existing venv if requested
938+ if [ "${CLEAN_VENV:-no}" = "yes" ]; then
939+ echo "Cleaning up existing virtual environment..."
940+ rm -rf "$TEST_ENV_DIR"
941+ fi
942+
943+ # Create virtual environment if it doesn't exist
944+ if [ ! -d "$TEST_ENV_DIR" ]; then
945+ echo "Setting up new virtual environment..."
946+ python -m venv "$TEST_ENV_DIR"
947+ fi
948+
949+ # Determine the correct activation script based on shell
950+ if [ -f "$TEST_ENV_DIR/bin/activate" ]; then
951+ ACTIVATE_SCRIPT="$TEST_ENV_DIR/bin/activate"
952+ elif [ -f "$TEST_ENV_DIR/Scripts/activate" ]; then
953+ ACTIVATE_SCRIPT="$TEST_ENV_DIR/Scripts/activate"
954+ else
955+ echo "❌ Unable to find activation script for virtual environment"
956+ exit 1
957+ fi
958+
959+ # Create a temporary script to run in the activated environment
960+ TMP_SCRIPT=$(mktemp)
961+ cat > "$TMP_SCRIPT" << 'EOF'
962+ set -e
963+ echo "Using Python: $(which python)"
964+ echo "Python version: $(python --version)"
965+ echo "Upgrading pip, setuptools, and wheel..."
966+ python -m pip install --upgrade pip setuptools wheel
967+
968+ echo "Installing dependencies with retry..."
969+ MAX_RETRIES=2
970+ RETRY_COUNT=0
971+ SUCCESS=false
972+
973+ while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ "$SUCCESS" != "true" ]; do
974+ RETRY_COUNT=$((RETRY_COUNT + 1))
975+ echo "Attempt $RETRY_COUNT/$MAX_RETRIES: Installing dependencies..."
976+
977+ if python -m pip install --no-cache-dir -r ./tests/requirements.txt; then
978+ SUCCESS=true
979+ else
980+ echo "Installation failed, trying with binary-only approach..."
981+ if python -m pip install --only-binary=:all: -r ./tests/requirements.txt; then
982+ SUCCESS=true
983+ else
984+ echo "Binary-only installation failed too."
985+ if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
986+ echo "Will retry in 5 seconds..."
987+ sleep 5
988+ fi
989+ fi
990+ fi
991+ done
992+
993+ if [ "$SUCCESS" != "true" ]; then
994+ echo "❌ Failed to install dependencies after $MAX_RETRIES attempts"
995+ exit 1
996+ fi
997+
998+ echo "Running MLflow application tests"
999+ python ./tests/mlflow_test.py localhost:5000 --protocol http --connection-timeout 180 --debug
1000+ EOF
1001+
1002+ # Make the script executable
1003+ chmod +x "$TMP_SCRIPT"
1004+
1005+ # Run the script within the activated environment
1006+ echo "Activating virtual environment and running tests..."
1007+ source "$ACTIVATE_SCRIPT" && bash "$TMP_SCRIPT"
1008+
1009+ # Clean up
1010+ rm -f "$TMP_SCRIPT"
1011+
1012+ # Task to clean the virtual environment
1013+ clean:venv :
1014+ desc : Clean up the Python virtual environment used for testing
1015+ cmds :
1016+ - echo "Cleaning up Python virtual environment..."
1017+ - rm -rf "{{.TESTS_DIR}}/.venv"
1018+ - echo "✅ Python virtual environment cleaned"
1019+
9161020 # Documentation generation tasks
9171021 docs:helm:generate :
9181022 desc : Generate Helm chart documentation from templates
0 commit comments