Skip to content

Commit

Permalink
Merge pull request #4 from scitran-apps/parseconfig
Browse files Browse the repository at this point in the history
add parse_config function + bump version
  • Loading branch information
lmperry authored Jun 25, 2018
2 parents 7e81bef + 272b8b3 commit f0c495b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"source": "https://github.com/scitran-apps/parrec-mr-classifier",
"license": "Apache-2.0",
"flywheel": "0",
"version": "1.1.0",
"version": "1.1.1",
"custom": {
"docker-image": "scitran/parrec-mr-classifier:1.1.0"
"docker-image": "scitran/parrec-mr-classifier:1.1.1"
},
"config": {
"timezone": {
Expand Down
23 changes: 15 additions & 8 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@ MANIFEST_FILE=$FLYWHEEL_BASE/manifest.json
##############################################################################
# Parse configuration

if [[ -f $CONFIG_FILE ]]; then
eval $(jq -r '.config | to_entries[] | "config_\(.key)=\(.value)"' $CONFIG_FILE)
else
CONFIG_FILE=$MANIFEST_FILE
eval $(jq -r '.config | to_entries[] | "config_\(.key)=\(.value.default)"' $CONFIG_FILE)
fi
function parse_config {

CONFIG_FILE=$FLYWHEEL_BASE/config.json
MANIFEST_FILE=$FLYWHEEL_BASE/manifest.json

if [[ -f $CONFIG_FILE ]]; then
echo "$(cat $CONFIG_FILE | jq -r '.config.'$1)"
else
CONFIG_FILE=$MANIFEST_FILE
echo "$(cat $MANIFEST_FILE | jq -r '.config.'$1'.default')"
fi
}


##############################################################################
# Set Time Zone

TZ="${config_timezone}"
TZ="$(parse_config 'timezone')"
echo "${CONTAINER} Setting time zone to: $TZ"
echo "$TZ" > /etc/timezone && ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
Expand All @@ -36,7 +42,8 @@ dpkg-reconfigure -f noninteractive tzdata
##############################################################################
# Handle sync option

if [[ ${config_sync} == "true" ]]; then
SYNC=$(parse_config 'sync')
if [[ ${SYNC} == "true" ]]; then
echo -e "$CONTAINER Syncing classification code from scitran-apps/dicom-mr-classifier/sync-classification-e4..."
mv ${FLYWHEEL_BASE}/classification_from_label.py /tmp
wget --quiet -O ${FLYWHEEL_BASE}/classification_from_label.py \
Expand Down

0 comments on commit f0c495b

Please sign in to comment.