Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions ci/run_single_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,26 @@ case ${TEST_TYPE} in
echo "Could not find baseline commit for ${TARGET_BRANCH:-main}. Skipping baseline generation."
fi
fi
# Run pip install and capture output to inspect for python compatibility issues
pip_output=$(pip install -e . 2>&1)
pip_retval=$?

pip install -e .

if [ ${pip_retval} -ne 0 ]; then
echo "${pip_output}"
if echo "${pip_output}" | grep -q "requires a different Python"; then
echo "WARNING: Package ${PACKAGE_NAME} is not compatible with Python ${PY_VERSION}. Skipping import profiler."
deactivate
rm -rf .venv-profiler
rm -rf "${PROFILER_TEMP_DIR}"
exit 0
else
echo "ERROR: Failed to install package ${PACKAGE_NAME}."
deactivate
rm -rf .venv-profiler
rm -rf "${PROFILER_TEMP_DIR}"
exit ${pip_retval}
fi
fi
Comment on lines +142 to +157

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cleanup logic (deactivate and removing temporary directories) is duplicated in both branches of the conditional check. This can be simplified by performing the cleanup immediately after printing the pip output, before checking the specific error message.

Suggested change
if [ ${pip_retval} -ne 0 ]; then
echo "${pip_output}"
if echo "${pip_output}" | grep -q "requires a different Python"; then
echo "WARNING: Package ${PACKAGE_NAME} is not compatible with Python ${PY_VERSION}. Skipping import profiler."
deactivate
rm -rf .venv-profiler
rm -rf "${PROFILER_TEMP_DIR}"
exit 0
else
echo "ERROR: Failed to install package ${PACKAGE_NAME}."
deactivate
rm -rf .venv-profiler
rm -rf "${PROFILER_TEMP_DIR}"
exit ${pip_retval}
fi
fi
if [ ${pip_retval} -ne 0 ]; then
echo "${pip_output}"
deactivate
rm -rf .venv-profiler
rm -rf "${PROFILER_TEMP_DIR}"
if echo "${pip_output}" | grep -q "requires a different Python"; then
echo "WARNING: Package ${PACKAGE_NAME} is not compatible with Python ${PY_VERSION}. Skipping import profiler."
exit 0
else
echo "ERROR: Failed to install package ${PACKAGE_NAME}."
exit ${pip_retval}
fi
fi

if [ -f "${BASELINE_CSV}" ]; then
python ${PROFILER_SCRIPT} --package ${PACKAGE_NAME} --iterations 11 --fail-threshold 5000 --diff-baseline "${BASELINE_CSV}" --diff-threshold 100
else
Expand Down
Loading