From 5ad4a5a4a806ff41e279ee10a075d0ee600cac7a Mon Sep 17 00:00:00 2001 From: Ilya Trushkin Date: Mon, 26 Feb 2024 08:33:10 +0200 Subject: [PATCH] Improve clarity and efficiency in "pip conflicts check" workflow (#1731) - [x] Identify missing `%pip install` commands in notebooks with clear error messages - [x] Reduce `pip install` output for cleaner analysis --------- Signed-off-by: Ilya Trushkin Co-authored-by: Artur Paniukov --- .ci/pip_conflicts_check.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.ci/pip_conflicts_check.sh b/.ci/pip_conflicts_check.sh index 97a22040464..f7a8b542e60 100644 --- a/.ci/pip_conflicts_check.sh +++ b/.ci/pip_conflicts_check.sh @@ -36,8 +36,12 @@ find "$(pwd)" -type f -name "*.ipynb" -exec realpath --relative-to="$(pwd)" {} + # Convert to Python script first to flatten multi-line commands output=$(jupyter nbconvert --no-prompt --to script --stdout "$file") - matched=$(grep -Po "$PARSER_REGEX" <<< "$output" || { echo "No %pip install line found in $file"; exit 1; }) - + matched=$(grep -Po "$PARSER_REGEX" <<< "$output" || true) + if [ -z "$matched" ]; then + echo "ERROR: No '%pip install' command found in $file" + exit 1 + fi + while IFS= read -r line; do index_url=$(grep -Po "(--index-url \S+)" <<< "$line" || true) extra_index_url=$(grep -Po "(--extra-index-url \S+)" <<< "$line" || true) @@ -63,4 +67,4 @@ find "$(pwd)" -type f -name "*.ipynb" -exec realpath --relative-to="$(pwd)" {} + echo "-r ${req_file_name##*/}" >> "$REQ_FILE" # add partial requirements to the main file done echo "Checking requirements..." -python -m pip install -vvv -r $REQ_FILE --dry-run --ignore-installed \ No newline at end of file +python -m pip install -r $REQ_FILE --dry-run --ignore-installed