Skip to content

Commit

Permalink
add execution options
Browse files Browse the repository at this point in the history
  • Loading branch information
brimoor committed Jan 15, 2024
1 parent 3bde4f8 commit 3128d5a
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 46 deletions.
12 changes: 8 additions & 4 deletions plugins/annotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand All @@ -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"]
Expand Down Expand Up @@ -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"
Expand All @@ -1221,7 +1225,7 @@ def _execution_mode(ctx, inputs):

inputs.bool(
"delegate",
default=False,
default=None,
label="Delegate execution?",
description=description,
view=types.CheckboxView(),
Expand Down
34 changes: 22 additions & 12 deletions plugins/brain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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"
Expand All @@ -1823,7 +1833,7 @@ def _execution_mode(ctx, inputs):

inputs.bool(
"delegate",
default=False,
default=None,
label="Delegate execution?",
description=description,
view=types.CheckboxView(),
Expand Down
8 changes: 5 additions & 3 deletions plugins/evaluation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand Down Expand Up @@ -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"
Expand All @@ -1144,7 +1146,7 @@ def _execution_mode(ctx, inputs):

inputs.bool(
"delegate",
default=False,
default=None,
label="Delegate execution?",
description=description,
view=types.CheckboxView(),
Expand Down
8 changes: 5 additions & 3 deletions plugins/indexes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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", [])
Expand Down Expand Up @@ -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"
Expand All @@ -335,7 +337,7 @@ def _execution_mode(ctx, inputs):

inputs.bool(
"delegate",
default=False,
default=None,
label="Delegate execution?",
description=description,
view=types.CheckboxView(),
Expand Down
24 changes: 17 additions & 7 deletions plugins/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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__(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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"
Expand All @@ -2663,7 +2673,7 @@ def _execution_mode(ctx, inputs):

inputs.bool(
"delegate",
default=False,
default=None,
label="Delegate execution?",
description=description,
view=types.CheckboxView(),
Expand Down
Loading

0 comments on commit 3128d5a

Please sign in to comment.