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: fix log_main_loop and add log_db plugin #4674

Merged
merged 5 commits into from
Mar 3, 2022

Conversation

oliver-sanders
Copy link
Member

@oliver-sanders oliver-sanders commented Feb 10, 2022

Impacts developer plugins not loaded in normal circumstances so a reasonably acceptable thing to sneak into an RC. Otherwise push to 8.1.

(Fixes a bug but not a user-facing one)

Contribute a patch developed during the review of #4581 for logging database operations. This helps keep track of:

  • Database operations.
  • Batching of operations between commit statements.
  • Queries (as in the case of #4581).

Fix an error in the log_main_loop plugin discovered on-route and add a test so it doesn't happen again.

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg and conda-environment.yml.
  • Appropriate tests are included (unit and/or functional).
  • No change log entry required (why? e.g. invisible to users).
  • No documentation update required.

@oliver-sanders oliver-sanders added this to the cylc-8.0rc2 milestone Feb 10, 2022
@oliver-sanders oliver-sanders self-assigned this Feb 10, 2022
@oliver-sanders oliver-sanders force-pushed the main_loop.log_db branch 2 times, most recently from 95df2b0 to 090d7a5 Compare February 11, 2022 13:26
@oliver-sanders
Copy link
Member Author

Add a miscellaneous fix for the conda-build workflow which appears to have broken due to it now detecting the conda activate script itself?

@oliver-sanders
Copy link
Member Author

Failed test tests/k/xtriggers/01-workflow_state.t, poking to see if it's random.

@oliver-sanders oliver-sanders requested a review from wxtim February 21, 2022 12:13
.github/workflows/test_conda-build.yml Outdated Show resolved Hide resolved
.github/workflows/test_conda-build.yml Outdated Show resolved Hide resolved
@@ -18,19 +19,27 @@ jobs:

Copy link
Member

Choose a reason for hiding this comment

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

May want to use actions/setup-python?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think so, this action doesn't use Python?

.github/workflows/test_conda-build.yml Show resolved Hide resolved
.github/workflows/test_conda-build.yml Outdated Show resolved Hide resolved
@MetRonnie MetRonnie mentioned this pull request Feb 21, 2022
7 tasks
@MetRonnie
Copy link
Member

Closing and reopening to get the tests to pick up the changes to master

@MetRonnie MetRonnie closed this Feb 22, 2022
@MetRonnie MetRonnie reopened this Feb 22, 2022
@MetRonnie

This comment was marked as outdated.

Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

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

Looks good but:

  • I'm not clear on what the bug actually was
  • Just noticed a small mistake with the logging
    diff --git a/cylc/flow/main_loop/__init__.py b/cylc/flow/main_loop/__init__.py
    index 4f77c2fde..83da68dc1 100644
    --- a/cylc/flow/main_loop/__init__.py
    +++ b/cylc/flow/main_loop/__init__.py
    @@ -350,9 +350,9 @@ def load(config, additional_plugins=None):
                )[(plugin_name, coro_name)] = coro
                plugins['timings'][(plugin_name, coro_name)] = deque(maxlen=1)
            LOG.debug(
    -            'Loaded main loop plugin "%s": %s',
    -            plugin_name + '\n',
    -            '\n'.join((f'* {x}' for x in log))
    +            'Loaded main loop plugin "%s":\n%s',
    +            plugin_name,
    +            '\n'.join(f'* {x}' for x in log)
            )
            # set the initial state of the plugin
            plugins['state'][plugin_name] = {}

* Plugin had become broken with changes to the way timings are recorded.
* A new main loop plugin for development purposes that logs
  database operations into a .sql file.
* Includes a test for the development main loop plugins to ensure they
  can run to the point of producing output.
@oliver-sanders
Copy link
Member Author

I'm not clear on what the bug actually was

log main loop had been broken, the lack of a functional test had hidden the failure.

(the root cause was a change in the way timings were stored)

Just noticed a small mistake with the logging

Applied.

@oliver-sanders
Copy link
Member Author

Is that the right issue you've linked?

I think it was this one. Needed to inspect the DB calls in order to confirm the changes were doing the right thing.

#4581

Copy link
Member

@wxtim wxtim left a comment

Choose a reason for hiding this comment

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

Nothing here which should block a merge (hence the approval), but a few comments made about spelling & semi-unrelated lack of docstrings.

I also noticed that if you run this for a while the cost of the mainloop plugins increases

image

Is there any housekeeping on this?

I'm not too worried if there isn't because at a rate of increase in the order of 1kb/s ~= 84mb/day which is OK if you aren't running really long running tests.

if data:
data = _normalise(data)
_dump(data, scheduler.workflow_run_dir)
_plot(data, scheduler.workflow_run_dir)


def _normalise(data):
earliest_time = min((
Copy link
Member

Choose a reason for hiding this comment

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

Would I be unreasonable in asking for docstrings for these functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • _normalise normalises the data.
  • _dump json.dumps the data.
  • _plot plots the data.

Copy link
Member

Choose a reason for hiding this comment

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

Is the meaning of "normalise" supposed to be intuitively obvious, without reading the code?

Copy link
Member

Choose a reason for hiding this comment

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

I see the unit test does have a docstring 😁

def test_normalise(test_data):
    """Ensure we correctly normalise the timings against the earliest time."""

tests/functional/rnd/05-main-loop.t Show resolved Hide resolved
tests/unit/main_loop/test_log_main_loop.py Outdated Show resolved Hide resolved
cylc/flow/main_loop/log_db.py Show resolved Hide resolved
tests/functional/rnd/05-main-loop.t Show resolved Hide resolved
@oliver-sanders
Copy link
Member Author

oliver-sanders commented Feb 25, 2022

I also noticed that if you run this for a while the cost of the mainloop plugins increases

That is because the mainloop plugins data is holding the information that was used to generate the graph.

Normally the timing data doesn't accumulate, but if you want to plot it it has to.

Co-authored-by: Tim Pillinger <26465611+wxtim@users.noreply.github.com>
@oliver-sanders
Copy link
Member Author

Merging with two approvals.

@oliver-sanders oliver-sanders merged commit 098a4fd into cylc:master Mar 3, 2022
@oliver-sanders oliver-sanders deleted the main_loop.log_db branch March 3, 2022 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants