Skip to content

Commit

Permalink
move ga preloading into script
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Jun 26, 2024
1 parent 3f3aa65 commit ac39fa5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
23 changes: 2 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ migrate-downgrade:
import-projects:
$(shell CRE_SKIP_IMPORT_CORE=1 bash ./scripts/import-all.sh)



import-all:
$(shell bash ./scripts/import-all.sh)

Expand All @@ -128,23 +126,6 @@ import-neo4j:
export FLASK_APP=$(CURDIR)/cre.py && python cre.py --populate_neo4j_db

preload-map-analysis:
make docker-neo4j&\
make docker-redis&\
make start-worker&
make start-worker&
make start-worker&
make start-worker&
make start-worker&
make start-worker&
make start-worker&
make start-worker&
make start-worker&
make start-worker&
make dev-flask&
sleep 5
[ -d "./venv" ] && . ./venv/bin/activate &&\
export FLASK_APP=$(CURDIR)/cre.py
python cre.py --preload_map_analysis_target_url 'http://127.0.0.1:5000'
echo "Map Analysis Loaded"
killall python flask
$(shell RUN_COUNT=5 bash ./scripts/preload_gap_analysis.sh)

all: clean lint test dev dev-run
14 changes: 2 additions & 12 deletions application/utils/gap_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,14 @@ def calculate_a_to_b(sa: str, sb: str) -> bool:
while len(waiting):
for sa in standards:
for sb in standards:
forward = False
backward = False
if sa == sb:
continue
if calculate_a_to_b(sa, sb):
forward = True
print(f"gap analysis {sa}->{sb} returned")
waiting.remove(f"{sa}->{sb}")
waiting.remove(f"{sa}->{sb}") if f"{sa}->{sb}" in waiting else ""
if calculate_a_to_b(sb, sa):
backward = True
print(f"gap analysis {sb}->{sa} returned")
waiting.remove(f"{sb}->{sa}")

if forward and backward:
print(
f"removing standard {sb} from the waiting list as it has returned "
)
standards.remove(sb)
waiting.remove(f"{sb}->{sa}") if f"{sb}->{sa}" in waiting else ""
print(f"calculating {len(waiting)} gap analyses")
time.sleep(30)
print("map analysis preloaded successfully")
23 changes: 23 additions & 0 deletions scripts/preload_gap_analysis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash

set -ex
export NEO4J_URL='neo4j://neo4j:[email protected]:7687'
export FLASK_APP=$(pwd)/cre.py

make docker-redis
make docker-neo4j

for i in $(seq 1 $RUN_COUNT); do
(rm -f "worker-$i.log" && make start-worker &> "worker-$i.log")&
done

[ -d "./venv" ] && . ./venv/bin/activate
rm -f gap_analysis_flask.log && make dev-flask&>gap_analysis_flask.log&

sleep 5

python cre.py --preload_map_analysis_target_url 'http://127.0.0.1:5000'
echo "Map Analysis Loaded"

killall python flask

0 comments on commit ac39fa5

Please sign in to comment.