update pause test
Browse files
app.py
CHANGED
|
@@ -10,6 +10,14 @@ 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 |
|
| 15 |
|
|
@@ -224,18 +232,32 @@ def verify_student_id(student_id):
|
|
| 224 |
|
| 225 |
quota_remaining = check_student_quota(student_id)
|
| 226 |
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
return [
|
| 232 |
gr.update(interactive=False, value=0),
|
| 233 |
gr.update(interactive=False, value=0),
|
| 234 |
gr.update(interactive=False, value=0),
|
| 235 |
-
"
|
| 236 |
gr.update(interactive=False)
|
| 237 |
]
|
| 238 |
-
|
| 239 |
return [
|
| 240 |
gr.update(interactive=True, value=0),
|
| 241 |
gr.update(interactive=True, value=0),
|
|
|
|
| 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 |
+
from prefect import get_run_logger, settings
|
| 14 |
+
from prefect.blocks.notifications import SlackWebhook
|
| 15 |
+
from prefect.context import get_run_context
|
| 16 |
+
from prefect.input import RunInput
|
| 17 |
+
|
| 18 |
+
class VerificationInput(RunInput):
|
| 19 |
+
approved: bool
|
| 20 |
+
comments: str = ""
|
| 21 |
|
| 22 |
|
| 23 |
|
|
|
|
| 232 |
|
| 233 |
quota_remaining = check_student_quota(student_id)
|
| 234 |
|
| 235 |
+
logger = get_run_logger()
|
| 236 |
+
flow_run = get_run_context().flow_run
|
| 237 |
+
logger.info(f"Student ID: {student_id} requested verification. Quota remaining: {quota_remaining}")
|
| 238 |
+
|
| 239 |
+
if flow_run and settings.PREFECT_UI_URL:
|
| 240 |
+
flow_run_url = f"{settings.PREFECT_UI_URL.value()}/flow-runs/flow-run/{flow_run.id}"
|
| 241 |
+
logger.info(f"Please review and resume the flow here: {flow_run_url}")
|
| 242 |
+
|
| 243 |
+
user_input = pause_flow_run(
|
| 244 |
+
wait_for_input=VerificationInput.with_initial_data(
|
| 245 |
+
description="Approve this Student ID to continue the experiment?",
|
| 246 |
+
approved=False,
|
| 247 |
+
comments="",
|
| 248 |
+
),
|
| 249 |
+
timeout=600, # 10 minutes
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
if not user_input.approved:
|
| 253 |
return [
|
| 254 |
gr.update(interactive=False, value=0),
|
| 255 |
gr.update(interactive=False, value=0),
|
| 256 |
gr.update(interactive=False, value=0),
|
| 257 |
+
"Student verification rejected",
|
| 258 |
gr.update(interactive=False)
|
| 259 |
]
|
| 260 |
+
|
| 261 |
return [
|
| 262 |
gr.update(interactive=True, value=0),
|
| 263 |
gr.update(interactive=True, value=0),
|