Skip to content

Commit

Permalink
store delegated flag
Browse files Browse the repository at this point in the history
  • Loading branch information
brimoor committed Nov 22, 2024
1 parent 1b8709d commit 2ede748
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 45 deletions.
Binary file not shown.
45 changes: 2 additions & 43 deletions docs/source/plugins/developing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,8 @@ contains the following properties:
instance that you can use to read and write the :ref:`state <panel-state>`
and :ref:`data <panel-data>` of the current panel, if the operator was
invoked from a panel
- `ctx.delegated` - whether delegated execution has been forced for the
operation
- `ctx.requesting_delegated_execution` - whether delegated execution has been
- `ctx.delegated` - whether the operation was delegated
- `ctx.requesting_delegated_execution` - whether delegated execution was
requested for the operation
- `ctx.delegation_target` - the orchestrator to which the operation should be
delegated, if applicable
Expand Down Expand Up @@ -1248,46 +1247,6 @@ of the current view:
to specify the available execution options as described in the previous
section.

Alternatively, you could simply ask the user to decide:

.. code-block:: python
:linenos:
def resolve_input(self, ctx):
delegate = ctx.params.get("delegate", None)
if delegate:
description = "Uncheck this box to execute the operation immediately"
else:
description = "Check this box to delegate execution of this task"
inputs.bool(
"delegate",
label="Delegate execution?",
description=description,
view=types.CheckboxView(),
)
if delegate:
inputs.view(
"notice",
types.Notice(
label=(
"You've chosen delegated execution. Note that you must "
"have a delegated operation service running in order for "
"this task to be processed. See "
"https://docs.voxel51.com/plugins/index.html#operators "
"for more information"
)
),
)
def resolve_delegation(self, ctx):
return ctx.params.get("delegate", None)
.. image:: /images/plugins/operators/operator-user-delegation.png
:align: center

.. _operator-reporting-progress:

Reporting progress
Expand Down
5 changes: 3 additions & 2 deletions fiftyone/operators/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ async def execute_or_delegate_operator(
try:
from .delegated import DelegatedOperationService

ctx.request_params["delegated"] = True
metadata = {"inputs_schema": None, "outputs_schema": None}

try:
Expand Down Expand Up @@ -694,12 +695,12 @@ def panel(self):

@property
def delegated(self):
"""Whether delegated execution has been forced for the operation."""
"""Whether the operation was delegated."""
return self.request_params.get("delegated", False)

@property
def requesting_delegated_execution(self):
"""Whether delegated execution has been requested for the operation."""
"""Whether delegated execution was requested for the operation."""
return self.request_params.get("request_delegation", False)

@property
Expand Down

0 comments on commit 2ede748

Please sign in to comment.