diff --git a/plugins/annotation/__init__.py b/plugins/annotation/__init__.py index 8a5aaf91..08a9d359 100644 --- a/plugins/annotation/__init__.py +++ b/plugins/annotation/__init__.py @@ -27,6 +27,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -40,7 +42,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): kwargs = ctx.params.copy() @@ -893,6 +895,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -906,7 +910,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): anno_key = ctx.params["anno_key"] @@ -1212,7 +1216,7 @@ def _inject_annotation_secrets(ctx): def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -1221,7 +1225,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(), diff --git a/plugins/brain/__init__.py b/plugins/brain/__init__.py index eb64cb04..418163c0 100644 --- a/plugins/brain/__init__.py +++ b/plugins/brain/__init__.py @@ -34,6 +34,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -47,7 +49,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) @@ -59,10 +61,10 @@ def execute(self, ctx): batch_size = ctx.params.get("batch_size", None) num_workers = ctx.params.get("num_workers", None) skip_failures = ctx.params.get("skip_failures", True) - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) # No multiprocessing allowed when running synchronously - if not delegate: + if not delegate and not ctx.requesting_delegated_execution: num_workers = 0 target_view = _get_target_view(ctx, target) @@ -142,6 +144,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -155,7 +159,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): kwargs = ctx.params.copy() @@ -174,7 +178,7 @@ def execute(self, ctx): _get_similarity_backend(backend).parse_parameters(ctx, kwargs) # No multiprocessing allowed when running synchronously - if not delegate: + if not delegate and not ctx.requesting_delegated_execution: num_workers = 0 target_view = _get_target_view(ctx, target) @@ -939,6 +943,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -952,7 +958,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) @@ -963,10 +969,10 @@ def execute(self, ctx): batch_size = ctx.params.get("batch_size", None) num_workers = ctx.params.get("num_workers", None) skip_failures = ctx.params.get("skip_failures", True) - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) # No multiprocessing allowed when running synchronously - if not delegate: + if not delegate and not ctx.requesting_delegated_execution: num_workers = 0 target_view = _get_target_view(ctx, target) @@ -1035,6 +1041,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -1048,7 +1056,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): kwargs = ctx.params.copy() @@ -1220,6 +1228,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -1233,7 +1243,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) @@ -1814,7 +1824,7 @@ def _inject_brain_secrets(ctx): def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -1823,7 +1833,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(), diff --git a/plugins/evaluation/__init__.py b/plugins/evaluation/__init__.py index bc4bc095..85a4ee05 100644 --- a/plugins/evaluation/__init__.py +++ b/plugins/evaluation/__init__.py @@ -23,6 +23,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -36,7 +38,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): kwargs = ctx.params.copy() @@ -1135,7 +1137,7 @@ def get_new_eval_key( def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -1144,7 +1146,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(), diff --git a/plugins/indexes/__init__.py b/plugins/indexes/__init__.py index 507d0c61..86f4f8ea 100644 --- a/plugins/indexes/__init__.py +++ b/plugins/indexes/__init__.py @@ -20,6 +20,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -33,7 +35,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): create = ctx.params.get("create", []) @@ -326,7 +328,7 @@ def _get_default_indexes(ctx): def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -335,7 +337,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(), diff --git a/plugins/io/__init__.py b/plugins/io/__init__.py index 0b66d780..aa305ca2 100644 --- a/plugins/io/__init__.py +++ b/plugins/io/__init__.py @@ -32,6 +32,8 @@ def config(self): dark_icon="/assets/icon-dark.svg", dynamic=True, execute_as_generator=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def __call__( @@ -171,7 +173,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=types.View(label="Import samples")) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): import_type = ctx.params.get("import_type", None) @@ -1003,6 +1005,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -1015,7 +1019,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=types.View(label="Merge samples")) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): src_type = ctx.params.get("src_type", None) @@ -1387,6 +1391,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -1399,7 +1405,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=types.View(label="Merge labels")) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) @@ -1523,6 +1529,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def __call__( @@ -1722,7 +1730,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=types.View(label="Export samples")) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): _export_samples(ctx) @@ -2505,6 +2513,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -2517,7 +2527,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=types.View(label="Draw labels")) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) @@ -2654,7 +2664,7 @@ def _get_target_view(ctx, target): def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -2663,7 +2673,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(), diff --git a/plugins/plugins/__init__.py b/plugins/plugins/__init__.py index 5cf61bdb..cefa585c 100644 --- a/plugins/plugins/__init__.py +++ b/plugins/plugins/__init__.py @@ -1487,7 +1487,7 @@ def _operator_skeleton_delegation_flow(ctx, inputs): EXECUTION_MODE_CODE = """ def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -1496,7 +1496,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(), @@ -1533,7 +1533,7 @@ def resolve_delegation(self, ctx): elif delegated_execution == "User Choice": code = """ def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) """ else: raise ValueError("Invalid delegation choice") diff --git a/plugins/utils/__init__.py b/plugins/utils/__init__.py index 2c096750..5ae06ee0 100644 --- a/plugins/utils/__init__.py +++ b/plugins/utils/__init__.py @@ -1125,6 +1125,8 @@ def config(self): dark_icon="/assets/icon-dark.svg", dynamic=True, execute_as_generator=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def __call__( @@ -1188,17 +1190,17 @@ def resolve_input(self, ctx): ) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) overwrite = ctx.params.get("overwrite", False) num_workers = ctx.params.get("num_workers", None) - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) view = _get_target_view(ctx, target) - if delegate: + if delegate or ctx.requesting_delegated_execution: view.compute_metadata(overwrite=overwrite, num_workers=num_workers) else: for update in _compute_metadata_generator( @@ -1388,6 +1390,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def __call__( @@ -1479,7 +1483,7 @@ def resolve_input(self, ctx): ) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) @@ -1489,7 +1493,7 @@ def execute(self, ctx): output_dir = ctx.params["output_dir"]["absolute_path"] overwrite = ctx.params.get("overwrite", False) num_workers = ctx.params.get("num_workers", None) - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) view = _get_target_view(ctx, target) @@ -1499,7 +1503,7 @@ def execute(self, ctx): size = (width or -1, height or -1) # No multiprocessing allowed when running synchronously - if not delegate: + if not delegate and not ctx.requesting_delegated_execution: num_workers = 0 foui.transform_images( @@ -1719,7 +1723,7 @@ def _get_target_view(ctx, target): def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -1728,7 +1732,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(), diff --git a/plugins/zoo/__init__.py b/plugins/zoo/__init__.py index a6b5741c..79f1ace2 100644 --- a/plugins/zoo/__init__.py +++ b/plugins/zoo/__init__.py @@ -24,6 +24,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -37,7 +39,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): kwargs = ctx.params.copy() @@ -406,6 +408,8 @@ def config(self): light_icon="/assets/icon-light.svg", dark_icon="/assets/icon-dark.svg", dynamic=True, + allow_immediate_execution=True, + allow_delegated_execution=True, ) def resolve_input(self, ctx): @@ -419,7 +423,7 @@ def resolve_input(self, ctx): return types.Property(inputs, view=view) def resolve_delegation(self, ctx): - return ctx.params.get("delegate", False) + return ctx.params.get("delegate", None) def execute(self, ctx): target = ctx.params.get("target", None) @@ -435,14 +439,14 @@ def execute(self, ctx): skip_failures = ctx.params.get("skip_failures", True) output_dir = ctx.params.get("output_dir", None) rel_dir = ctx.params.get("rel_dir", None) - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) target_view = _get_target_view(ctx, target) model = foz.load_zoo_model(model) # No multiprocessing allowed when running synchronously - if not delegate: + if not delegate and not ctx.requesting_delegated_execution: num_workers = 0 if embeddings and patches_field is not None: @@ -741,7 +745,7 @@ def _get_target_view(ctx, target): def _execution_mode(ctx, inputs): - delegate = ctx.params.get("delegate", False) + delegate = ctx.params.get("delegate", None) if delegate: description = "Uncheck this box to execute the operation immediately" @@ -750,7 +754,7 @@ def _execution_mode(ctx, inputs): inputs.bool( "delegate", - default=False, + default=None, label="Delegate execution?", description=description, view=types.CheckboxView(),