Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main loop: plugins for periodic functions #3492

Merged
merged 19 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 10 additions & 7 deletions cylc/flow/main_loop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ async def my_startup_coroutine(schd, state):

# plugins must be properly installed, in-place PYTHONPATH meddling will
# not work.
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved

from setuptools import setup

setup(
name='my-plugin',
version='1.0',
Expand All @@ -109,18 +112,14 @@ async def my_startup_coroutine(schd, state):
'my_plugin=my_plugin.my_plugin'
]
}
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved
)

Examples
^^^^^^^^

For examples see the built-in plugins in the :py:mod:`cylc.flow.main_loop`
module which are registered in the Cylc Flow ``setup.cfg`` file.

Registration
^^^^^^^^^^^^

Plugins must be registered using the `cylc.main_loop` entry point.

Coroutines
^^^^^^^^^^

Expand Down Expand Up @@ -152,12 +151,12 @@ async def my_startup_coroutine(schd, state):
.. autofunction:: cylc.flow.main_loop.periodic

"""
import asyncio
from collections import deque
from inspect import (
getmembers,
isfunction
)
from textwrap import indent
from time import time

import pkg_resources
Expand Down Expand Up @@ -324,7 +323,11 @@ def load(config, additional_plugins=None):
try:
module_name = entry_points[plugin_name.replace(' ', '_')]
except KeyError:
raise UserInputError(f'No main-loop plugin: "{plugin_name}"')
raise UserInputError(
f'No main-loop plugin: "{plugin_name}"\n'
+ ' Available plugins:\n'
+ indent('\n'.join(sorted(entry_points)), ' ')
)
# load plugin
try:
module = module_name.load()
Expand Down
3 changes: 3 additions & 0 deletions cylc/flow/main_loop/log_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

This plugin is for Cylc developers debugging the data store.

If ``matplotlib`` is installed this plugin will plot results as a PDF in
the run directory when the suite is shut down (cleanly).

"""
import json
from pathlib import Path
Expand Down
3 changes: 3 additions & 0 deletions cylc/flow/main_loop/log_main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

This plugin is for Cylc developers debugging main loop operations.

If ``matplotlib`` is installed this plugin will plot results as a PDF in
the run directory when the suite is shut down (cleanly).

"""
from collections import deque
import json
Expand Down
3 changes: 3 additions & 0 deletions cylc/flow/main_loop/log_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

Set a sensible interval before running suites.

If ``matplotlib`` is installed this plugin will plot results as a PDF in
the run directory when the suite is shut down (cleanly).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That cleanly note will be helpful too. I stopped the suite a few times with CTRL+C and went looking for the plot, then tried cylc stop five and that worked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a suite abort hook too at some point.


"""

import json
Expand Down
1 change: 0 additions & 1 deletion cylc/flow/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from cylc.flow.daemonize import daemonize
from cylc.flow.exceptions import (
CylcError,
HostSelectException,
PointParsingError,
TaskProxySequenceBoundsError
)
Expand Down