@@ -77,6 +77,7 @@ def callback(
7777 cache_args_to_ignore : Optional [list ] = None ,
7878 cache_ignore_triggered = True ,
7979 on_error : Optional [Callable [[Exception ], Any ]] = None ,
80+ optional : Optional [bool ] = False ,
8081 ** _kwargs ,
8182) -> Callable [..., Any ]:
8283 """
@@ -159,6 +160,8 @@ def callback(
159160 Function to call when the callback raises an exception. Receives the
160161 exception object as first argument. The callback_context can be used
161162 to access the original callback inputs, states and output.
163+ :param optional:
164+ Mark all dependencies as not required on the initial layout checks.
162165 """
163166
164167 background_spec = None
@@ -213,6 +216,7 @@ def callback(
213216 manager = manager ,
214217 running = running ,
215218 on_error = on_error ,
219+ optional = optional ,
216220 )
217221
218222
@@ -258,6 +262,7 @@ def insert_callback(
258262 running = None ,
259263 dynamic_creator : Optional [bool ] = False ,
260264 no_output = False ,
265+ optional = False ,
261266):
262267 if prevent_initial_call is None :
263268 prevent_initial_call = config_prevent_initial_callbacks
@@ -281,6 +286,7 @@ def insert_callback(
281286 },
282287 "dynamic_creator" : dynamic_creator ,
283288 "no_output" : no_output ,
289+ "optional" : optional ,
284290 }
285291 if running :
286292 callback_spec ["running" ] = running
@@ -624,6 +630,7 @@ def register_callback(
624630 dynamic_creator = allow_dynamic_callbacks ,
625631 running = running ,
626632 no_output = not has_output ,
633+ optional = _kwargs .get ("optional" , False ),
627634 )
628635
629636 # pylint: disable=too-many-locals
0 commit comments