-
Notifications
You must be signed in to change notification settings - Fork 94
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
Tui 1.0 #5731
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
571b27f
Tui 1.0
oliver-sanders b175218
tui: update screenshots
oliver-sanders 6f3f170
tui: fix an obscure freezing issue
oliver-sanders 7b2058c
tui: tidy dangling interfaces
oliver-sanders de23766
tui: log view
oliver-sanders c303aa9
tui: show view
oliver-sanders File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Major upgrade to `cylc tui` which now supports larger workflows and can browse installed workflows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,34 +15,36 @@ | |
# 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] | ||
|
||
View and control running workflows in the terminal. | ||
|
||
(Tui = Terminal User Interface) | ||
|
||
WARNING: Tui is experimental and may break with large flows. | ||
An upcoming change to the way Tui receives data from the scheduler will make it | ||
much more efficient in the future. | ||
Tui allows you to monitor and interact with workflows in a manner similar | ||
to the GUI. | ||
|
||
Press "h" whilst running Tui to bring up the help screen, use the arrow | ||
keys to navigage. | ||
|
||
""" | ||
# TODO: remove this warning once Tui is delta-driven | ||
# https://github.com/cylc/cylc-flow/issues/3527 | ||
|
||
from getpass import getuser | ||
from textwrap import indent | ||
from typing import TYPE_CHECKING | ||
from typing import TYPE_CHECKING, Optional | ||
from urwid import html_fragment | ||
|
||
from cylc.flow.id import Tokens | ||
from cylc.flow.id_cli import parse_id | ||
from cylc.flow.option_parsers import ( | ||
WORKFLOW_ID_ARG_DOC, | ||
OPT_WORKFLOW_ID_ARG_DOC, | ||
CylcOptionParser as COP, | ||
) | ||
from cylc.flow.terminal import cli_function | ||
from cylc.flow.tui import TUI | ||
from cylc.flow.tui.util import suppress_logging | ||
from cylc.flow.tui.app import ( | ||
TuiApp, | ||
TREE_EXPAND_DEPTH | ||
# ^ a nasty solution | ||
) | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -55,57 +57,36 @@ | |
def get_option_parser() -> COP: | ||
parser = COP( | ||
__doc__, | ||
argdoc=[WORKFLOW_ID_ARG_DOC], | ||
argdoc=[OPT_WORKFLOW_ID_ARG_DOC], | ||
# auto_add=False, NOTE: at present auto_add can not be turned off | ||
color=False | ||
) | ||
|
||
parser.add_option( | ||
'--display', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
help=( | ||
'Specify the display technology to use.' | ||
' "raw" for interactive in-terminal display.' | ||
' "html" for non-interactive html output.' | ||
), | ||
action='store', | ||
choices=['raw', 'html'], | ||
default='raw', | ||
) | ||
parser.add_option( | ||
'--v-term-size', | ||
help=( | ||
'The virtual terminal size for non-interactive' | ||
'--display options.' | ||
), | ||
action='store', | ||
default='80,24' | ||
) | ||
|
||
return parser | ||
|
||
|
||
@cli_function(get_option_parser) | ||
def main(_, options: 'Values', workflow_id: str) -> None: | ||
workflow_id, *_ = parse_id( | ||
workflow_id, | ||
constraint='workflows', | ||
def configure_screenshot(v_term_size): | ||
wxtim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
screen = html_fragment.HtmlGenerator() | ||
screen.set_terminal_properties(256) | ||
screen.register_palette(TuiApp.palette) | ||
html_fragment.screenshot_init( | ||
[tuple(map(int, v_term_size.split(',')))], | ||
[] | ||
) | ||
screen = None | ||
if options.display == 'html': | ||
TREE_EXPAND_DEPTH[0] = -1 # expand tree fully | ||
screen = html_fragment.HtmlGenerator() | ||
screen.set_terminal_properties(256) | ||
screen.register_palette(TuiApp.palette) | ||
html_fragment.screenshot_init( | ||
[tuple(map(int, options.v_term_size.split(',')))], | ||
[] | ||
) | ||
return screen, html_fragment | ||
|
||
|
||
try: | ||
TuiApp(workflow_id, screen=screen).main() | ||
@cli_function(get_option_parser) | ||
def main(_, options: 'Values', workflow_id: Optional[str] = None) -> None: | ||
# get workflow ID if specified | ||
if workflow_id: | ||
workflow_id, *_ = parse_id( | ||
workflow_id, | ||
constraint='workflows', | ||
) | ||
tokens = Tokens(workflow_id) | ||
workflow_id = tokens.duplicate(user=getuser()).id | ||
|
||
if options.display == 'html': | ||
for fragment in html_fragment.screenshot_collect(): | ||
print(fragment) | ||
except KeyboardInterrupt: | ||
# start Tui | ||
with suppress_logging(), TuiApp().main(workflow_id): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,3 @@ def list_groups(self): | |
if binding['group'] == name | ||
] | ||
) | ||
|
||
|
||
BINDINGS = Bindings() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.