Skip to content

cat-log tail-end mode - #7414

Open
samuel-denton wants to merge 24 commits into
cylc:masterfrom
samuel-denton:cat-log-tail-mode
Open

cat-log tail-end mode#7414
samuel-denton wants to merge 24 commits into
cylc:masterfrom
samuel-denton:cat-log-tail-mode

Conversation

@samuel-denton

@samuel-denton samuel-denton commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Trio of PRs to add a new tail mode to cat-log and make use of it in the GUI

The three PR's will close

Changes will be documented in cylc-doc:


Added a new mode to cat-log called tail and renamed the old mode to tail_from_start.

Behaviour of the old mode should be identical.

The new tail_from_end mode takes a line_count param as it needs to know where to start tailing from, and can follow as lines are added.

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 if present).
  • Tests are included (or explain why tests are not needed).
  • Changelog entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

Comment thread cylc/flow/scripts/cat_log.py Outdated
Comment thread cylc/flow/cfgspec/globalcfg.py
@hjoliver

hjoliver commented Aug 10, 2026

Copy link
Copy Markdown
Member

Behaviour of the old mode should be identical, but calls will need to be updated from cat-log -t to cat-log -ts. I could switch it so the old mode keeps -t but semantically this makes the most sense to me.

I think your new way is fine as this is an interactive thing, and if users don't realize the semantics have changed they'll still get the end of the file, which is likely what's wanted most of the time anyway.

@hjoliver

Copy link
Copy Markdown
Member

Trying to recall why we need a configurable tail command template. Is it because you (MO) use a custom command to tail job logs in the PBS staging area? Here, we tell PBS to write directly to the final log destination.

… the middle of the log. Also added some markers to the stream so uiserver and ui know where to truncate/pop old lines.
@MetRonnie

MetRonnie commented Aug 14, 2026

Copy link
Copy Markdown
Member

I think the default --mode tail behaviour of the command should stay as the original. The reason we are putting in new behaviour is for the uiserver, where we can update the args passed to the cat-log command as needed (i.e. changing it there to --mode tail-end or whatever you want to call it).

@MetRonnie
MetRonnie self-requested a review August 14, 2026 11:48
Comment thread cylc/flow/cfgspec/globalcfg.py Outdated
@samuel-denton
samuel-denton marked this pull request as ready for review August 26, 2026 14:46
@samuel-denton samuel-denton self-assigned this Aug 26, 2026

@MetRonnie MetRonnie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good

Comment thread tests/unit/scripts/test_cat_log.py Outdated
Comment on lines +101 to +105
platform = {
'tail command template': 'tail -n +1 --follow=name %(filename)s',
'tail from end command template':
'tail -n %(lines)s --follow=name %(filename)s',
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This platform dict looks identical in each test - could be extracted into a class variable?

Or, instead of using a test class, what we would tend to do for this is a @pytest.mark.parametrized test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok makes sense thanks, I'll try that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think i've done that properly this time.

Comment thread cylc/flow/cfgspec/globalcfg.py Outdated
Comment thread cylc/flow/scripts/cat_log.py Outdated
@MetRonnie MetRonnie added this to the 8.7.0 milestone Aug 27, 2026
samuel-denton and others added 2 commits August 27, 2026 13:21
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>

@ChrisPaulBennett ChrisPaulBennett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. Could we bump up the codecov a bit?

Comment thread changes.d/7414.feat.md Outdated
Co-authored-by: Christopher Bennett <christopher.bennett@metoffice.gov.uk>
Comment thread changes.d/7414.feat.md Outdated
Comment thread cylc/flow/cfgspec/globalcfg.py
Comment thread tests/unit/scripts/test_cat_log.py
captured['kwargs'] = kwargs
return 0

monkeypatch.setattr(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
monkeypatch.setattr(
lambda *a, **k: '/remote/workflow/log/job.out',

@samuel-denton samuel-denton Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the suggestion is messed up due to latter commits messing with line numbers? I think this was the intent which I have applied:

    async def mock_remote_cylc_cmd(cmd, platform, **kwargs):
        captured['cmd'] = cmd
        captured['kwargs'] = kwargs
        return 0

    monkeypatch.setattr(
        'cylc.flow.scripts.cat_log.remote_cylc_cmd',
        mock_remote_cylc_cmd
    )
    monkeypatch.setattr(
        'cylc.flow.scripts.cat_log.get_remote_workflow_run_job_dir',
        lambda *a, **k: '/remote/workflow/log/job.out',
    )
    monkeypatch.setattr(
        'cylc.flow.scripts.cat_log.verbosity_to_opts',
        lambda *a, **k: []
    )

@MetRonnie

MetRonnie commented Aug 28, 2026

Copy link
Copy Markdown
Member

821a770 Moved tests from integration to unit (I think appropriately) so they are picked up by codecov.

Mmm, this shouldn't make a difference

samuel-denton and others added 2 commits August 28, 2026 11:49
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
@samuel-denton

samuel-denton commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

821a770 Moved tests from integration to unit (I think appropriately) so they are picked up by codecov.

Mmm, this shouldn't make a difference

Oh, maybe my tests just dont cover what I think they do then :D
Ill let the checks finish and have another go.

Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
@MetRonnie MetRonnie changed the title cat-log Tail Mode cat-log tail-end mode Aug 28, 2026
@samuel-denton

Copy link
Copy Markdown
Contributor Author

I can't seem to patch this gap:
image
I'm sure my tests "test_bad_submit_number()" and "test_good_submit_number()" should cover those cases?

@MetRonnie

MetRonnie commented Aug 28, 2026

Copy link
Copy Markdown
Member

@samuel-denton I'm pretty sure this is a long-standing bug in Codecov that they never fixed: codecov/feedback#556. For example, there are lines that show coverage hits despite being non-executable (e.g. blank lines or comments)!

TLDR; try merging master into your branch, or rebasing onto master

@samuel-denton

Copy link
Copy Markdown
Contributor Author

@samuel-denton I'm pretty sure this is a long-standing bug in Codecov that they never fixed: codecov/feedback#556. For example, there are lines that show coverage hits despite being non-executable (e.g. blank lines or comments)!

TLDR; try merging master into your branch, or rebasing onto master

Ok that seems likely. Ill save the rebase until I am back from holiday as I don't want to rush it.

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