Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sphinx/user-guide/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ or :py:func:`vortex.task`, the corresponding Python modules must be
installed as part of a package that declares the ``vtx`` entry point
in its metadata.

The :py:func:`vortex.loaded_plugins` can be used to list currently
loaded plugin packages.

Example
-------

Expand Down
37 changes: 18 additions & 19 deletions src/vortex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""

import atexit
import copy
from pathlib import Path
import sys

Expand All @@ -35,7 +36,6 @@
import importlib.metadata

from bronx.fancies import loggers as bloggers
import bronx.stdtypes.date

import footprints

Expand Down Expand Up @@ -67,6 +67,7 @@
"task",
"promise",
"diff",
"loaded_plugins",
]

# Set vortex specific priorities for footprints usage
Expand Down Expand Up @@ -128,9 +129,24 @@ def vortexfpdefaults():
# will typically depend on objects defined in 'vortex'
# and 'vortex.nwp', these must be imported /before/
# loading plugins.
_LOADED_PLUGINS = set()
for plugin in importlib.metadata.entry_points(group="vtx"):
plugin.load()
print(f"Loaded plugin {plugin.name}")
_LOADED_PLUGINS.add(plugin.name)


def loaded_plugins() -> set[str]:
"""Return the set of names for loaded plugins

**Example:**

.. code:: python

>>> import vortex
>>> vortex.loaded_plugins()
{"gco", "cen"}
"""
return copy.copy(_LOADED_PLUGINS)


# Register proper vortex exit before the end of interpreter session
Expand All @@ -141,26 +157,9 @@ def complete():
for kid in multiprocessing.active_children():
logger.warning("Terminate active kid %s", str(kid))
kid.terminate()
print(
"Vortex",
__version__,
"completed",
"(",
bronx.stdtypes.date.at_second().reallynice(),
")",
)


atexit.register(complete)
del atexit, complete

print(
"Vortex",
__version__,
"loaded",
"(",
bronx.stdtypes.date.at_second().reallynice(),
")",
)

del footprints
Loading