@@ -13,7 +13,7 @@ DATA_ZIP_FILENAME="aisdk-2024-08-07.zip" # Expected name of the zip file in da
1313MANUAL_DOWNLOAD_URL=" http://aisdata.ais.dk/?prefix=2024/"
1414CONFIG_FILE=" config.json"
1515REQUIREMENTS_FILE=" requirements.txt"
16-
16+ TRAJECTORIES_FILE= " data/trajectories_mf1.json "
1717show_help () {
1818 echo " Usage: ./run.sh [OPTIONS]"
1919 echo " "
@@ -38,7 +38,7 @@ command -v docker >/dev/null 2>&1 || { echo -e "${RED}Docker not found. Please i
3838command -v python3 > /dev/null 2>&1 || { echo -e " ${RED} Python3 not found.${NC} " ; exit 1; }
3939command -v lsof > /dev/null 2>&1 || { echo -e " ${YELLOW} lsof not found. Install it for automatic port killing.${NC} " ; }
4040
41- # CAS PORT ALREADY IN USE
41+ # Free port if already in use
4242free_port () {
4343 local PORT=$1
4444 if command -v lsof > /dev/null 2>&1 ; then
8888 fi
8989}
9090
91- # API port <-fconig .json
91+ # Get API port from config .json
9292get_api_port () {
9393 if [ -f " $CONFIG_FILE " ]; then
9494 python3 -c " import json; print(json.load(open('$CONFIG_FILE ')).get('API_PORT', 8080))" 2> /dev/null || echo " 8080"
@@ -136,7 +136,8 @@ start_container() {
136136 echo -e " ${YELLOW} Waiting for database to be ready...${NC} "
137137 sleep 5
138138}
139- # check for dataset presence
139+
140+ # Check for dataset presence
140141check_data () {
141142 DATA_DIR=" data"
142143 mkdir -p " $DATA_DIR "
@@ -151,7 +152,7 @@ check_data() {
151152 fi
152153}
153154
154- # data preprocessing
155+ # Data preprocessing
155156run_preprocessing () {
156157 if [ ! -f " data/ais_to_json.py" ]; then
157158 echo -e " ${RED} Preprocessing script not found: data/ais_to_json.py${NC} "
@@ -181,14 +182,20 @@ run_tests() {
181182 exit $TEST_EXIT
182183}
183184
184-
185185setup_config
186186setup_venv
187187start_container
188188
189189if [ " $WITH_TESTS " = true ]; then
190- check_data
191- run_preprocessing
190+
191+ if [ -f " $TRAJECTORIES_FILE " ] && [ -s " $TRAJECTORIES_FILE " ]; then
192+ echo -e " ${GREEN} Found existing $TRAJECTORIES_FILE (non‑empty). Skipping preprocessing.${NC} "
193+ else
194+ echo -e " ${YELLOW} Missing or empty $TRAJECTORIES_FILE . Running preprocessing...${NC} "
195+ check_data
196+ run_preprocessing
197+ fi
198+
192199 run_tests
193200else
194201 API_PORT=$( get_api_port)
0 commit comments