-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie-recs.sh
executable file
·72 lines (63 loc) · 2.45 KB
/
movie-recs.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
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
#!/bin/bash
# run movie-recs notebook from CLI using papermill
# process CLI args using bash getops built-in command to simplify CL calls
# this lets us set non-default values selectively
# based on code from:
# https://www.computerhope.com/unix/bash/getopts.htm
usage() { # Function: Print a help message.
echo "Usage: $0 [ -l LENGTH ] [ -f FRACTION ] [ -t TAG ] [ -r RESULTSDIR ]" 1>&2
}
exit_abnormal() { # Function: Exit with error.
usage
exit 1
}
while getopts ":l:f:t:r:d:" options; do # Loop: Get the next option;
# use silent error checking;
# options n and t take arguments.
case "${options}" in #
l) # If the option is n,
LENGTH=${OPTARG} # set $LEN to specified value.
;;
f) # If the option is t,
FRACTION=${OPTARG} # Set $FRACTION to specified value.
;;
t) # If the option is t,
TAG=${OPTARG} # Set $TAG to specified value.
;;
o) # If the option is t,
OUTPUTDIR=${OPTARG} # Set $OUTPUTDIR to specified value.
;;
d) # If the option is t,
RATINGS=${OPTARG} # Set $RATINGS to specified value.
;;
:) # If expected argument omitted:
echo "Error: -${OPTARG} requires an argument."
exit_abnormal # Exit abnormally.
;;
*) # If unknown (any other) option:
exit_abnormal # Exit abnormally.
;;
esac
done
# parameters are defined in the environment or overwritten
# positional parameters above to support CLI and batch execution
# create a papermill parameter argument vector to pass to the notebook
if [ "${LENGTH}" != "" ]
then
PARGS="$PARGS -p challenge_length ${LENGTH}"
fi
if [ "${FRACTION}" != "" ]
then
PARGS="$PARGS -p trainfraction ${FRACTION}"
fi
if [ "${RATINGS}" != "" ]
then
PARGS="$PARGS -p movie_ratings ${RATINGS}"
fi
LEN=${LENGTH:-5}
FRAC=${FRACTION:-1.0}
TAG=${TAG:-notag}
outfile=${OUTPUTDIR:-results}/movie-recs_${LEN}_${FRAC}_${TAG}.ipynb
papermill \
${PARGS} movie-recs.ipynb \
$outfile