@@ -116,7 +116,6 @@ def __init__(
116116 self ,
117117 fn : Callable [[Any , Context ], R ] | Callable [[Any , Context ], Awaitable [R ]],
118118 type : StepType ,
119- workflow : Union ["BaseWorkflow" , None ] = None ,
120119 name : str = "" ,
121120 timeout : str = "60m" ,
122121 parents : list [str ] = [],
@@ -130,7 +129,7 @@ def __init__(
130129 ) -> None :
131130 self .fn = fn
132131 self .is_async_function = is_async_fn (fn )
133- self .workflow = workflow
132+ self .workflow : Union [ "BaseWorkflow" , None ] = None
134133
135134 self .type = type
136135 self .timeout = timeout
@@ -146,7 +145,9 @@ def __init__(
146145
147146 def call (self , ctx : Context ) -> R :
148147 if not self .is_registered :
149- raise ValueError ("Only steps that have been registered can be called." )
148+ raise ValueError (
149+ "Only steps that have been registered can be called. To register this step, instantiate its corresponding workflow."
150+ )
150151
151152 if self .is_async_function :
152153 raise TypeError (f"{ self .name } is not a sync function. Use `acall` instead." )
@@ -159,7 +160,9 @@ def call(self, ctx: Context) -> R:
159160
160161 async def acall (self , ctx : Context ) -> R :
161162 if not self .is_registered :
162- raise ValueError ("Only steps that have been registered can be called." )
163+ raise ValueError (
164+ "Only steps that have been registered can be called. To register this step, instantiate its corresponding workflow."
165+ )
163166
164167 if not self .is_async_function :
165168 raise TypeError (
@@ -207,6 +210,9 @@ class BaseWorkflow:
207210 def __init__ (self ) -> None :
208211 self .config .name = self .config .name or str (self .__class__ .__name__ )
209212
213+ for step in self .steps :
214+ step .workflow = self
215+
210216 def get_service_name (self , namespace : str ) -> str :
211217 return f"{ namespace } { self .config .name .lower ()} "
212218
0 commit comments