LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
fix: Lock file script changes to fail fast (#774)
Chandrasekharan M887dfde0292a
diff --git a/.github/workflows/pdm-lock-automation.yaml b/.github/workflows/pdm-lock-automation.yamlindex bd65e5546..38c54273e 100644--- a/.github/workflows/pdm-lock-automation.yaml+++ b/.github/workflows/pdm-lock-automation.yaml@@ -57,7 +57,7 @@ jobs:IFS=',' read -r -a dir_array <<< "$dirs"# Print directories being processed- echo "Processing specified directories: ${dir_array[@]}"+ echo "Processing specified directories: ${dir_array[*]}"# Pass directories as command-line arguments to the script./scripts/pdm-lock.sh "${dir_array[@]}"diff --git a/scripts/pdm-lock.sh b/scripts/pdm-lock.shindex 8cdfcc964..2460ef0be 100755--- a/scripts/pdm-lock.sh+++ b/scripts/pdm-lock.sh@@ -1,4 +1,5 @@#!/bin/bash+set -o pipefail# Function to update the lockfile in a directoryupdate_lockfile() {@@ -6,52 +7,65 @@ update_lockfile() {file_path="$dir/pyproject.toml"if [[ ! -f "$file_path" ]]; then- echo "[$dir] No pyproject.toml found in $dir"- return+ echo "[$dir] No pyproject.toml found in '$dir'"+ return 0fi- echo "[$dir] Checking $file_path for changes against origin/main..."+ echo "[$dir] Checking '$file_path' for changes against origin/main..."if ! git diff --quiet origin/main -- "$file_path"; then- echo "[$dir] Changes detected in $file_path, updating pdm.lock for $dir ..."+ echo "[$dir] Changes detected in '$file_path', updating pdm.lock for '$dir' ..."# Move to the directory if it's not rootif [[ "$dir" != "." ]]; then- cd "$dir"+ cd "$dir" || return 1fi# Set up virtual environment if not existsif [[ ! -d ".venv" ]]; then- echo "[$dir] Creating virtual environment in directory: $dir"- pdm venv create -w virtualenv --with-pip+ echo "[$dir] Creating virtual environment in directory: '$dir'"+ pdm venv create -w virtualenv --with-pip 2>&1 | sed "s|^|[$dir] |" || return 1elseecho "[$dir] Virtual environment already exists in $dir"fi# Activate virtual environment- source .venv/bin/activate+ source .venv/bin/activate 2>&1 | sed "s|^|[$dir] |" || return 1# HACK: https://github.com/pdm-project/pdm/issues/3199# Replace with checking the exit code directly once above issue is fixedlock_output=$(pdm lock --check 2>&1)if echo "$lock_output" | grep -q "WARNING: Lockfile is generated on an older version of PDM"; then- echo "[$dir] Updating pdm.lock in $dir due to outdated version..."- pdm lock -G :all -v 2>&1 | sed "s/^/[$dir] /"+ echo "[$dir] Updating pdm.lock in '$dir' due to outdated version..."+ pdm lock -G :all -v 2>&1 | sed "s|^|[$dir] |" || return 1elif [[ $? -ne 0 ]]; then- echo "[$dir] Updating pdm.lock in $dir due to detected changes..."- pdm lock -G :all -v 2>&1 | sed "s/^/[$dir] /"+ echo "[$dir] Updating pdm.lock in '$dir' due to detected changes..."+ pdm lock -G :all -v 2>&1 | sed "s|^|[$dir] |" || return 1else- echo "[$dir] No changes required for pdm.lock in $dir."+ echo "[$dir] No changes required for pdm.lock in '$dir'."fi# Go back to root if moved to a subdirectoryif [[ "$dir" != "." ]]; then- cd -+ cd - || return 1fielse- echo "[$dir] No changes detected in $file_path"+ echo "[$dir] No changes detected in '$file_path'"fi}+# https://unix.stackexchange.com/a/124148+# Used to list child processes to kill them in case of an error+list_descendants ()+{+ local children=$(ps -o pid= --ppid "$1")++ for pid in $children+ do+ list_descendants "$pid"+ done++ echo "$children"+}# Default directories listdirectories=(@@ -75,11 +89,28 @@ fi# To compare against main branchgit fetch origin main+# Array to store the job PIDs and directories+pids=()+dirs=()# Run lockfile updates in parallelfor dir in "${directories[@]}"; doupdate_lockfile "$dir" &+ pid=$!+ pids+=($pid) # Add the PID of the background job to the array+ dirs+=("$dir") # Add the corresponding directory to the arraydone-# Wait for all background processes to complete-wait+# Wait for each background process to complete, exit on the first failure+for i in "${!pids[@]}"; do+ pid=${pids[$i]}+ dir=${dirs[$i]}+ echo "[$dir] Waiting for child process with PID: $pid..."++ # # Wait for the specific process to finish+ if ! wait "$pid"; then+ echo "[$dir] Lock file generation failed. Killing other sub-processes..."+ kill $(list_descendants $$) 2>/dev/null || true+ exit 1+ fi+done