Nested steps
Heya 👋 quick question to confirm my understanding: do nested steps behave identical to non-nested ones with regards to cache usage after failures?
Specifically, if a nested step fails, would the cached results from all parent steps be reused? Or is the caching of parent steps tied to the success of the (most) inner step(s) somehow?
12 Replies
by nested steps, you mean this?
Yes
This is a pattern that I don't know if I would recommend to use 😅 - but I think that the caching of the parent steps are tied to the success of the inner ones
Hmm yeah it guess it's not super useful when the outer and inner steps' fates are tied (which actually makes sense to be the case).
for curiosity’s sake, why do you want to do nested steps?
The use case I have in mind is where you invoke an external API that returns a list, and then for each result or so you may need to invoke another API. Trying to think how to model that best and wondered if nesting would be helpful here or not.
then I would do something like this:
you also get concurrency (for I/O tasks) for free in this case 🙂
Nice, that looks elegant.
I suppose that would cache succeeded steps at the per-
val
level even if one of the many calls eventually failed?yes, exactly
Great, thanks LuÃs.
FYI, when creating a workflow with an empty ID, it throws an error
I guess that's a bug because the docs say that the ID is optional
Also, when you create a workflow, the
id
property of the workflow is undefined
Also, is there a way to get the workflow id from within a workflow?
And is there any way to make the params from workflow.create()
typed?The empty ID problem is well-known, see multiple other mentions in this channel.
the workflow
run
method has a signature like this:
<Params>
can be your custom type that you can also use on the caller site.
it's probably best for you to ask questions unrelated to the topic of this thread in the main channel.