CreateProcessFailures endpoint
https://redmine.teklia.com/issues/6972
A new CreateProcessFailures
endpoint should be introduced, at /api/v1/process/{id}/process-failures/
. It takes a process ID and creates a new Workers
process on the same corpus. New ProcessElement
items must be created to select all of the WorkerActivities that were in an error
state in the original process. The existing worker runs or any other configuration is ignored.
This is the equivalent of these two API calls, but without using the selection:
client.request("SelectProcessFailures", id=process["id"])
client.request("CreateProcess", body={"corpus": process["corpus"], "selection": True})
The process and process element creation must run in a transaction to avoid having a process without any elements, or a process with only a portion of the elements. You can add all the elements from the original processes activities in two queries:
new_process.elements.add(original_process.activities.values_list('element_id', flat=True).distinct())
This causes a round-trip where all the element UUIDs are retrieved from the database and sent back again, so we might hit some performance issues if we try to make processes with millions of failures, but we will wait and see how many failures we really need to handle before going further.