@@ -98,18 +98,27 @@ def assign_workflow_id(self) -> str:
9898 wfid = str (uuid .uuid4 ())
9999 return wfid
100100
101- def start_workflow (self , wfid : Optional [str ], attributes : TracedAttributes ) -> None :
101+ def start_workflow (
102+ self ,
103+ wfid : Optional [str ],
104+ attributes : TracedAttributes ,
105+ is_temp_workflow : bool = False ,
106+ ) -> None :
102107 if wfid is None or len (wfid ) == 0 :
103108 wfid = self .assign_workflow_id ()
104109 self .id_assigned_for_next_workflow = ""
105110 self .workflow_id = wfid
106111 self .function_id = 0
107- self ._start_span (attributes )
112+ if not is_temp_workflow :
113+ self ._start_span (attributes )
108114
109- def end_workflow (self , exc_value : Optional [BaseException ]) -> None :
115+ def end_workflow (
116+ self , exc_value : Optional [BaseException ], is_temp_workflow : bool = False
117+ ) -> None :
110118 self .workflow_id = ""
111119 self .function_id = - 1
112- self ._end_span (exc_value )
120+ if not is_temp_workflow :
121+ self ._end_span (exc_value )
113122
114123 def is_within_workflow (self ) -> bool :
115124 return len (self .workflow_id ) > 0
@@ -349,6 +358,7 @@ class EnterDBOSWorkflow(AbstractContextManager[DBOSContext, Literal[False]]):
349358 def __init__ (self , attributes : TracedAttributes ) -> None :
350359 self .created_ctx = False
351360 self .attributes = attributes
361+ self .is_temp_workflow = attributes ["name" ] == "temp_wf"
352362
353363 def __enter__ (self ) -> DBOSContext :
354364 # Code to create a basic context
@@ -359,7 +369,7 @@ def __enter__(self) -> DBOSContext:
359369 _set_local_dbos_context (ctx )
360370 assert not ctx .is_within_workflow ()
361371 ctx .start_workflow (
362- None , self .attributes
372+ None , self .attributes , self . is_temp_workflow
363373 ) # Will get from the context's next workflow ID
364374 return ctx
365375
@@ -371,7 +381,7 @@ def __exit__(
371381 ) -> Literal [False ]:
372382 ctx = assert_current_dbos_context ()
373383 assert ctx .is_within_workflow ()
374- ctx .end_workflow (exc_value )
384+ ctx .end_workflow (exc_value , self . is_temp_workflow )
375385 # Code to clean up the basic context if we created it
376386 if self .created_ctx :
377387 _clear_local_dbos_context ()
0 commit comments