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

Adjust gridtk list output to fit terminal width #15

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

183amir
Copy link
Collaborator

@183amir 183amir commented Oct 23, 2024

Fixes #13

Adjust the gridtk list output to fit terminal width and add a --full-output option.

  • src/gridtk/cli.py

    • Update the list_jobs function to adjust column widths based on terminal size.
    • Add logic to truncate long content with ellipses in the list_jobs function.
    • Add a new option --full-output to the list_jobs command to view the full output without truncation.
  • tests/test_gridtk.py

    • Add unit tests to verify the new behavior of the gridtk list command.
    • Add unit tests to verify the --full-output option for the gridtk list command.
  • README.md

    • Update the documentation to reflect the new behavior of the gridtk list command.
    • Add information about the --full-output option for the gridtk list command.
  • .devcontainer.json

    • Add a devcontainer configuration file with tasks for testing, building, and launching the project.

For more details, open the Copilot Workspace session.


📚 Documentation preview 📚: https://gridtk--15.org.readthedocs.build/en/15/

183amir and others added 5 commits October 23, 2024 10:59
Fixes #13

Adjust the `gridtk list` output to fit terminal width and add a `--full-output` option.

* **src/gridtk/cli.py**
  - Update the `list_jobs` function to adjust column widths based on terminal size.
  - Add logic to truncate long content with ellipses in the `list_jobs` function.
  - Add a new option `--full-output` to the `list_jobs` command to view the full output without truncation.

* **tests/test_gridtk.py**
  - Add unit tests to verify the new behavior of the `gridtk list` command.
  - Add unit tests to verify the `--full-output` option for the `gridtk list` command.

* **README.md**
  - Update the documentation to reflect the new behavior of the `gridtk list` command.
  - Add information about the `--full-output` option for the `gridtk list` command.

* **.devcontainer.json**
  - Add a devcontainer configuration file with tasks for testing, building, and launching the project.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/idiap/gridtk/issues/13?shareId=XXXX-XXXX-XXXX-XXXX).
…mmand for improved readability

Also, adjust max column widths for output formatting to accommodate new options
* truncates with only 2 dots
* dynamically adjusts the command column to use all the width of the terminal
Copy link

github-actions bot commented Oct 29, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/gridtk
  cli.py
  manager.py
  models.py
Project Total  

This report was generated by python-coverage-comment-action

@183amir 183amir marked this pull request as ready for review October 29, 2024 23:30
@183amir 183amir requested a review from Yannick-Dayer October 29, 2024 23:30
Copy link
Contributor

@Yannick-Dayer Yannick-Dayer left a comment

Choose a reason for hiding this comment

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

I must have missed the mail for that review.

This is a nice feature!

When testing it however, I noticed issues with both --wrap and --truncate options when using a small terminal width (<=87 for truncate, and <=95 for wrap). The total width somehow exceeds the width of the terminal and wraps some full lines (like the header separator).

list --wrap with width 95
With a terminal width of 95 and the --wrap option. Notice the - of the header separator and the t of submit.

I think this is due to tabulate adding some horizontal padding to some columns despite specifying their maxcolwidths parameters.

@183amir
Copy link
Collaborator Author

183amir commented Nov 26, 2024

Yes, I have found the output of tabulate quite unpreditable regarding this. Not sure what to do here.

@Yannick-Dayer
Copy link
Contributor

One solution to prevent overflows would be to force the padding to 0 (tabulate.MIN_PADDING = 0), but this results in a table that is smaller than it needs and feels more cramped (it leaves a lot of space unused due to most columns ending under their maxcolwidths).

Screenshot from 2024-11-26 22-10-43

@183amir
Copy link
Collaborator Author

183amir commented Nov 27, 2024

could you show a before and after photo? I am not sure I understand what changed.

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.

Adjust gridtk list output to fit terminal width
2 participants