Skip to content

Commit b815c54

Browse files
committed
finish presets when unable to continue the processor chain
1 parent 0c179e9 commit b815c54

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

backend/lib/preset.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class ProcessorPreset(BasicProcessor):
1313
"""
1414
def process(self):
1515
"""
16+
ALL PRESETS MUST PREPEND 'preset-' TO THEIR TYPE.
17+
1618
This queues a series of post-processors to run in sequence, with an
1719
overarching dataset to which the results of the last processor in the
1820
sequence are copied. The processor pipeline is then attached to the

backend/lib/processor.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def after_process(self):
233233

234234
# see if we have anything else lined up to run next
235235
for next in self.parameters.get("next", []):
236+
can_run_next = True
236237
next_parameters = next.get("parameters", {})
237238
next_type = next.get("type", "")
238239
try:
@@ -243,6 +244,7 @@ def after_process(self):
243244

244245
# run it only if the post-processor is actually available for this query
245246
if self.dataset.data["num_rows"] <= 0:
247+
can_run_next = False
246248
self.log.info("Not running follow-up processor of type %s for dataset %s, no input data for follow-up" % (next_type, self.dataset.key))
247249

248250
elif next_type in available_processors:
@@ -257,8 +259,32 @@ def after_process(self):
257259
)
258260
self.queue.add_job(next_type, remote_id=next_analysis.key)
259261
else:
262+
can_run_next = False
260263
self.log.warning("Dataset %s (of type %s) wants to run processor %s next, but it is incompatible" % (self.dataset.key, self.type, next_type))
261264

265+
if not can_run_next:
266+
# We are unable to continue the chain of processors, so we check to see if we are attaching to a parent
267+
# preset; this allows the parent (for example a preset) to be finished and any successful processors displayed
268+
if "attach_to" in self.parameters:
269+
# Probably should not happen, but for some reason a mid processor has been designated as the processor
270+
# the parent should attach to
271+
pass
272+
else:
273+
# Check for "attach_to" parameter in descendents
274+
have_attach_to = False
275+
while not have_attach_to:
276+
if "attach_to" in next_parameters:
277+
self.parameters["attach_to"] = next_parameters["attach_to"]
278+
break
279+
else:
280+
if "next" in next_parameters:
281+
next_parameters = next_parameters["next"]
282+
else:
283+
# No more descendents
284+
# Should not happen; we cannot find the source dataset
285+
break
286+
287+
262288
# see if we need to register the result somewhere
263289
if "copy_to" in self.parameters:
264290
# copy the results to an arbitrary place that was passed

0 commit comments

Comments
 (0)