-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_v1_code_samples.sh
More file actions
executable file
·51 lines (43 loc) · 1.33 KB
/
test_v1_code_samples.sh
File metadata and controls
executable file
·51 lines (43 loc) · 1.33 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
#! /bin/sh
set -e
OUTPUT_FILE='./_test_v1.py'
ACCOUNT=$1
ENDPOINT=$2
for f in $(
find ./docs/extras/code_samples -maxdepth 1 -name "*.txt" -not -name "workflow_*.txt" -not -name "v2_*.txt" | sort -h
)
do
if echo "${f}" | grep -q "default_v2.txt"; then
if [ -z "${API_KEY_V2}" ] || [ -z "${MODEL_ID}" ]; then
echo "Skipping ${f} (API_KEY_V2 or MODEL_ID not supplied)"
echo
continue
fi
fi
echo
echo "###############################################"
echo "${f}"
echo "###############################################"
echo
sed "s/my-api-key/${MINDEE_API_KEY}/" "${f}" > $OUTPUT_FILE
sed -i 's/\/path\/to\/the\/file.ext/.\/tests\/data\/file_types\/pdf\/blank_1.pdf/' $OUTPUT_FILE
if echo "$f" | grep -q "custom_v1.txt"
then
sed -i "s/my-account/$ACCOUNT/g" $OUTPUT_FILE
sed -i "s/my-endpoint/$ENDPOINT/g" $OUTPUT_FILE
fi
if echo "${f}" | grep -q "default.txt"
then
sed -i "s/my-account/$ACCOUNT/" $OUTPUT_FILE
sed -i "s/my-endpoint/$ENDPOINT/" $OUTPUT_FILE
sed -i "s/my-version/1/" $OUTPUT_FILE
fi
if echo "${f}" | grep -q "default_async.txt"
then
sed -i "s/my-account/mindee/" $OUTPUT_FILE
sed -i "s/my-endpoint/invoice_splitter/" $OUTPUT_FILE
sed -i "s/my-version/1/" $OUTPUT_FILE
fi
sleep 0.5 # avoid too many request errors
python $OUTPUT_FILE
done