Skip to content

Commit 28c8cdd

Browse files
authored
Merge pull request #4 from riniangreani/fix_canfar_running_sessions
Fix canfar running sessions
2 parents 7cab381 + 2bd32c2 commit 28c8cdd

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

automation/canfar_polling.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ def build_running_canfar_session_set(session_df) -> set[str]:
8383
if "status" not in session_df.columns or "id" not in session_df.columns:
8484
return set()
8585

86-
running = session_df[session_df["status"].astype(str).str.lower() == "running"]
86+
running = session_df[
87+
session_df["status"].astype(str).str.lower().isin(
88+
["pending", "running", "terminating", "succeeded", "completed"]
89+
)
90+
]
8791
return {str(x).strip() for x in running["id"].dropna().tolist() if str(x).strip()}
8892

8993

@@ -107,6 +111,7 @@ async def _fetch_prefect_completed_flow_runs(limit: int = 200):
107111
async def _fail_flow_run(flow_run_id, reason: str) -> None:
108112
"""Mark the specified flow-run as FAILED with the given reason/message."""
109113
async with get_client() as client:
114+
await client.cancel_flow_run(flow_run_id=flow_run_id)
110115
await client.set_flow_run_state(
111116
flow_run_id=flow_run_id,
112117
state=Failed(message=reason),

possum_pipeline_control/check_status_and_launch_3Dpipeline_v2.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,7 @@ def run_prefect_db_backup():
493493
ts = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H%M%SZ")
494494
OUTDIR = Path.home() / "prefect-backups"
495495
OUTDIR.mkdir(parents=True, exist_ok=True)
496-
db_file_name = f"prefect-{ts}.sql"
497-
db_backup = OUTDIR / db_file_name
496+
db_backup = OUTDIR / f"prefect-{ts}.sql"
498497

499498
cmd = ["bash", bkpscript, str(db_backup)]
500499
result = subprocess.run(cmd, capture_output=True, text=True)
@@ -514,14 +513,9 @@ def run_prefect_db_backup():
514513
)
515514
# --- Copy to CANFAR ---
516515
print("Copying the backup to CANFAR...")
517-
try:
518-
client = Client()
519-
VOS_FOLDER = "arc:projects/CIRADA/polarimetry/software/prefect-backups"
520-
remote_file = f"{VOS_FOLDER}/{db_file_name}"
521-
client.copy(str(db_backup), remote_file)
522-
print("Backup completed successfully")
523-
except Exception as e:
524-
print(f"Failed to copy backup to CANFAR: {e}")
516+
client = Client()
517+
client.copy(str(db_backup), "arc:projects/CIRADA/polarimetry/software/prefect-backups")
518+
print("Backup completed successfully")
525519

526520
if __name__ == "__main__":
527521
parser = argparse.ArgumentParser(

0 commit comments

Comments
 (0)