-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·80 lines (61 loc) · 2.2 KB
/
run
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/bash
# This script is meant to evoke the algorithm without requiring any input arguments
#
CONTAINER="[ scitran/parrec-mr-classifier ]"
FLYWHEEL_BASE=/flywheel/v0
# Make sure that /output directory is empty (all content will be removed later).
OUTPUT_DIR=$FLYWHEEL_BASE/output
INPUT_DIR=$FLYWHEEL_BASE/input/parrec
CONFIG_FILE=$FLYWHEEL_BASE/config.json
MANIFEST_FILE=$FLYWHEEL_BASE/manifest.json
##############################################################################
# Parse configuration
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="$(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
##############################################################################
# Check I/O directories and Generate metadata
if [[ -z $@ ]]
then
input_file=`find $INPUT_DIR -not -path '*/\.*' -type f | head -1`
if [[ -n $input_file ]]
then
PYHONPATH=$PYTHONPATH:/flywheel/v0/ python $FLYWHEEL_BASE/parrec-mr-classifier.py "$input_file" "$OUTPUT_DIR"
E_STATUS=$?
else
echo -e "$INPUT_DIR has no valid input files!"
exit 1
fi
else
# Run with input arguments
PYHONPATH=$PYTHONPATH:/flywheel/v0/ python $FLYWHEEL_BASE/parrec-mr-classifier.py $@
E_STATUS=$?
fi
##############################################################################
# Check for outputs and exit
output=`find $OUTPUT_DIR -type f -name ".metadata.json"`
# If outputs exist, then go on...
if [[ -f $output ]] && [[ $E_STATUS == 0 ]]; then
chmod -R 777 $OUTPUT_DIR
echo -e "$CONTAINER Success."
else
echo -e "$CONTAINER Errors occurred during metadata generation... Exiting!"
exit 1
if [[ -f $output ]]; then
rm $output
fi
fi
exit 0