-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate1
executable file
·99 lines (80 loc) · 2.82 KB
/
generate1
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
#!/bin/bash
set -e
#sudo apt install python
#sudo pip3 install "pillow!=8.3.0" tensorflow-cpu==2.6.5 matplotlib numpy tensorflow_hub pyyaml
export INPUT_DATA_PATH=${INPUT_DATA_PATH:="$(pwd)/data-repo"}
export CODE_REPO_PATH=${CODE_REPO_PATH:="$(pwd)/code-repo"}
export OUTPUT_DATA_PATH=${OUTPUT_DATA_PATH:="$(pwd)/pages-repo"}
mkdir $OUTPUT_DATA_PATH || true
# Data processing
cd $CODE_REPO_PATH/etl
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o youtube-dl
chmod +x youtube-dl
npm install
npm run lets-do-this
cd ../..
# Copy config file from data repo to viewer
# cp -u data-repo/config.yml $CODE_REPO_PATH || true
export URL=$(yq e .url data-repo/config.yml)
export BASE_PATH=$(yq e .basePath data-repo/config.yml)
export SITE_TITLE=$(yq e .siteTitle data-repo/config.yml)
export SITE_DESCRIPTION=$(yq e .siteDescription data-repo/config.yml)
export DISTANCE_THRESHOLD=$(yq e .distanceThreshold data-repo/config.yml)
export TIME_THRESHOLD=$(yq e .timeThreshold data-repo/config.yml)
export ENABLE_TAGGER=$(yq e .enableTagger data-repo/config.yml)
export AUTO_TAGS=$(yq e .autoTags data-repo/config.yml)
echo "Configuration:"
echo "INPUT_DATA_PATH: $INPUT_DATA_PATH"
echo "OUTPUT_DATA_PATH: $OUTPUT_DATA_PATH"
echo "CODE_REPO_PATH: $CODE_REPO_PATH"
echo "URL: $URL"
echo "BASE_PATH: $BASE_PATH"
echo "SITE_TITLE: $SITE_TITLE"
echo "SITE_DESCRIPTION: $SITE_DESCRIPTION"
echo "DISTANCE_THRESHOLD: $DISTANCE_THRESHOLD"
echo "TIME_THRESHOLD: $TIME_THRESHOLD"
echo "ENABLE_TAGGER: $ENABLE_TAGGER"
echo "AUTO_TAGS: $AUTO_TAGS"
genereteStaticPages () {
echo ""
echo "Regenerate static pages"
rm -R $CODE_REPO_PATH/viewer-2/public/*
cp -R $OUTPUT_DATA_PATH/data $CODE_REPO_PATH/viewer-2/public
cp -R $OUTPUT_DATA_PATH/images $CODE_REPO_PATH/viewer-2/public
cp -R $OUTPUT_DATA_PATH/index.json $CODE_REPO_PATH/viewer-2/public
# Compile code of site/viewer
cd $CODE_REPO_PATH/viewer-2
npm install --force
npm run build
cd ../..
cp -R $CODE_REPO_PATH/viewer-2/out/* $OUTPUT_DATA_PATH
touch $OUTPUT_DATA_PATH/_next/.nojekyll
}
# Generate static pages with default setting for cretion of previews
genereteStaticPages
# Run site in dev mode
#cd $CODE_REPO_PATH/viewer-2
#npm run dev &
#cd ../..
npx http-server $CODE_REPO_PATH/viewer-2/out -p 3000 &
# Make preview/thumbnail for every trip
cd $CODE_REPO_PATH/previewer
npm install
npm run lets-do-this
cd ../..
# Tag inference using python and tensorflow
if [[ "$ENABLE_TAGGER" == "true" ]]
then
echo "Tagger is enabled"
cd $CODE_REPO_PATH/tagger
python3 ./tagger.py
cd ../..
else
echo "Tagger is disabled"
fi
# Data processing (ELT) again since out tags were changed
cd $CODE_REPO_PATH/etl
npm run lets-do-this
cd ../..
cat $CODE_REPO_PATH/viewer-2/next.config.template.js | envsubst > $CODE_REPO_PATH/viewer-2/next.config.js
genereteStaticPages