Skip to content

Commit

Permalink
Add a new entry_point for xtriggers
Browse files Browse the repository at this point in the history
This creates a clean way to add xtriggers from python packages.
xtriggers no longer need to be directly in the PYTHONPATH.
  • Loading branch information
ThomasColemanBoM committed Nov 21, 2023
1 parent eb769d8 commit aa170b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cylc/flow/scripts/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,20 @@ def install(
exc
) from None

for entry_point in iter_entry_points(
'cylc.xtriggers'
):
try:
entry_point.resolve()()
except Exception as exc:
# NOTE: except Exception (purposefully vague)
# this is to separate plugin from core Cylc errors
raise PluginError(
'cylc.xtriggers',
entry_point.name,
exc
) from None

print(f'INSTALLED {workflow_id} from {source_dir}')

return workflow_name, workflow_id
6 changes: 6 additions & 0 deletions cylc/flow/subprocpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@

_XTRIG_FUNCS: dict = {}

# Add in xtriggers from entry_points for external sources
for entry_point in iter_entry_points('cylc.xtriggers'):
entry = entry_point.resolve()()
for func_name, func in entry.items():
_XTRIG_FUNCS[func_name] = func


def _killpg(proc, signal):
"""Kill a process group."""
Expand Down

0 comments on commit aa170b1

Please sign in to comment.