-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
102 lines (81 loc) · 2.51 KB
/
Copy pathrun.sh
File metadata and controls
102 lines (81 loc) · 2.51 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
readonly PSL_VERSION='2.1.0'
readonly JAR_PATH="./psl-cli-${PSL_VERSION}.jar"
readonly BASE_NAME='simple-acquaintances'
readonly ADDITIONAL_PSL_OPTIONS=''
readonly ADDITIONAL_EVAL_OPTIONS='--infer --eval org.linqs.psl.evaluation.statistics.DiscreteEvaluator'
function main() {
trap exit SIGINT
# The data is already included, no need to fetch it.
# Make sure we can run PSL.
check_requirements
fetch_psl
# Run PSL
runEvaluation
}
function runEvaluation() {
echo "Running PSL Inference"
java -jar "${JAR_PATH}" --model "${BASE_NAME}.psl" --data "${BASE_NAME}.data" --output inferred-predicates ${ADDITIONAL_EVAL_OPTIONS} ${ADDITIONAL_PSL_OPTIONS}
if [[ "$?" -ne 0 ]]; then
echo 'ERROR: Failed to run infernce'
exit 70
fi
}
function check_requirements() {
local hasWget
local hasCurl
type wget > /dev/null 2> /dev/null
hasWget=$?
type curl > /dev/null 2> /dev/null
hasCurl=$?
if [[ "${hasWget}" -ne 0 ]] && [[ "${hasCurl}" -ne 0 ]]; then
echo 'ERROR: wget or curl required to download the jar'
exit 10
fi
type java > /dev/null 2> /dev/null
if [[ "$?" -ne 0 ]]; then
echo 'ERROR: java required to run project'
exit 13
fi
}
function get_fetch_command() {
type curl > /dev/null 2> /dev/null
if [[ "$?" -eq 0 ]]; then
echo "curl -o"
return
fi
type wget > /dev/null 2> /dev/null
if [[ "$?" -eq 0 ]]; then
echo "wget -O"
return
fi
echo 'ERROR: wget or curl not found'
exit 20
}
function fetch_file() {
local url=$1
local path=$2
local name=$3
if [[ -e "${path}" ]]; then
echo "${name} file found cached, skipping download."
return
fi
echo "Downloading ${name} file located at: '${url}'."
`get_fetch_command` "${path}" "${url}"
if [[ "$?" -ne 0 ]]; then
echo "ERROR: Failed to download ${name} file"
exit 30
fi
}
# Fetch the jar from a remote or local location and put it in this directory.
# Snapshots are fetched from the local maven repo and other builds are fetched remotely.
function fetch_psl() {
if [[ $PSL_VERSION == *'SNAPSHOT'* ]]; then
local snapshotJARPath="$HOME/.m2/repository/org/linqs/psl-cli/${PSL_VERSION}/psl-cli-${PSL_VERSION}.jar"
cp "${snapshotJARPath}" "${JAR_PATH}"
else
local remoteJARURL="https://linqs-data.soe.ucsc.edu/maven/repositories/psl-releases/org/linqs/psl-cli/${PSL_VERSION}/psl-cli-${PSL_VERSION}.jar"
fetch_file "${remoteJARURL}" "${JAR_PATH}" 'psl-jar'
fi
}
main "$@"