Hey,
I have a case similar to the video processing example here: Composition — Oban Pro v1.6.4
Composing the steps as Workflow steps work like a charm. However, I’m trying to get one optimization.
In my case, I’m generating AI videos from an input image. Before the actual video can be generated, I need to extract the description of the image using an LLM and then also conditionally do some preprocessing such as cropping.
In other words, there’s the preparation step and the video generation step.
Now, it’s possible that the user generates different videos from the same input image, in which case I don’t want to redo the preparation steps.
If the preparation for that image has already been completed, things are easy – I can just re-use the results.
But it’s possible that the user would start the generation of several videos in a short burst.
So, when e.g. the second request comes in, the preparation for the supplied image has already been started by the first request.
In this case, I’d like to schedule the video generation to when the preparation (that’s already started by the first request) is done.
The current implementation that doesn’t account for this looks something like this
workflow =
Workflow.new()
|> Workflow.put_context(%{input: input, video_request_id: request.id})
|> Workflow.add_workflow(
:preprocess,
Workflow.new(workflow_name: "video-preprocess-#{input.input_image_key}")
|> Workflow.add_cascade(:ensure_extract_subject, &ensure_extract_subject/1)
|> Workflow.add_cascade(:ensure_outpaint, &ensure_outpaint/1, deps: :ensure_extract_subject, max_attempts: 1)
)
|> Workflow.add_cascade(:generate_video, &generate_video/1, deps: :preprocess)
|> Oban.insert_all()
Question: is there some simplish way to identify that there’s already pre-processing in progress for input.input_image_key and in that case schedule generate_video to the end of it while also overriding the context for that delayed generate_video job?






















