From 2059c7d05ea686642054a961dc39f80f771b4f4d Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 30 May 2024 22:49:59 -0700 Subject: [PATCH] fix: start script --- start.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/start.sh b/start.sh index 8e7a70a..bc21188 100755 --- a/start.sh +++ b/start.sh @@ -54,17 +54,20 @@ download_pipelines() { # Function to parse and install requirements from frontmatter install_frontmatter_requirements() { local file=$1 - - echo "Checking $file for requirements in frontmatter..." - - # Extract the frontmatter if it exists - frontmatter=$(sed -n '/^---$/,/^---$/p' "$file") - - if echo "$frontmatter" | grep -q "requirements:"; then - # Extract lines starting from "requirements:" to the end of the block or until another top-level key is found - requirements=$(echo "$frontmatter" | sed -n '/^requirements:/,/^[a-zA-Z\-]*:/p' | sed -e '1d' -e '$d' | tr -d ',\n') - requirements=$(echo "$requirements" | awk '{$1=$1};1') - echo "Installing requirements: $requirements" + local file_content=$(cat "$1") + # Extract the first triple-quoted block + local first_block=$(echo "$file_content" | awk '/"""/{flag=!flag; if(flag) count++; if(count == 2) {exit}} flag' ) + + # Check if the block contains requirements + local requirements=$(echo "$first_block" | grep -i 'requirements:') + + if [ -n "$requirements" ]; then + # Extract the requirements list + requirements=$(echo "$requirements" | awk -F': ' '{print $2}' | tr ',' ' ' | tr -d '\r') + + # Construct and echo the pip install command + local pip_command="pip install $requirements" + echo "$pip_command" pip install $requirements else echo "No requirements found in frontmatter of $file." @@ -72,6 +75,7 @@ install_frontmatter_requirements() { } + # Check if PIPELINES_URLS environment variable is set and non-empty if [[ -n "$PIPELINES_URLS" ]]; then pipelines_dir="./pipelines"