test pause
Browse files- app.py +5 -2
- prefect_utils.py +11 -2
app.py
CHANGED
|
@@ -8,7 +8,7 @@ import secrets
|
|
| 8 |
from DB_utls import find_unused_wells, update_used_wells, save_result, get_student_quota, decrement_student_quota
|
| 9 |
import os
|
| 10 |
from yt_utils import get_latest_video_id
|
| 11 |
-
from prefect import flow
|
| 12 |
from prefect_utils import start_prefect_worker
|
| 13 |
|
| 14 |
|
|
@@ -46,7 +46,6 @@ video_id = get_latest_video_id(channel_id, playlist_id = "PL8uZlc2CEpenUCAo9PeiO
|
|
| 46 |
start_prefect_worker()
|
| 47 |
print("[TEST]Prefect worker initialized")
|
| 48 |
|
| 49 |
-
@flow
|
| 50 |
def check_student_quota(student_id):
|
| 51 |
"""Check student's remaining experiment quota"""
|
| 52 |
student_quota = get_student_quota(student_id)
|
|
@@ -275,6 +274,7 @@ def update_queue_display():
|
|
| 275 |
except Exception as e:
|
| 276 |
return f"Error getting queue status: {str(e)}"
|
| 277 |
|
|
|
|
| 278 |
def add_to_queue(student_id, R, Y, B):
|
| 279 |
global queue_counter
|
| 280 |
|
|
@@ -309,7 +309,10 @@ def add_to_queue(student_id, R, Y, B):
|
|
| 309 |
try:
|
| 310 |
empty_wells = find_unused_wells()
|
| 311 |
if not empty_wells:
|
|
|
|
|
|
|
| 312 |
raise ValueError("No available wells")
|
|
|
|
| 313 |
selected_well = empty_wells[0]
|
| 314 |
|
| 315 |
|
|
|
|
| 8 |
from DB_utls import find_unused_wells, update_used_wells, save_result, get_student_quota, decrement_student_quota
|
| 9 |
import os
|
| 10 |
from yt_utils import get_latest_video_id
|
| 11 |
+
from prefect import task, flow, pause_flow_run, resume_flow_run
|
| 12 |
from prefect_utils import start_prefect_worker
|
| 13 |
|
| 14 |
|
|
|
|
| 46 |
start_prefect_worker()
|
| 47 |
print("[TEST]Prefect worker initialized")
|
| 48 |
|
|
|
|
| 49 |
def check_student_quota(student_id):
|
| 50 |
"""Check student's remaining experiment quota"""
|
| 51 |
student_quota = get_student_quota(student_id)
|
|
|
|
| 274 |
except Exception as e:
|
| 275 |
return f"Error getting queue status: {str(e)}"
|
| 276 |
|
| 277 |
+
@flow
|
| 278 |
def add_to_queue(student_id, R, Y, B):
|
| 279 |
global queue_counter
|
| 280 |
|
|
|
|
| 309 |
try:
|
| 310 |
empty_wells = find_unused_wells()
|
| 311 |
if not empty_wells:
|
| 312 |
+
pause_flow_run(timeout=2)
|
| 313 |
+
print("[TEST] Pause flow for 2 seconds")
|
| 314 |
raise ValueError("No available wells")
|
| 315 |
+
|
| 316 |
selected_well = empty_wells[0]
|
| 317 |
|
| 318 |
|
prefect_utils.py
CHANGED
|
@@ -12,5 +12,14 @@ def start_prefect_worker(work_pool_name: str = "ot2-pool"):
|
|
| 12 |
worker_thread.start()
|
| 13 |
print("Prefect Worker started in background thread.")
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
worker_thread.start()
|
| 13 |
print("Prefect Worker started in background thread.")
|
| 14 |
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
from prefect.blocks.notifications import SlackWebhook
|
| 18 |
+
from prefect.input import RunInput
|
| 19 |
+
|
| 20 |
+
slack_block = SlackWebhook.load("prefect-test")
|
| 21 |
+
class UserInput(RunInput):
|
| 22 |
+
github_username: str
|
| 23 |
+
comments: str = ""
|
| 24 |
+
flag_for_review: bool
|
| 25 |
+
|