Skip to content

Commit e75a1be

Browse files
authored
Merge pull request #3514 from jsiirola/conda-timeout-update
Be more careful when/how we timeout conda install
2 parents a1cf555 + 7db69d7 commit e75a1be

File tree

2 files changed

+62
-32
lines changed

2 files changed

+62
-32
lines changed

.github/workflows/test_branches.yml

+31-16
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,21 @@ jobs:
304304
# Set up environment
305305
conda config --set always_yes yes
306306
conda config --set auto_update_conda false
307+
conda config --set channel_priority strict
307308
conda config --remove channels defaults
308309
conda config --append channels nodefaults
309310
conda config --append channels conda-forge
310311
# Try to install mamba
311-
# Note: removed '--update-deps' on 2025-02-28 to work around
312-
# broken libffi(?)
313-
conda install -q -y -n base conda-libmamba-solver \
314-
|| MAMBA_FAILED=1
315-
if test -z "$MAMBA_FAILED"; then
316-
echo "*** Activating the mamba environment solver ***"
317-
conda config --set solver libmamba
312+
CONDA_VER=$(conda --version | cut -d\ -f2)
313+
if test 23.10 = "`echo -e "23.10\n$CONDA_VER" | sort -V | tail -1`"; then
314+
# Note: removed '--update-deps' on 2025-02-28 to work around
315+
# broken libffi(?)
316+
conda install -q -y -n base conda-libmamba-solver \
317+
|| MAMBA_FAILED=1
318+
if test -z "$MAMBA_FAILED"; then
319+
echo "*** Activating the mamba environment solver ***"
320+
conda config --set solver libmamba
321+
fi
318322
fi
319323
# Add the rest of the channels
320324
conda config --append channels gurobi
@@ -366,17 +370,19 @@ jobs:
366370
# possibly if it outputs messages to stderr)
367371
conda install --update-deps -q -y $CONDA_DEPENDENCIES
368372
if test -z "${{matrix.slim}}"; then
369-
# xpress.init() (from conda) hangs indefinitely on GHA/Windows under
370-
# Python 3.10 and 3.11. Exclude that release on that platform.
373+
# xpress.init() (xpress 9.5.1 from conda) hangs indefinitely
374+
# on GHA/Windows under Python 3.10 and 3.11. Exclude that
375+
# release on that platform.
371376
if [[ ${{matrix.TARGET}} == win && ${{matrix.python}} =~ 3.1[01] ]]; then
372377
# We would like to just use something like:
373378
# - "!=9.5.1" (conda errors)
374379
# - "<9.5.1|>9.5.1" (conda installs 9.1.2, which also hangs)
375380
# - "<=9.5.0|>9.5.1" (conda seg faults)
376-
XPRESS='xpress=9.5.0'
381+
XPRESS='xpress>=9.5.2'
377382
else
378383
XPRESS='xpress'
379384
fi
385+
TIMEOUT_MSG="TIMEOUT: killing conda install process"
380386
PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g')
381387
echo "Installing for $PYVER"
382388
for PKG in 'cplex>=12.10' docplex gurobi "$XPRESS" cyipopt pymumps scip; do
@@ -405,13 +411,22 @@ jobs:
405411
# indefinitely (lately while installing SCIP),
406412
# we will run "conda install" in a subshell and
407413
# kill it after 5-minutes.
408-
(conda install -q -y $PKG) &
409-
conda_pid=$!
410-
(sleep 300 && kill "$conda_pid" 2>/dev/null) &
414+
(conda install -q -y $PKG |& tee conda.log) &
415+
conda_subshell_pid=$!
416+
sleep 1
417+
conda_pid=$(ps | grep conda | sed 's/^ *//' | sed 's/ .*//')
418+
# Only timeout the conda process if it's not to
419+
# the installation phase yet. Signalling conda
420+
# after it has started the installation process
421+
# can irrecoverably corrupt the environment.
422+
(sleep 300 \
423+
&& if test `grep 'Package Plan' conda.log | wc -l` -eq 0; \
424+
then echo "$TIMEOUT_MSG $conda_pid (TERM)" \
425+
&& kill -TERM $conda_pid 2>/dev/null ; fi) &
411426
timeout_pid=$!
412-
wait "$conda_pid" || _BUILDS=""
413-
kill "$timeout_pid" 2>/dev/null \
414-
|| echo "TIMEOUT: killed conda install process"
427+
wait $conda_subshell_pid || _BUILDS=""
428+
kill $timeout_pid 2>/dev/null \
429+
|| echo "TIMEOUT: time limit expired"
415430
fi
416431
fi
417432
echo ""

.github/workflows/test_pr_and_main.yml

+31-16
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,21 @@ jobs:
341341
# Set up environment
342342
conda config --set always_yes yes
343343
conda config --set auto_update_conda false
344+
conda config --set channel_priority strict
344345
conda config --remove channels defaults
345346
conda config --append channels nodefaults
346347
conda config --append channels conda-forge
347348
# Try to install mamba
348-
# Note: removed '--update-deps' on 2025-02-28 to work around
349-
# broken libffi(?)
350-
conda install -q -y -n base conda-libmamba-solver \
351-
|| MAMBA_FAILED=1
352-
if test -z "$MAMBA_FAILED"; then
353-
echo "*** Activating the mamba environment solver ***"
354-
conda config --set solver libmamba
349+
CONDA_VER=$(conda --version | cut -d\ -f2)
350+
if test 23.10 = "`echo -e "23.10\n$CONDA_VER" | sort -V | tail -1`"; then
351+
# Note: removed '--update-deps' on 2025-02-28 to work around
352+
# broken libffi(?)
353+
conda install -q -y -n base conda-libmamba-solver \
354+
|| MAMBA_FAILED=1
355+
if test -z "$MAMBA_FAILED"; then
356+
echo "*** Activating the mamba environment solver ***"
357+
conda config --set solver libmamba
358+
fi
355359
fi
356360
# Add the rest of the channels
357361
conda config --append channels gurobi
@@ -403,17 +407,19 @@ jobs:
403407
# possibly if it outputs messages to stderr)
404408
conda install --update-deps -q -y $CONDA_DEPENDENCIES
405409
if test -z "${{matrix.slim}}"; then
406-
# xpress.init() (from conda) hangs indefinitely on GHA/Windows under
407-
# Python 3.10 and 3.11. Exclude that release on that platform.
410+
# xpress.init() (xpress 9.5.1 from conda) hangs indefinitely
411+
# on GHA/Windows under Python 3.10 and 3.11. Exclude that
412+
# release on that platform.
408413
if [[ ${{matrix.TARGET}} == win && ${{matrix.python}} =~ 3.1[01] ]]; then
409414
# We would like to just use something like:
410415
# - "!=9.5.1" (conda errors)
411416
# - "<9.5.1|>9.5.1" (conda installs 9.1.2, which also hangs)
412417
# - "<=9.5.0|>9.5.1" (conda seg faults)
413-
XPRESS='xpress=9.5.0'
418+
XPRESS='xpress>=9.5.2'
414419
else
415420
XPRESS='xpress'
416421
fi
422+
TIMEOUT_MSG="TIMEOUT: killing conda install process"
417423
PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g')
418424
echo "Installing for $PYVER"
419425
for PKG in 'cplex>=12.10' docplex gurobi "$XPRESS" cyipopt pymumps scip; do
@@ -442,13 +448,22 @@ jobs:
442448
# indefinitely (lately while installing SCIP),
443449
# we will run "conda install" in a subshell and
444450
# kill it after 5-minutes.
445-
(conda install -q -y $PKG) &
446-
conda_pid=$!
447-
(sleep 300 && kill "$conda_pid" 2>/dev/null) &
451+
(conda install -q -y $PKG |& tee conda.log) &
452+
conda_subshell_pid=$!
453+
sleep 1
454+
conda_pid=$(ps | grep conda | sed 's/^ *//' | sed 's/ .*//')
455+
# Only timeout the conda process if it's not to
456+
# the installation phase yet. Signalling conda
457+
# after it has started the installation process
458+
# can irrecoverably corrupt the environment.
459+
(sleep 300 \
460+
&& if test `grep 'Package Plan' conda.log | wc -l` -eq 0; \
461+
then echo "$TIMEOUT_MSG $conda_pid (TERM)" \
462+
&& kill -TERM $conda_pid 2>/dev/null ; fi) &
448463
timeout_pid=$!
449-
wait "$conda_pid" || _BUILDS=""
450-
kill "$timeout_pid" 2>/dev/null \
451-
|| echo "TIMEOUT: killed conda install process"
464+
wait $conda_subshell_pid || _BUILDS=""
465+
kill $timeout_pid 2>/dev/null \
466+
|| echo "TIMEOUT: time limit expired"
452467
fi
453468
fi
454469
echo ""

0 commit comments

Comments
 (0)