From b46ff030f38f3ff4352cb30fcc54c32e02536818 Mon Sep 17 00:00:00 2001 From: Dries Schaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:07:56 +0200 Subject: [PATCH] Build nextflow schemas and params with viash 0.9 (#41) --- CHANGELOG.md | 6 +++++ pro/build-nextflow-params/action.yml | 33 +++++++++++++++++++-------- pro/build-nextflow-schemas/action.yml | 30 +++++++++++++++++++----- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f5a6e..cf3f082 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# viash-actions v6.5.0 + +## New functionality + +* `build-nextflow-params` and `build-nextflow-schemas`: allow using viash versions starting from `0.9.0` (PR #41). + # viash-actions v6.4.0 ## New functionality diff --git a/pro/build-nextflow-params/action.yml b/pro/build-nextflow-params/action.yml index 4897155..4afbe3b 100644 --- a/pro/build-nextflow-params/action.yml +++ b/pro/build-nextflow-params/action.yml @@ -56,16 +56,31 @@ runs: TARGET_DIR="${{ steps.defaults.outputs.target_dir }}" - BUILT_CONFIGS=$(find "$TARGET_DIR" -name .config.vsh.yaml) + readarray -d '' BUILT_CONFIGS < <(find "$TARGET_DIR" -name .config.vsh.yaml -print0) echo "Detected configs:" - echo "$BUILT_CONFIGS" + printf "%s\n" "${BUILT_CONFIGS[@]}" echo - - NEXTFLOW_PARAMS=$(echo "$BUILT_CONFIGS" | sed 's/.config.vsh.yaml/nextflow_params.yaml/g') + NEXTFLOW_PARAMS=() + for config_path in "${BUILT_CONFIGS[@]}"; do + dir=$(dirname "$config_path") + NEXTFLOW_PARAMS+=("$dir/nextflow_params.yaml") + done echo "Building Nextflow param files:" - echo "$NEXTFLOW_PARAMS" + printf "%s\n" "${NEXTFLOW_PARAMS[@]}" echo - - viash_tools/target/docker/nextflow/generate_params/generate_params \ - --input $(echo "$BUILT_CONFIGS" | paste -sd ";") \ - --output $(echo "$NEXTFLOW_PARAMS" | paste -sd ";") + + VIASH_VERSION=`viash -v | grep -oP 'viash \K[0-9.]+'` + IFS=. read -r major minor patch <<< $VIASH_VERSION + JOINED_CONFIGS=$(IFS=';'; printf '%s' "${BUILT_CONFIGS[*]}") + JOINED_PARAMS=$(IFS=';'; printf '%s' "${NEXTFLOW_PARAMS[*]}") + if (( "$major" > 0 )) || (( "$minor" >= 9 )); then + VIASH_VERSION_LONG=$(viash -v | grep -oP 'viash \K[0-9.]+.\w+') + viash_tools/target/docker/nextflow/generate_params_v9/generate_params_v9 \ + --input "$JOINED_CONFIGS" \ + --output "$JOINED_PARAMS" \ + --viash_version $VIASH_VERSION_LONG + else + viash_tools/target/docker/nextflow/generate_params/generate_params \ + --input "$JOINED_CONFIGS" \ + --output "$JOINED_PARAMS" + fi diff --git a/pro/build-nextflow-schemas/action.yml b/pro/build-nextflow-schemas/action.yml index c9a8ab4..5e91436 100644 --- a/pro/build-nextflow-schemas/action.yml +++ b/pro/build-nextflow-schemas/action.yml @@ -60,17 +60,35 @@ runs: TARGET_DIR="${{ steps.defaults.outputs.target_dir }}" - BUILT_CONFIGS=$(find "$TARGET_DIR" -name .config.vsh.yaml) + readarray -d '' BUILT_CONFIGS < <(find "$TARGET_DIR" -name .config.vsh.yaml -print0) echo "Detected configs:" - echo "$BUILT_CONFIGS" + printf "%s\n" "${BUILT_CONFIGS[@]}" echo + NEXTFLOW_SCHEMAS=() + for config_path in "${BUILT_CONFIGS[@]}"; do + dir=$(dirname "$config_path") + NEXTFLOW_SCHEMAS+=("$dir/nextflow_schema.json") + done + NEXTFLOW_SCHEMAS=$(echo "$BUILT_CONFIGS" | sed 's/.config.vsh.yaml/nextflow_schema.json/g') echo "Building Nextflow schema files:" - echo "$NEXTFLOW_SCHEMAS" + printf "%s\n" "${NEXTFLOW_SCHEMAS[@]}" echo - viash_tools/target/docker/nextflow/generate_schema/generate_schema \ - --input "$(echo "$BUILT_CONFIGS" | paste -sd ";")" \ - --output "$(echo "$NEXTFLOW_SCHEMAS" | paste -sd ";")" \ + VIASH_VERSION=`viash -v | grep -oP 'viash \K[0-9.]+'` + IFS=. read -r major minor patch <<< $VIASH_VERSION + JOINED_CONFIGS=$(IFS=';'; printf '%s' "${BUILT_CONFIGS[*]}") + JOINED_SCHEMAS=$(IFS=';'; printf '%s' "${NEXTFLOW_SCHEMAS[*]}") + if (( "$major" > 0 )) || (( "$minor" >= 9 )); then + viash_tools/target/docker/nextflow/generate_schema_v9/generate_schema_v9 \ + --input "$JOINED_CONFIGS" \ + --output "$JOINED_SCHEMAS" \ + $([[ "${{ inputs.enable_dataset_input }}" == "true" ]] && echo "--enable_dataset_input") + else + viash_tools/target/docker/nextflow/generate_schema/generate_schema \ + --input "$JOINED_CONFIGS" \ + --output "$JOINED_SCHEMAS" \ $([[ "${{ inputs.enable_dataset_input }}" == "true" ]] && echo "--enable_dataset_input") + fi +