Find answers from the community

Updated 4 weeks ago

Subclassing Workflows: Understanding the Intuition

hello there, I am going through the tutorials of Subclassing workflows here https://docs.llamaindex.ai/en/stable/understanding/workflows/subclass/

I can execute the codes fine. What I don't understand fully is the intuition of subclassing. CustomWorkflow inherits MainWorkflow and step_two now emits Step2BEvent instead of Step3Event. When we do that, are we overwriting the functionality of step_two of MainWorkflow? And to execute the workflow end to end, why are we running CustomWorkflow but not MainWorkflow? I would thought MainWorkflow to encapculate all subclassed workflows (or child workflow if I'm understanding correctly)
L
g
2 comments
I think you are maybe misunderstanding how python classes work?

  1. Yes, we are rewriting step_two, and adding a new step_two_b in between step_two and step_three
  2. We call CustomWorkflow to run it because this is the class with our modified steps
  3. In python, parent classes have no knowledge of their subclasses. MainWorkflow has no idea CustomWorkflow exists. CustomWorkflow subclasses MainWorkflow, but that just means it gets a copy of everything from the main, and then we override select methods
ok point 3 enlightens me. thanks @Logan M !
Add a reply
Sign up and join the conversation on Discord