-
Notifications
You must be signed in to change notification settings - Fork 7
About add_data.sh
TODO(Anthony): Move the following to their own wiki pages.
docker cp python/add_data.sh opendrr-api_python-opendrr_1:/usr/src/app/add_data.sh && \
docker compose up python-opendrr
docker compose up --build python-opendrr
is helpful too, but it cannot be used to update the add_data.sh
that was previously copied to an existing volume.
TODO
Regarding RUN mapfile -t ARRAY_NAME < <(jq -r '......' input.json)
(Issue #111)
First of all, this is related to ShellCheck https://github.com/koalaman/shellcheck/wiki/SC2207 "Prefer mapfile or read -a to split command output (or quote to avoid splitting)". Code like array=( $(mycommand) )
is considered problematic, and mapfile -t array < <(mycommand)
is offered as as correct code for Bash 4.x and up.
In particular, ss using the RUN function here OK?
The answer is: Yes!
Even though the log only records mapfile -t ARRAY_NAME
and nothing after the <
operator, the redirection is fully functional.
The <(command_list)
syntax is known as process substitution. It does not stop at errors. set -o pipefail
does not affect this behaviour. And the use of our custom RUN function has nothing to do with it either.
For more information and workarounds (e.g. to get the error code), see the discussion "How to detect an error using process substitution" at https://unix.stackexchange.com/questions/376114/how-to-detect-an-error-using-process-substitution
For our purposes though, I think jq errors not stopping the build is good. :-) It is probably also good to keep a log file and have add_data.sh automatically show warnings and errors at the end.
docker compose logs python-opendrr | egrep '\[add_data|maxresident'
docker compose logs pygeoapi-opendrr | grep '| NotFoundError' | uniq
Wikis: data | model-factory | opendrr-api | opendrr | python-env | riskprofiler-cms