Skip to content

Commit

Permalink
cleanup builtin plugins interface
Browse files Browse the repository at this point in the history
  • Loading branch information
brimoor committed Jan 1, 2025
1 parent fddb6a4 commit 6bbc7fe
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 104 deletions.
6 changes: 6 additions & 0 deletions docs/generate_docs.bash
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ sphinx-apidoc --force --no-toc --separate --follow-links \
--templatedir=docs/templates/apidoc \
-o docs/source/api fiftyone \
fiftyone/brain/internal/models \
fiftyone/constants \
fiftyone/internal \
fiftyone/server \
fiftyone/service \
fiftyone/management \
fiftyone/api

sphinx-apidoc --force --no-toc --separate --follow-links \
--templatedir=docs/templates/apidoc \
-o docs/source/plugins/api plugins

# Remove symlink
unlink fiftyone/brain

Expand Down
44 changes: 29 additions & 15 deletions docs/source/cli/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -830,19 +830,19 @@ Tools for working with FiftyOne operators and panels.
available commands:
{list,info}
list List operators and panels that you've installed locally.
info Prints information about operators and panels that you've installed locally.
list List operators and panels that are installed locally.
info Prints information about operators and panels that are installed locally.
.. _cli-fiftyone-operators-list:

List operators
~~~~~~~~~~~~~~

List operators and panels that you've installed locally.
List operators and panels that are installed locally.

.. code-block:: text
fiftyone operators list [-h] [-e] [-d] [-o] [-p] [-n]
fiftyone operators list [-h] [-e] [-d] [-b] [-c] [-o] [-p] [-n]
**Arguments**

Expand All @@ -852,6 +852,8 @@ List operators and panels that you've installed locally.
-h, --help show this help message and exit
-e, --enabled only show enabled operators and panels
-d, --disabled only show disabled operators and panels
-b, --builtins-only only show builtin operators and panels
-c, --no-builtins only show non-builtin operators and panels
-o, --operators-only only show operators
-p, --panels-only only show panels
-n, --names-only only show names
Expand All @@ -875,15 +877,20 @@ List operators and panels that you've installed locally.
.. code-block:: shell
# Only list panels
# List non-builtin operators and panels
fiftyone operators list --no-builtins
.. code-block:: shell
# List panels
fiftyone operators list --panels-only
.. _cli-fiftyone-operators-info:

Operator info
~~~~~~~~~~~~~

Prints information about operators and panels that you've installed locally.
Prints information about operators and panels that are installed locally.

.. code-block:: text
Expand Down Expand Up @@ -1169,8 +1176,8 @@ Tools for working with FiftyOne plugins.
available commands:
{list,info,download,requirements,create,enable,disable,delete}
list List plugins that you've downloaded or created locally.
info Prints information about plugins that you've downloaded or created
list List plugins that are installed locally.
info Prints information about plugins that are installed locally.
download Download plugins from the web.
requirements Handles package requirements for plugins.
create Creates or initializes a plugin.
Expand All @@ -1183,21 +1190,23 @@ Tools for working with FiftyOne plugins.
List plugins
~~~~~~~~~~~~

List plugins that you've downloaded or created locally.
List plugins that are installed locally.

.. code-block:: text
fiftyone plugins list [-h] [-e] [-d] [-n]
fiftyone plugins list [-h] [-e] [-d] [-b] [-c] [-n]
**Arguments**

.. code-block:: text
optional arguments:
-h, --help show this help message and exit
-e, --enabled only show enabled plugins
-d, --disabled only show disabled plugins
-n, --names-only only show plugin names
-h, --help show this help message and exit
-e, --enabled only show enabled plugins
-d, --disabled only show disabled plugins
-b, --builtins-only only show builtin plugins
-c, --no-builtins only show non-builtin plugins
-n, --names-only only show plugin names
**Examples**

Expand All @@ -1216,12 +1225,17 @@ List plugins that you've downloaded or created locally.
# List disabled plugins
fiftyone plugins list --disabled
.. code-block:: shell
# List non-builtin plugins
fiftyone plugins list --no-builtins
.. _cli-fiftyone-plugins-info:

Plugin info
~~~~~~~~~~~

List plugins that you've downloaded or created locally.
List plugins that are installed locally.

.. code-block:: text
Expand Down
12 changes: 5 additions & 7 deletions docs/source/plugins/developing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ more complex workflows such as requesting annotation of samples from a
configurable backend. Operators can even be composed of other operators or be
used to add functionality to custom panels.

FiftyOne comes with a number of builtin
:mod:`Python <fiftyone.operators.builtin.operations>` and
FiftyOne comes with a number of builtin :mod:`Python <plugins.operators>` and
`JavaScript <https://github.com/voxel51/fiftyone/blob/develop/app/packages/operators/src/built-in-operators.ts>`_
operators for common tasks that are intended for either user-facing or internal
plugin use.
Expand Down Expand Up @@ -676,7 +675,7 @@ outputs. They can be :ref:`executed <using-operators>` by users in the App or
triggered internally by other operators.

Operators can be defined in either Python or JS, and FiftyOne comes with a
number of builtin :mod:`Python <fiftyone.operators.builtin>` and
number of builtin :mod:`Python <plugins.operators>` and
`JS <https://github.com/voxel51/fiftyone/blob/develop/app/packages/operators/src/built-in-operators.ts>`_
operators for common tasks.

Expand Down Expand Up @@ -1405,11 +1404,10 @@ method via :meth:`ctx.ops <fiftyone.operators.operations.Operations>` and
:meth:`ctx.trigger <fiftyone.operators.executor.ExecutionContext.trigger>`.

The :meth:`ctx.ops <fiftyone.operators.operations.Operations>` property of an
execution context exposes all builtin
:mod:`Python <fiftyone.operators.builtin>` and
execution context exposes all builtin :mod:`Python <plugins.operators>` and
`JavaScript <https://github.com/voxel51/fiftyone/blob/develop/app/packages/operators/src/built-in-operators.ts>`_
in a conveniently documented functional interface. For example, many operations
involve updating the current state of the App:
operators in a conveniently documented functional interface. For example, many
operations involve updating the current state of the App:

.. code-block:: python
:linenos:
Expand Down
1 change: 1 addition & 0 deletions docs/source/plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ App? Just open the :ref:`Embeddings panel <app-embeddings-panel>`:
Overview <self>
Using plugins <using_plugins>
Developing plugins <developing_plugins>
API reference <api/plugins>
TypeScript API reference <ts-api>
6 changes: 3 additions & 3 deletions docs/source/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ SDK
- Improved support for creating summary fields and indexes
`#5091 <https://github.com/voxel51/fiftyone/pull/5091>`_
- Added support for creating compound indexes when using the builtin
:class:`create_index <fiftyone.operators.builtin.CreateIndex>` operator that
:class:`create_index <plugins.operators.CreateIndex>` operator that
optimize sidebar queries for group datasets
`#5174 <https://github.com/voxel51/fiftyone/pull/5174>`_
- The builtin
:class:`clear_sample_field <fiftyone.operators.builtin.ClearSampleField>`
:class:`clear_sample_field <plugins.operators.ClearSampleField>`
and
:class:`clear_frame_field <fiftyone.operators.builtin.ClearFrameField>`
:class:`clear_frame_field <plugins.operators.ClearFrameField>`
operators now support clearing fields of views, in addition to full datasets
`#5122 <https://github.com/voxel51/fiftyone/pull/5122>`_
- Fixed a bug that prevented users with `pydantic` installed from loading the
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/evaluation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ When you evaluate a model in FiftyOne, you get access to the standard aggregate
metrics such as classification reports, confusion matrices, and PR curves
for your model. In addition, FiftyOne can also record fine-grained statistics
like accuracy and false positive counts at the sample-level, which you can
:ref:`interactively explore <model-evaluation-panel>` in the App to diagnose
:ref:`interactively explore <app-model-evaluation-panel>` in the App to diagnose
the strengths and weaknesses of your models on individual data samples.

Sample-level analysis often leads to critical insights that will help you
Expand Down
77 changes: 63 additions & 14 deletions fiftyone/core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2905,7 +2905,7 @@ def execute(parser, args):


class OperatorsListCommand(Command):
"""List operators and panels that you've installed locally.
"""List operators and panels that are installed locally.
Examples::
Expand All @@ -2918,7 +2918,10 @@ class OperatorsListCommand(Command):
# List disabled operators and panels
fiftyone operators list --disabled
# Only list panels
# List non-builtin operators and panels
fiftyone operators list --no-builtins
# List panels
fiftyone operators list --panels-only
"""

Expand All @@ -2938,12 +2941,26 @@ def setup(parser):
default=None,
help="only show disabled operators and panels",
)
parser.add_argument(
"-b",
"--builtins-only",
action="store_true",
default=None,
help="only show builtin operators and panels",
)
parser.add_argument(
"-c",
"--no-builtins",
action="store_true",
default=None,
help="only show non-builtin operators and panels",
)
parser.add_argument(
"-o",
"--operators-only",
action="store_true",
default=None,
help="only show operators",
help="only show non-panel operators",
)
parser.add_argument(
"-p",
Expand All @@ -2968,18 +2985,25 @@ def execute(parser, args):
else:
enabled = "all"

if args.builtins_only:
builtin = True
elif args.no_builtins:
builtin = False
else:
builtin = "all"

if args.operators_only:
type = "operator"
elif args.panels_only:
type = "panel"
else:
type = None

_print_operators_list(enabled, type, args.names_only)
_print_operators_list(enabled, builtin, type, args.names_only)


def _print_operators_list(enabled, type, names_only):
operators = foo.list_operators(enabled=enabled, type=type)
def _print_operators_list(enabled, builtin, type, names_only):
operators = foo.list_operators(enabled=enabled, builtin=builtin, type=type)

if names_only:
operators_map = defaultdict(list)
Expand Down Expand Up @@ -3016,7 +3040,7 @@ def _print_operators_list(enabled, type, names_only):


class OperatorsInfoCommand(Command):
"""Prints info about operators and panels that you've installed locally.
"""Prints info about operators and panels that are installed locally.
Examples::
Expand Down Expand Up @@ -3498,7 +3522,7 @@ def execute(parser, args):


class PluginsListCommand(Command):
"""List plugins that you've installed locally.
"""List plugins that are installed locally.
Examples::
Expand All @@ -3510,6 +3534,9 @@ class PluginsListCommand(Command):
# List disabled plugins
fiftyone plugins list --disabled
# List non-builtin plugins
fiftyone plugins list --no-builtins
"""

@staticmethod
Expand All @@ -3528,6 +3555,20 @@ def setup(parser):
default=None,
help="only show disabled plugins",
)
parser.add_argument(
"-b",
"--builtins-only",
action="store_true",
default=None,
help="only show builtin plugins",
)
parser.add_argument(
"-c",
"--no-builtins",
action="store_true",
default=None,
help="only show non-builtin plugins",
)
parser.add_argument(
"-n",
"--names-only",
Expand All @@ -3544,11 +3585,18 @@ def execute(parser, args):
else:
enabled = "all"

_print_plugins_list(enabled, args.names_only)
if args.builtins_only:
builtin = True
elif args.no_builtins:
builtin = False
else:
builtin = "all"

_print_plugins_list(enabled, builtin, args.names_only)


def _print_plugins_list(enabled, names_only):
plugin_defintions = fop.list_plugins(enabled=enabled)
def _print_plugins_list(enabled, builtin, names_only):
plugin_defintions = fop.list_plugins(enabled=enabled, builtin=builtin)

if names_only:
for pd in plugin_defintions:
Expand All @@ -3558,14 +3606,15 @@ def _print_plugins_list(enabled, names_only):

enabled_plugins = set(fop.list_enabled_plugins())

headers = ["plugin", "version", "enabled", "directory"]
headers = ["plugin", "version", "enabled", "builtin", "directory"]
rows = []
for pd in plugin_defintions:
rows.append(
{
"plugin": pd.name,
"version": pd.version or "",
"enabled": pd.name in enabled_plugins,
"enabled": pd.builtin or pd.name in enabled_plugins,
"builtin": pd.builtin,
"directory": pd.directory,
}
)
Expand All @@ -3577,7 +3626,7 @@ def _print_plugins_list(enabled, names_only):


class PluginsInfoCommand(Command):
"""Prints info about plugins that you've installed locally.
"""Prints info about plugins that are installed locally.
Examples::
Expand Down
Loading

0 comments on commit 6bbc7fe

Please sign in to comment.