-
Notifications
You must be signed in to change notification settings - Fork 4
Created common script argument parsing #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,44 +57,18 @@ if [[ -z $PRESTO_DATA_DIR ]]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| source ./common_functions.sh | ||
| source ../../scripts/helper_functions.sh | ||
|
|
||
| wait_for_worker_node_registration | ||
| declare -A OPTION_MAP=( ["-b"]="--benchmark-type" | ||
| ["-d"]="--data-dir-name" | ||
| ["-s"]="--schema-name" ) | ||
| make_options "OPTION_MAP" | ||
|
|
||
| parse_args() { | ||
| custom_parse_args() { | ||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) | ||
| print_help | ||
| exit 0 | ||
| ;; | ||
| -b|--benchmark-type) | ||
| if [[ -n $2 ]]; then | ||
| BENCHMARK_TYPE=$2 | ||
| shift 2 | ||
| else | ||
| echo "Error: --benchmark-type requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| -s|--schema-name) | ||
| if [[ -n $2 ]]; then | ||
| SCHEMA_NAME=$2 | ||
| shift 2 | ||
| else | ||
| echo "Error: --schema-name requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| -d|--data-dir-name) | ||
| if [[ -n $2 ]]; then | ||
| DATA_DIR_NAME=$2 | ||
| shift 2 | ||
| else | ||
| echo "Error: --data-dir-name requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| -h|--help) print_help; exit 0;; | ||
| $OPTIONS) parse_option $1 $2; shift 2;; | ||
| -c|--convert-decimals-to-floats) | ||
| CONVERT_DECIMALS_TO_FLOATS_ARG="--convert-decimals-to-floats" | ||
| shift | ||
|
|
@@ -118,7 +92,11 @@ parse_args() { | |
| done | ||
| } | ||
|
|
||
| parse_args "$@" | ||
| custom_parse_args "$@" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved argument parsing before waiting on worker node so the user can use functions like "--help" without having to wait for a worker registration. |
||
|
|
||
| source ./common_functions.sh | ||
|
|
||
| wait_for_worker_node_registration | ||
|
|
||
| if [[ -z ${BENCHMARK_TYPE} || ! ${BENCHMARK_TYPE} =~ ^tpc(h|ds)$ ]]; then | ||
| echo "Error: A valid benchmark type (tpch or tpcds) is required. Use the -b or --benchmark-type argument." | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |
|
|
||
| set -e | ||
|
|
||
| source ./start_presto_helper_parse_args.sh | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this up so the user can use "--help" before running into the ENV variable validation. |
||
|
|
||
| if [[ -z ${VARIANT_TYPE} || ! ${VARIANT_TYPE} =~ ^(cpu|gpu|java)$ ]]; then | ||
| echo "Internal error: A valid variant type (cpu, gpu, or java) is required. Set VARIANT_TYPE to an appropriate value." | ||
| exit 1 | ||
|
|
@@ -29,8 +31,6 @@ fi | |
| # Validate repo layout using shared script | ||
| ../../scripts/validate_directories_exist.sh "../../../presto" "../../../velox" | ||
|
|
||
| source ./start_presto_helper_parse_args.sh | ||
|
|
||
| COORDINATOR_SERVICE="presto-coordinator" | ||
| COORDINATOR_IMAGE=${COORDINATOR_SERVICE}:latest | ||
| JAVA_WORKER_SERVICE="presto-java-worker" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,48 +44,25 @@ EOF | |
|
|
||
| NUM_THREADS=$(($(nproc) / 2)) | ||
|
|
||
| parse_args() { | ||
| source ../../scripts/helper_functions.sh | ||
| declare -A OPTION_MAP=( ["-b"]="--build-target" ["-j"]="--num-threads" ) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
| make_options "OPTION_MAP" | ||
|
|
||
| custom_parse_args() { | ||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) | ||
| print_help | ||
| exit 0 | ||
| ;; | ||
| -n|--no-cache) | ||
| SKIP_CACHE_ARG="--no-cache" | ||
| shift | ||
| ;; | ||
| -b|--build) | ||
| if [[ -n $2 ]]; then | ||
| BUILD_TARGET=$2 | ||
| shift 2 | ||
| else | ||
| echo "Error: --build requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| -j|--num-threads) | ||
| if [[ -n $2 ]]; then | ||
| NUM_THREADS=$2 | ||
| shift 2 | ||
| else | ||
| echo "Error: --num-threads requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| *) | ||
| echo "Error: Unknown argument $1" | ||
| print_help | ||
| exit 1 | ||
| ;; | ||
| -h|--help) print_help; exit 0 ;; | ||
| -n|--no-cache) SKIP_CACHE_ARG="--no-cache"; shift ;; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left custom in. |
||
| $OPTIONS) parse_option $1 $2; shift 2 ;; | ||
| *) echo "Error: Unknown argument $1"; print_help; exit 1 ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| parse_args "$@" | ||
| custom_parse_args "$@" | ||
|
|
||
| if [[ -n ${BUILD_TARGET} && ! ${BUILD_TARGET} =~ ^(coordinator|c|worker|w|all|a)$ ]]; then | ||
| echo "Error: invalid --build value." | ||
| echo "Error: invalid --build-target value." | ||
| print_help | ||
| exit 1 | ||
| fi | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left this one in since it sets it's variable to a custom value, rather than "TRUE"