diff --git a/convert_to_grayscale/run_grayscale.sh b/convert_to_grayscale/run_grayscale.sh index 1fac55a..6102902 100755 --- a/convert_to_grayscale/run_grayscale.sh +++ b/convert_to_grayscale/run_grayscale.sh @@ -32,8 +32,20 @@ INPUT_DIR=input # Since we only have one input we can list it as below INPUT_IMAGE_PATH=$(ls input/*) -# Read the positional argument as defined in the algorithm registration here -OUTPUT_IMAGE_NAME=$1 +# Parse named arguments instead of positional arguments +while [[ $# -gt 0 ]]; do + case $1 in + --output_image_name) + OUTPUT_IMAGE_NAME="$2" + shift 2 + ;; + *) + echo "Unknown argument: $1" + exit 1 + ;; + esac +done + OUTPUT_IMAGE_PATH="output/${OUTPUT_IMAGE_NAME}" # Call the script using the absolute path diff --git a/gdal_wrapper/environment.yml b/gdal_wrapper/environment.yml index eaf4034..d057e47 100644 --- a/gdal_wrapper/environment.yml +++ b/gdal_wrapper/environment.yml @@ -1,4 +1,4 @@ -name: python +name: notebook channels: - conda-forge - defaults diff --git a/gdal_wrapper/run_gdal.sh b/gdal_wrapper/run_gdal.sh index a5d9585..21a51fd 100755 --- a/gdal_wrapper/run_gdal.sh +++ b/gdal_wrapper/run_gdal.sh @@ -16,23 +16,32 @@ basedir=$(dirname "$(readlink -f "$0")") mkdir -p output - -# DPS downloads all files provided as inputs to -# this directory called input. -# In our example the image will be downloaded here. -INPUT_DIR=input - -# Since we only have one input we can list it as below -input_filename=$(ls -d input/*) - -# Read the positional argument as defined in the algorithm registration here -output_filename=$1 -reduction_size=$2 +# Parse named arguments as defined in the CWL file +while [[ $# -gt 0 ]]; do + case $1 in + --input_file) + input_filename="$2" + shift 2 + ;; + --output_file) + output_filename="$2" + shift 2 + ;; + --outsize) + reduction_size="$2" + shift 2 + ;; + *) + echo "Unknown argument: $1" + exit 1 + ;; + esac +done # Call the script using the absolute paths # Use the updated environment when calling 'conda run' # This lets us run the same way in a Terminal as in DPS # Any output written to the stdout and stderr streams will be automatically captured and placed in the output dir -# echo conda run --live-stream --name vanilla python ${basedir}/gdal_wrapper.py --input_file ${input_filename} --output_file output/${output_filename} --outsize ${reduction_size} +# echo conda run --live-stream --name notebook python ${basedir}/gdal_wrapper.py --input_file ${input_filename} --output_file output/${output_filename} --outsize ${reduction_size} -conda run --live-stream --name python python ${basedir}/gdal_wrapper.py --input_file ${input_filename} --output_file output/${output_filename} --outsize ${reduction_size} +conda run --live-stream --name notebook python ${basedir}/gdal_wrapper.py --input_file ${input_filename} --output_file output/${output_filename} --outsize ${reduction_size}