Skip to content

rosie lookup: quick improvements#2903

Merged
ChrisPaulBennett merged 3 commits into
metomi:masterfrom
oliver-sanders:rosie-lookup++
Jul 17, 2025
Merged

rosie lookup: quick improvements#2903
ChrisPaulBennett merged 3 commits into
metomi:masterfrom
oliver-sanders:rosie-lookup++

Conversation

@oliver-sanders
Copy link
Copy Markdown
Member

@oliver-sanders oliver-sanders commented Jun 26, 2025

The rosie lookup interface is more important than it used to be due to the loss of rosie go.

However, the CLI help is not especially informative, especially on the query format.

Additionally, the tabulated output suffers from line wrapping which makes it very hard to read.

This is a quick slapdash attempt to improve the situation for users.

This PR:

  • Improves the docs.
  • Fixes the line wrap issue (caused by broken terminal size detection) - note lines will clip rather than wrapping.
  • Changes the default format to a word-wrapped table (avoids the clipping problem), try the --no-pretty option to see the old format.

@oliver-sanders oliver-sanders added this to the 2.5.0 milestone Jun 26, 2025
@oliver-sanders oliver-sanders requested a review from wxtim June 26, 2025 16:11
@oliver-sanders oliver-sanders self-assigned this Jun 26, 2025
Comment thread metomi/rosie/cli_utils.py
# h, v -> horizontal, vertical
# l, x -> line, cross (i.e. vertex)

# unicode (U_) chars
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Heavily inspired by the Cylc --box format system.

Search the internet for "box drawing characters" for more info.

Comment on lines +424 to +425
print(table(
_rows, header=cols, max_width=terminal_cols, unicode=False
))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just in case someone tries to run this in a 1980s build of emacs or whatever.

Comment on lines -298 to -304
try:
terminal_cols = int(ws_client.popen("stty", "size")[0].split()[1])
except (IndexError, RosePopenError, ValueError):
terminal_cols = None

if terminal_cols == 0:
terminal_cols = None
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The stty size command just does not work when run via the Rose Popener module.

I did try hacking it, but I couldn't figure out what Popener was doing to aggravate stty and gave in.

@oliver-sanders oliver-sanders force-pushed the rosie-lookup++ branch 3 times, most recently from d063d30 to f34d090 Compare June 27, 2025 13:36
Comment thread metomi/rosie/cli_utils.py Outdated
Comment thread metomi/rosie/cli_utils.py Outdated
Comment thread metomi/rosie/cli_utils.py Outdated
Comment thread metomi/rosie/cli_utils.py Outdated
Copy link
Copy Markdown
Contributor

@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.

Happy that this will work as is. Happy to approve once you've decided what you want to do with the subprocess.

* Fix broken terminal width detection.
* Change default format to a table
@oliver-sanders
Copy link
Copy Markdown
Member Author

I've tested the shutil.get_terminal_size interface in various places and it seems to work well 👍, have converted both existing uses of stty over.

@ChrisPaulBennett
Copy link
Copy Markdown
Contributor

What is causing the doc check failure? Sphinx is complaining about a dead link, but the link is fine.

@oliver-sanders
Copy link
Copy Markdown
Member Author

oliver-sanders commented Jul 11, 2025

Hmm, I wonder if StackOverflow is protecting against web crawlers, perhaps our test looks a little fishy? The link has passed the test in the past and still seems to work.

@ChrisPaulBennett ChrisPaulBennett merged commit 788618c into metomi:master Jul 17, 2025
9 of 10 checks passed
@oliver-sanders oliver-sanders deleted the rosie-lookup++ branch July 17, 2025 12:47
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.

3 participants