@@ -77,6 +77,7 @@ def callback(
77
77
cache_args_to_ignore : Optional [list ] = None ,
78
78
cache_ignore_triggered = True ,
79
79
on_error : Optional [Callable [[Exception ], Any ]] = None ,
80
+ optional : Optional [bool ] = False ,
80
81
** _kwargs ,
81
82
) -> Callable [..., Any ]:
82
83
"""
@@ -159,6 +160,8 @@ def callback(
159
160
Function to call when the callback raises an exception. Receives the
160
161
exception object as first argument. The callback_context can be used
161
162
to access the original callback inputs, states and output.
163
+ :param optional:
164
+ Mark all dependencies as not required on the initial layout checks.
162
165
"""
163
166
164
167
background_spec = None
@@ -213,6 +216,7 @@ def callback(
213
216
manager = manager ,
214
217
running = running ,
215
218
on_error = on_error ,
219
+ optional = optional ,
216
220
)
217
221
218
222
@@ -258,6 +262,7 @@ def insert_callback(
258
262
running = None ,
259
263
dynamic_creator : Optional [bool ] = False ,
260
264
no_output = False ,
265
+ optional = False ,
261
266
):
262
267
if prevent_initial_call is None :
263
268
prevent_initial_call = config_prevent_initial_callbacks
@@ -281,6 +286,7 @@ def insert_callback(
281
286
},
282
287
"dynamic_creator" : dynamic_creator ,
283
288
"no_output" : no_output ,
289
+ "optional" : optional ,
284
290
}
285
291
if running :
286
292
callback_spec ["running" ] = running
@@ -624,6 +630,7 @@ def register_callback(
624
630
dynamic_creator = allow_dynamic_callbacks ,
625
631
running = running ,
626
632
no_output = not has_output ,
633
+ optional = _kwargs .get ("optional" , False ),
627
634
)
628
635
629
636
# pylint: disable=too-many-locals
0 commit comments