Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.

Commit 497f8fa

Browse files
committed
Make flow planning atomic
1 parent 4f4e21a commit 497f8fa

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

punchpipe/control/scheduler.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ def generic_scheduler_flow_logic(
111111
database_flow_info = construct_child_flow_info(parent_files, children_files,
112112
pipeline_config, session=session,
113113
reference_time=reference_time, **args_dictionary)
114+
# We've had some failures where a flow reports "no associated files", despite the output files having
115+
# their processing_flow set properly. Best guess is the DB is running slow, and so the new flow has been
116+
# committed but the files' processing_flow hasn't been updated yet. So let's not let the state be
117+
# 'planned' until everything is in place.
118+
database_flow_info.state = 'being_planned'
114119
if backprocess_cutoff := pipeline_config.get('prioritize_most_recent_n_days', None):
115120
cutoff = datetime.now(UTC) - timedelta(days=backprocess_cutoff)
116121
if all(cf.date_obs.replace(tzinfo=UTC) < cutoff for cf in children_files):
@@ -138,5 +143,7 @@ def generic_scheduler_flow_logic(
138143
for parent_file, child_file in iterable:
139144
session.add(FileRelationship(parent=parent_file.file_id, child=child_file.file_id))
140145

146+
database_flow_info.state = 'planned'
147+
141148
session.commit()
142149
return len(ready_files)

0 commit comments

Comments
 (0)