Skip to content

Commit 4066f6e

Browse files
P2Rank 2.5.1, Flower, failed predictions (#182)
* Update P2Rank to 2.5.1 * Fix Flower infrastructure * Enable failed prediction re-run after 1 hour
1 parent 9399920 commit 4066f6e

9 files changed

Lines changed: 49 additions & 42 deletions

File tree

docker-compose-prankweb.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
timeout: 30s
3030
retries: 3
3131
flower:
32-
build: https://github.com/mher/flower.git
32+
image: mher/flower
3333
command: "celery flower --url_prefix=service/flower"
3434
environment:
3535
CELERY_BROKER_URL: "amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672"

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ services:
2727
timeout: 30s
2828
retries: 3
2929
flower:
30-
build: https://github.com/mher/flower.git
30+
image: mher/flower
3131
command: "celery flower --url_prefix=service/flower"
3232
environment:
3333
CELERY_BROKER_URL: "amqp://${RABBITMQ_DEFAULT_USER:-user}:${RABBITMQ_DEFAULT_PASS:-1234}@rabbitmq:5672"
3434
depends_on:
3535
rabbitmq:
36-
condition: service_healthy
36+
condition: service_healthy
3737
web-server:
3838
build:
3939
context: ./

executor-p2rank/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ FROM debian:bookworm-20231009
100100

101101
ARG UID=5988
102102
ARG GID=5988
103-
ARG P2RANK_URL=https://github.com/rdk/p2rank/releases/download/2.5/p2rank_2.5.tar.gz
103+
ARG P2RANK_URL=https://github.com/rdk/p2rank/releases/download/2.5.1/p2rank_2.5.1.tar.gz
104104
ARG CELERY_BROKER_URL="amqp://user-develop:develop@localhost:5672"
105105

106106
RUN apt-get update \

flower/Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

flower/requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

frontend/client/analyze/analyze.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function renderFailedTask(database: string, id: string) {
145145
UserInterface.progressStdout
146146
]);
147147
setProgressMessage("Task failed, see the log below for more details.<br/>");
148-
if (!database.includes("user")) setProgressMessage("Task failed, see the log below for more details.<br/><strong>To re-run the prediction, please refresh the page.</strong>");
148+
if (!database.includes("user")) setProgressMessage("Task failed, see the log below for more details.<br/><strong>To re-run the prediction, please try again in 1 hour.</strong>");
149149
setStdout(database, id);
150150
}
151151

gateway/nginx/gateway.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ server {
1919

2020
# https://flower.readthedocs.io/en/latest/reverse-proxy.html
2121
set $flower_url flower;
22-
location /service/flower {
23-
return 301 ./service/flower/;
24-
}
2522
location /service/flower/ {
2623
include restricted.conf;
2724
proxy_pass http://$flower_url:5555;
@@ -32,6 +29,10 @@ server {
3229
proxy_set_header Connection "upgrade";
3330
}
3431

32+
location /service/flower {
33+
return 301 ../service/flower/;
34+
}
35+
3536
# https://grafana.com/tutorials/run-grafana-behind-a-proxy/
3637
# set $grafana_url grafana;
3738
# location /service/grafana {

web-server/src/database_v3.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_info(self, identifier: str):
6363
# In such cases, we want to remove the prediction and run it again.
6464
with open(os.path.join(directory, "info.json"), "r") as f:
6565
info = json.load(f)
66-
if info["status"] == "failed":
66+
if _should_rerun_prediction(info):
6767
# Remove the directory and create a new prediction.
6868
shutil.rmtree(directory)
6969
else:
@@ -103,7 +103,7 @@ def get_info(self, identifier: str):
103103
# In such cases, we want to remove the prediction and run it again.
104104
with open(os.path.join(directory, "info.json"), "r") as f:
105105
info = json.load(f)
106-
if info["status"] == "failed":
106+
if _should_rerun_prediction(info):
107107
# Remove the directory and create a new prediction.
108108
shutil.rmtree(directory)
109109
else:
@@ -185,7 +185,7 @@ def get_info(self, identifier: str):
185185
# In such cases, we want to remove the prediction and run it again.
186186
with open(os.path.join(directory, "info.json"), "r") as f:
187187
info = json.load(f)
188-
if info["status"] == "failed":
188+
if _should_rerun_prediction(info):
189189
# Remove the directory and create a new prediction.
190190
shutil.rmtree(directory)
191191
else:
@@ -229,7 +229,7 @@ def get_info(self, identifier: str):
229229
# In such cases, we want to remove the prediction and run it again.
230230
with open(os.path.join(directory, "info.json"), "r") as f:
231231
info = json.load(f)
232-
if info["status"] == "failed":
232+
if _should_rerun_prediction(info):
233233
# Remove the directory and create a new prediction.
234234
shutil.rmtree(directory)
235235
else:
@@ -356,6 +356,22 @@ def _configuration_to_prediction(
356356
metadata={},
357357
)
358358

359+
def _should_rerun_prediction(info: dict) -> bool:
360+
last_change_str = info.get("lastChange")
361+
last_change = None
362+
363+
if last_change_str:
364+
try:
365+
last_change = datetime.datetime.strptime(last_change_str, "%Y-%m-%dT%H:%M:%S")
366+
except Exception:
367+
last_change = None
368+
369+
now = datetime.datetime.now()
370+
if info["status"] == "failed" and last_change and (now - last_change).total_seconds() >= 3600:
371+
return True
372+
373+
return False
374+
359375

360376
def _is_prediction_valid(prediction: Prediction) -> bool:
361377
if prediction.structure_sealed:

web-server/src/database_v4.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_info(self, identifier: str):
6363
# In such cases, we want to remove the prediction and run it again.
6464
with open(os.path.join(directory, "info.json"), "r") as f:
6565
info = json.load(f)
66-
if info["status"] == "failed":
66+
if _should_rerun_prediction(info):
6767
# Remove the directory and create a new prediction.
6868
shutil.rmtree(directory)
6969
else:
@@ -103,7 +103,7 @@ def get_info(self, identifier: str):
103103
# In such cases, we want to remove the prediction and run it again.
104104
with open(os.path.join(directory, "info.json"), "r") as f:
105105
info = json.load(f)
106-
if info["status"] == "failed":
106+
if _should_rerun_prediction(info):
107107
# Remove the directory and create a new prediction.
108108
shutil.rmtree(directory)
109109
else:
@@ -185,7 +185,7 @@ def get_info(self, identifier: str):
185185
# In such cases, we want to remove the prediction and run it again.
186186
with open(os.path.join(directory, "info.json"), "r") as f:
187187
info = json.load(f)
188-
if info["status"] == "failed":
188+
if _should_rerun_prediction(info):
189189
# Remove the directory and create a new prediction.
190190
shutil.rmtree(directory)
191191
else:
@@ -229,7 +229,7 @@ def get_info(self, identifier: str):
229229
# In such cases, we want to remove the prediction and run it again.
230230
with open(os.path.join(directory, "info.json"), "r") as f:
231231
info = json.load(f)
232-
if info["status"] == "failed":
232+
if _should_rerun_prediction(info):
233233
# Remove the directory and create a new prediction.
234234
shutil.rmtree(directory)
235235
else:
@@ -356,6 +356,22 @@ def _configuration_to_prediction(
356356
metadata={},
357357
)
358358

359+
def _should_rerun_prediction(info: dict) -> bool:
360+
last_change_str = info.get("lastChange")
361+
last_change = None
362+
363+
if last_change_str:
364+
try:
365+
last_change = datetime.datetime.strptime(last_change_str, "%Y-%m-%dT%H:%M:%S")
366+
except Exception:
367+
last_change = None
368+
369+
now = datetime.datetime.now()
370+
if info["status"] == "failed" and last_change and (now - last_change).total_seconds() >= 3600:
371+
return True
372+
373+
return False
374+
359375

360376
def _is_prediction_valid(prediction: Prediction) -> bool:
361377
if prediction.structure_sealed:

0 commit comments

Comments
 (0)