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

Tui 1.0 #5731

Merged
merged 6 commits into from
Nov 27, 2023
Merged

Tui 1.0 #5731

merged 6 commits into from
Nov 27, 2023

Conversation

oliver-sanders
Copy link
Member

@oliver-sanders oliver-sanders commented Sep 14, 2023

Remove the "Tui is experimental" notice 🎉

  • Move the data update into another process: Closes tui: improve performance #3527
    • Tui used to contact workflows in the same process it used to run the application.
    • This meant that the app was held in lockstep with the update. If the update took longer than the refresh time it would fall over.
    • This PR puts the updater into another process to break this lockstep so that the application and updater refresh rates can differ.
  • Add multi-workflow capability: Closes tui: list all suites #3464
    • Use the scan pipe to list workflows in Tui the same way we use it in the CylcUIServer.
    • The workflow refresh rate is different to the scan refresh rate.
    • Each workflow node has one child under it, the "spring" node. When you expand this "spring" node, Tui will connect to the workflow and will replace the "spring" node with the workflow tree once the data arrives.
    • When you collapse the workflow node, Tui will disconnect from the workflow.
    • You can expand multiple workflows.
  • Add visual regression testing framework: Closes tui: testing #3530
    • Add a test fixture which launches Tui in a "headless" mode where it's not rendering to a terminal.
    • The fixture has a method to provide user input allowing you to press keys as if there was a terminal running.
    • The fixture has a method for generating HTML screenshots which are then used for visual regression.
    • I.E. if anything changes in the output HTML, then test will fail.
    • This allows us to test navigation, filtering, help screens and more.
    • Tui coverage is now up to ~80%.
  • Add some new functionalities.
    • Log view: support for cylc cat-log.
    • Show view: support for cylc show.
tui2-large.mp4

In the process I spotted an issue with task filtering which looks like it might be a data store thing but requires more investigation, lower priority as filtering is not an issue for the GUI. Until then the task filtering won't work right: #5716

TODO:

  • Niceify the code.
  • Complete restart/reconnect test.
  • Do something better with the Tui header (which is now blank).
  • Investigate test flakyness (workflow states test quite flaky).

Tui integration test failures result in HTML files like this being written into the test directory in ~cylc-run/. When tests fail in CI, these HTML files will be bundled into the artefact so can be inspected locally to determine the cause of the failure:

Screenshot from 2023-09-26 13-17-55

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).
  • CHANGES.md entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/663.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@oliver-sanders oliver-sanders added efficiency For notable efficiency improvements could be better Not exactly a bug, but not ideal. labels Sep 14, 2023
@oliver-sanders oliver-sanders added this to the cylc-8.3.0 milestone Sep 14, 2023
@oliver-sanders oliver-sanders self-assigned this Sep 14, 2023
@@ -0,0 +1,31 @@
<pre><span style="color:#000000;background:#e5e5e5"> </span>
Copy link
Member Author

Choose a reason for hiding this comment

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

I was really hoping GitHub would render this HTML which would make it much easier to review screenshot updates in PRs. Any ideas?

Copy link
Member Author

Choose a reason for hiding this comment

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

The best thing I can come up with is to use some Python lib to render them into png derived files.

@hjoliver
Copy link
Member

Nice, looking forward to this!

@@ -15,34 +15,37 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""cylc tui WORKFLOW
"""cylc tui [WORKFLOW]
Copy link
Member Author

Choose a reason for hiding this comment

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

If you give a workflow, tui will startup, pre-filtered to just that workflow. Press "E" to unset this filtering an view all workflows.

# auto_add=False, NOTE: at present auto_add can not be turned off
color=False
)

parser.add_option(
'--display',
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the HTML testing mode from the Tui script as this is now handled by an integration test fixture.

Comment on lines +249 to +224
# the UI update interval
# NOTE: this is different from the data update interval
UPDATE_INTERVAL = 0.1
Copy link
Member Author

Choose a reason for hiding this comment

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

This means that the UI will look for updates every 0.1 seconds, but the frequency of these updates is determined by the updater which is decoupled and runs to its own clock.

# for now we will exit tui when the workflow is cleaned
# this will change when tui supports multiple workflows
cli_cmd('clean', workflow)
sys.exit(0)
Copy link
Member Author

Choose a reason for hiding this comment

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

Tui used to exit when you cleaned the workflow, but now it can stay open.

Comment on lines +91 to +97
# the maximum time to wait for a workflow update
CLIENT_TIMEOUT = 2
Copy link
Member Author

Choose a reason for hiding this comment

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

If the workflow takes more than 2 seconds to send its response, then it will time out. Tui will put a message under the workflow saying that it has timed out, but will retry with the next update cycle.

Previously both the application and updater used the same update period of 1 second. If it took longer to get the response and do the required processing, then Tui would crash.

Comment on lines +97 to +103
# the interval between workflow data updates
BASE_UPDATE_INTERVAL = 1
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the desired update interval. If it takes longer than 1 second to update the workflow, no problem, the updates just come through slower, no more crashes.

@oliver-sanders
Copy link
Member Author

With Tui now better tested, this brings the project coverage up above 90%!

We still can get more of Tui covered now there's a testing framework for it.

@oliver-sanders oliver-sanders marked this pull request as ready for review September 28, 2023 16:00
@dwsutherland
Copy link
Member

Amazing work 🚀

@oliver-sanders
Copy link
Member Author

(added some extra tests to fill some coverage holes)

@wxtim
Copy link
Member

wxtim commented Oct 13, 2023

Sorry, I think that I found a bug on pressing p in the main view I get this error (sorry, my terminal isn't letting me copy/paste it:

image

@oliver-sanders
Copy link
Member Author

Good spot, the tests cover toggling workflow states using W and filling out the form, but not using the shortcuts. Will fix.

@wxtim

This comment was marked as resolved.

@oliver-sanders

This comment was marked as resolved.

@oliver-sanders
Copy link
Member Author

Would clean-all-stopped be unreasonable to ask for?

Not unreasonable, I think that's just cylc clean '*:stopped' or since clean auto filters out running workflows, just cylc clean '*'.

It might be considered a little dangerous having a button like that kicking about, so we might want to put an "are you sure" check on that which Tui doesn't currently have an interface for.

@oliver-sanders
Copy link
Member Author

* Move the updater into another process.
  This removes the limitation that caused Tui to crash with active workflows.
  Closes cylc#3527
* Add multi-workflow capability.
  Closes cylc#3464
* Add visual regression testing framework.
  Closes cylc#3530
* Fixes an obscure issue where the applications main loop becomes
  suspended as the result of attempting to register an `on_press`
  callback which takes as an argument a Cylc client.
* Even though this callback is not actually called at this point,
  just passing the reference to it appears to be enough to cause
  thread deadlocking because Cylc clients are async based and
  not thread safe.
@oliver-sanders
Copy link
Member Author

oliver-sanders commented Oct 13, 2023

Fixed an issue with "E" not working properly: https://github.com/cylc/cylc-flow/compare/54b7e609af8676c7fcb3b4e8723a50d92ad9c3a7..6f3f1701c1106ecd779b11b08ad4293186678da0

The "E" (reset all workflow filters) binding is the one thing in Tui which we cannot test. This is because in order to prevent Tui from seeing other workflows on the system (outside of the test), we have to use an ID filter. Pressing "E" would reset that filter getting Tui to view everything.

cylc/flow/scripts/tui.py Outdated Show resolved Hide resolved
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.

  • Functional testing of PR.
  • Read function code.
  • Read the testing.

I really enjoyed working through the Raikura test framework. 🐦 !

* Post-refactor clean up of dangling code.
@oliver-sanders
Copy link
Member Author

Training day came around again, added support for cat-log and show.

@wxtim, could you check the last three commits.

@@ -1380,7 +1380,7 @@ def insert_job(self, name, cycle_point, status, job_conf):
name=tproxy.name,
cycle_point=tproxy.cycle_point,
execution_time_limit=job_conf.get('execution_time_limit'),
platform=job_conf.get('platform')['name'],
platform=job_conf['platform']['name'],
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated, spotted during testing.

The .get here wasn't protecting against anything as the default return value of None would cause the ['name'] bit to error anyway.

* Add a log view to tui and add it to the context menu for workflows,
  tasks and jobs.
* Allow raikura sessions to see module-scoped fixtures when appropriate.
* Fix a bug (which only surfaced in tests for some reason) where a
  colour was specified as an empty string which urwid doesn't appear to
  like.
* Add `cylc show` support for tasks in Tui.
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.

This is great. Please stop with the mission creep so that we can merge. Pretty Please.

@oliver-sanders oliver-sanders requested review from markgrahamdawson and removed request for hjoliver November 22, 2023 15:22
@oliver-sanders oliver-sanders merged commit ddeaa97 into cylc:master Nov 27, 2023
20 of 24 checks passed
@oliver-sanders oliver-sanders deleted the tui++ branch November 27, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
could be better Not exactly a bug, but not ideal. efficiency For notable efficiency improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tui: testing tui: improve performance tui: list all suites
5 participants