-
Notifications
You must be signed in to change notification settings - Fork 542
/
load-compute-driver.sh
32 lines (29 loc) · 1.28 KB
/
load-compute-driver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# load-compute-driver.sh -- Loads the compute driver configured for the DeepDive app
# > DEEPDIVE_COMPUTER=...
# > . load-compute-driver.sh
#
# $DEEPDIVE_COMPUTER environment variable has precedence over the
# deepdive.computer value configured in computers.conf file in the DeepDive
# application.
##
if [[ -z "${DEEPDIVE_COMPUTER_TYPE:-}" ]]; then
# parse computers.conf with fallback to built-in default if not defined already
eval "$(
DEEPDIVE_APP=$(find-deepdive-app)
export DEEPDIVE_APP
hocon2json <(cat "$DEEPDIVE_APP"/computers.conf 2>/dev/null || echo '{}') "$DEEPDIVE_HOME"/util/computers-default.conf | jq2sh \
DEEPDIVE_COMPUTER='.deepdive.computer' \
DEEPDIVE_COMPUTER_TYPE='.deepdive.computers[.deepdive.computer].type' \
DEEPDIVE_COMPUTER_CONFIG='.deepdive.computers[.deepdive.computer]' \
#
)"
# place the driver on PATH
PATH="$DEEPDIVE_HOME"/util/compute-driver/"$DEEPDIVE_COMPUTER_TYPE":"$PATH"
# make sure all operations are defined
for op in execute
do type compute-$op &>/dev/null || error "$DEEPDIVE_COMPUTER_TYPE compute driver does not provide compute-$op operation"
done
# set up the environment for using the configured computer
export DEEPDIVE_COMPUTER{,_{TYPE,CONFIG}} PATH
fi