Skip to content
Snippets Groups Projects
Commit fd238cc7 authored by Holger Brendebach's avatar Holger Brendebach
Browse files

moved pipeline_wrapper_sh to new function; new flags --deployment and --analysis

parent 9ccb87f0
Branches
No related tags found
No related merge requests found
......@@ -18,8 +18,10 @@ ${bold}Description:${normal}
Deploy all pipelines in the scope of the BfR-ABC-Harmonization repository
${bold}Optional Named Arguments:${normal}
-d, --deploy_paths Override deploy base path (default: <git_parent_dir> from paths.cfg)
-a, --auto Do not ask for interactive confirmation, e.g. for automated deployments
-d, --deployment Deploy BfR-ABC pipelines to <deploy_path>
-a, --analysis Analyse BfR-ABC pipelines test datasets
-p, --deploy_path Override deploy base path (default: <git_parent_dir> from paths.cfg)
--auto Do not ask for interactive confirmation, e.g. for automated deployments
--imeanit Do not perform a dryrun
${bold}Example:${normal}
......@@ -35,10 +37,12 @@ parse_args() {
## default values of variables
repo_path=$(dirname "$script_path")
args_git_parent_dir=""
## default values of switches
args_dryrun="--dryrun"
args_interactive=""
## default values of switches
args_deployment=false
args_analysis=false
dryrun=true
interactive=true
......@@ -50,7 +54,15 @@ parse_args() {
set -x
shift
;;
-d | --deploy_paths)
-d | --deployment)
args_deployment=true
shift
;;
-a | --analysis)
args_analysis=true
shift
;;
-p | --deploy_paths)
args_git_parent_dir=${2:-}
shift 2
;;
......@@ -59,7 +71,7 @@ parse_args() {
dryrun=false
shift
;;
-a | --auto)
--auto) # -a is already taken
args_interactive="--auto"
interactive=false
shift
......@@ -154,7 +166,6 @@ deploy_single_pipeline() {
skip_git_pull=true
skip_setup_env=true
skip_setup_data=true
skip_test_analysis=false # TODO: change to true
pipeline=$1
branch=${2:-main}
......@@ -178,22 +189,17 @@ branch:|$branch
## setup mamba environment
[[ ! "${conda_envs[*]}" =~ ${pipeline,,} && -f "$pipeline_dir/${pipeline_setup_sh[$pipeline]}" ]] && skip_setup_env=false || logwarn "Conda environment already exists or setup script not found"
[[ $skip_setup_env == false ]] && logexec bash "$pipeline_dir"/"${pipeline_setup_sh[$pipeline]}" $args_interactive ${setup_args_env[$pipeline]}
[[ $skip_setup_env == false ]] && logexec bash "$pipeline_dir"/"${pipeline_setup_sh[$pipeline]}" $args_interactive "${setup_args_env[$pipeline]}"
## setup data dependencies
[[ -f "$pipeline_dir/${pipeline_setup_sh[$pipeline]}" && $(find $pipeline_dir/test_data -type f \( -name "*.sha256" -o -name "*.md5" \) | wc -l) -lt 1 ]] && skip_setup_data=false || logwarn "Data already retrieved or setup script not found"
[[ $skip_setup_data == false ]] && logexec bash "$pipeline_dir"/"${pipeline_setup_sh[$pipeline]}" $args_interactive ${setup_args_data[$pipeline]}
## analyze test data
# TODO: create a test for successful data analysis, maybe pipeline status
[[ $skip_test_analysis == false ]] && logexec bash "$pipeline_dir"/"${pipeline_wrapper_sh[$pipeline]}" $args_interactive --norun
[[ $skip_setup_data == false ]] && logexec bash "$pipeline_dir"/"${pipeline_setup_sh[$pipeline]}" $args_interactive "${setup_args_data[$pipeline]}"
logsuccess "Pipeline $pipeline deployed successfully"
return 0
}
deploy_bfr_abc() {
## [Rationale] create_symlinks() This is the Rationale for create_symlinks() and mode "create"
## [Rationale] deploy_bfr_abc() This is the Rationale for deploy_bfr_abc() and mode "--deployment"
local pipeline branch="feature/harmonization"
......@@ -226,14 +232,60 @@ deploy_bfr_abc() {
# deploy pipelines from branch
for pipeline in "${!repository_origin_urls[@]}"; do
echo
interactive_query "Deploy pipeline $pipeline?" || continue
[[ $interactive == true ]] && (
echo
interactive_query "Analyse pipeline ${magenta}$pipeline${normal}?" || continue # TODO: interactive_query exits upon "no"; This only exits the subshell caused by the (..) group.
)
deploy_single_pipeline "$pipeline" "$branch"
done
echo
}
analyse_single_pipeline() {
## [Rationale] analyse_single_pipeline() This is the Rationale for analyse_single_pipeline() which is looped in analyse_bfr_abc()
local pipeline pipeline_dir skip_test_analysis
skip_test_analysis=true
pipeline=$1
logheader "Test data analysis of pipeline $pipeline:"
## check if directory exists
pipeline_dir="$git_parent_dir/$pipeline"
echo "
pipeline_dir:|$pipeline_dir
" | column -t -s "|" | logpipe
## analyse test data
[[ $(find "$pipeline_dir/test_data" -type f -name "pipeline_status*" | wc -l) -lt 1 ]] && skip_test_analysis=false || logwarn "No test data found"
[[ $skip_test_analysis == false ]] && logexec bash "$pipeline_dir"/"${pipeline_wrapper_sh[$pipeline]}" $args_interactive --norun
logsuccess "Pipeline $pipeline test data analysed successfully"
}
analyse_bfr_abc() {
## [Rationale] analyse_bfr_abc() This is the Rationale for deploy_bfr_abc() and mode "--analysis"
local pipeline
pipeline_table_column2array "pipeline_wrapper_sh"
declare -g -A pipeline_wrapper_sh
for key in "${!column_array[@]}"; do pipeline_wrapper_sh["$key"]="${column_array[$key]}"; done
# deploy pipelines from branch
for pipeline in "${!pipeline_wrapper_sh[@]}"; do
[[ $interactive == true ]] && (
echo
interactive_query "Analyse pipeline ${magenta}$pipeline${normal}?" || continue # TODO: interactive_query exits upon "no"; This only exits the subshell caused by the (..) group.
)
analyse_single_pipeline "$pipeline"
done
echo
}
## (3) Main
define_paths
......@@ -242,8 +294,9 @@ logglobal "Arguments: ${*:-"No arguments provided"}"
show_info
## Workflow
deploy_bfr_abc
[[ $args_deployment == true ]] && deploy_bfr_abc
[[ $args_analysis == true ]] && analyse_bfr_abc
logglobal "All steps were logged to: $logfile"
logglobal "[STOP] $script_real"
echo "Thank you for deploying the BfR-ABC"
echo "Thank you for using the BfR-ABC"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment