Skip to content

Commit a08b6d4

Browse files
committed
revert using requirements
1 parent 6c88bb1 commit a08b6d4

File tree

3 files changed

+149
-13
lines changed

3 files changed

+149
-13
lines changed

.github/workflows/mlflow-ci.yml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ jobs:
3737
version: v3.13.3
3838

3939
- name: Set up Python
40-
uses: actions/setup-python@v5
40+
uses: actions/setup-python@v4
4141
with:
42-
python-version: '3.13'
42+
python-version: 3.12
43+
cache: 'pip'
44+
cache-dependency-path: applications/mlflow/tests/requirements.txt
4345

4446
- name: Install Task
4547
uses: arduino/setup-task@v1
@@ -232,9 +234,11 @@ jobs:
232234
version: v3.13.3
233235

234236
- name: Set up Python
235-
uses: actions/setup-python@v5
237+
uses: actions/setup-python@v4
236238
with:
237-
python-version: '3.13'
239+
python-version: 3.12
240+
cache: 'pip'
241+
cache-dependency-path: applications/mlflow/tests/requirements.txt
238242

239243
- name: Install Task
240244
uses: arduino/setup-task@v1
@@ -326,7 +330,18 @@ jobs:
326330
- name: Run Application Tests
327331
working-directory: applications/mlflow
328332
run: |
329-
# Run task to test application
333+
# Create Python virtual environment
334+
python -m venv ./venv
335+
source ./venv/bin/activate
336+
337+
# Install dependencies with fallback to binary-only
338+
python -m pip install --upgrade pip wheel setuptools
339+
python -m pip install --no-cache-dir -r tests/requirements.txt || {
340+
echo "Regular installation failed, trying with binary-only approach..."
341+
python -m pip install --only-binary=:all: -r tests/requirements.txt
342+
}
343+
344+
# Run tests
330345
task run:tests:app
331346
env:
332347
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
@@ -380,9 +395,11 @@ jobs:
380395
fetch-depth: 0
381396

382397
- name: Set up Python
383-
uses: actions/setup-python@v5
398+
uses: actions/setup-python@v4
384399
with:
385-
python-version: '3.13.3'
400+
python-version: 3.12
401+
cache: 'pip'
402+
cache-dependency-path: applications/mlflow/tests/requirements.txt
386403

387404
- name: Install Task
388405
uses: arduino/setup-task@v1
@@ -584,11 +601,21 @@ jobs:
584601
env:
585602
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
586603

587-
# Application testing with our consolidated test file
588604
- name: Run Application Tests
589605
working-directory: applications/mlflow
590606
run: |
591-
# Run task to test application
607+
# Create Python virtual environment
608+
python -m venv ./venv
609+
source ./venv/bin/activate
610+
611+
# Install dependencies with fallback to binary-only
612+
python -m pip install --upgrade pip wheel setuptools
613+
python -m pip install --no-cache-dir -r tests/requirements.txt || {
614+
echo "Regular installation failed, trying with binary-only approach..."
615+
python -m pip install --only-binary=:all: -r tests/requirements.txt
616+
}
617+
618+
# Run tests
592619
task run:tests:app
593620
env:
594621
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}

applications/mlflow/Taskfile.yml

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
setuptools>=65.0.0
2+
wheel>=0.40.0
23
mlflow==2.11.0
3-
pandas>=2.0.0
4-
scikit-learn>=1.3.0
4+
# Pre-built wheels for problematic packages
5+
numpy<2.0.0
6+
pandas<2.2.0
7+
scikit-learn<1.4.0
8+
# Pin pyarrow to a version with pre-built wheels
9+
pyarrow==15.0.0
510
requests>=2.31.0
611
urllib3>=2.0.0

0 commit comments

Comments
 (0)