Skip to content

Poc gui #739

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

Draft
wants to merge 55 commits into
base: dev
Choose a base branch
from
Draft

Poc gui #739

wants to merge 55 commits into from

Conversation

ebba-eliasson
Copy link

Read this before submitting the PR

  1. Always create a Draft PR first
  2. Go through sections 1-5 below, fill them in and check all the boxes
  3. Make sure that the branch is updated; if there's an "Update branch" button at the bottom of the PR, rebase or update branch.
  4. When all boxes are checked, information is filled in, and the branch is updated: mark as Ready For Review and tag reviewers (top right)
  5. Once there is a submitted review, implement the suggestions (if reasonable, otherwise discuss) and request an new review.

If there is a field which you are unsure about, enter the edit mode of this description or go to the PR template; There are invisible comments providing descriptions which may be of help.

1. Description / Summary

Add a summary here: What does this PR add/change and why?

POC fot the DDS CLI new GUI/TUI

2. Jira task / GitHub issue

Is this a GitHub issue? --> Add the link to the github issue

Is this from a Jira task? --> If your branch does not contain info regarding the Jira task ID, put it here.

HMS-2332

3. Type of change - Add label

What type of change(s) does the PR contain? For an explanation of the different options below, enter edit mode of this PR description template.

If you do not want this change to be included in release notes, add the label skip-changelog.

  • New feature
    • Breaking --> label: breaking
    • Non-breaking --> label: feature
  • Database change --> label: feature or none at all.
    Remember the to include a new migration version, or explain here why it's not needed.
  • Bug fix --> label: bug
  • Security Alert fix
    • Package update --> label: dependency
      • Major version update
  • Documentation --> label can be skipped, will be included in "other changes"
  • Workflow --> label: skip-changelog
  • Tests only --> label: skip-changelog

4. Additional information

5. Actions / Scans

Make sure that the following checks/actions have passed.

  • Black
  • Prettier
  • Pylint
  • Yamllint
  • Tests
  • CodeQL
  • Trivy
  • Snyk
  • TestPyPI

If an action does not pass and you need help with how to solve it, enter edit mode of this PR template or go to the PR template.

Copy link

codecov bot commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 50.44643% with 222 lines in your changes missing coverage. Please review.

Project coverage is 48.74%. Comparing base (b2a295c) to head (6378544).
Report is 41 commits behind head on dev.

Files with missing lines Patch % Lines
dds_cli/gui_poc/pages/dds_auth.py 40.96% 49 Missing ⚠️
dds_cli/gui_poc/pages/dds_base_page.py 44.11% 38 Missing ⚠️
dds_cli/user.py 14.28% 36 Missing ⚠️
dds_cli/gui_poc/utils.py 51.72% 28 Missing ⚠️
dds_cli/gui_poc/components/dds_modal.py 42.50% 23 Missing ⚠️
dds_cli/gui_poc/pages/dds_home.py 61.11% 14 Missing ⚠️
dds_cli/gui_poc/app.py 72.00% 7 Missing ⚠️
dds_cli/gui_poc/components/dds_text_item.py 73.68% 5 Missing ⚠️
dds_cli/__main__.py 50.00% 4 Missing ⚠️
dds_cli/base.py 63.63% 4 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #739      +/-   ##
==========================================
+ Coverage   47.78%   48.74%   +0.96%     
==========================================
  Files          31       44      +13     
  Lines        2890     3315     +425     
==========================================
+ Hits         1381     1616     +235     
- Misses       1509     1699     +190     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@valyo
Copy link
Member

valyo commented Mar 21, 2025

I give it a try and this time I got blanc terminal when I ran "dds gui". No error in the container log.
When I switched to the commit I previously tested

commit aaf063c8e14f2fde2cd7904eba67e5a19690727b (HEAD)                                                                                                                                                                               [0/858]
Author: ebba-eliasson <ebba.eliasson@scilifelab.se>
Date:   Wed Mar 19 09:24:37 2025 +0100

    Auth commands done

it worked again (without the user functionality obviously). So it must be something in the last two commits.
@ebba-eliasson does it work for you in the docker environment?

@i-oden
Copy link
Member

i-oden commented Mar 24, 2025

@ebba-eliasson I'm also getting an empty terminal atm

@valyo
Copy link
Member

valyo commented Mar 24, 2025

@ebba-eliasson I'm also getting an empty terminal atm

I had an empty terminal and what, I suspect, helped was to first run the dds command normally without the gui
Question remains, why it behaves so, but hopefully this can help you, @i-oden, to test it

@ebba-eliasson
Copy link
Author

@i-oden @valyo I have located the issue, seems to be that components are loaded before I though they loaded (introduced thought the user info page). A solution until I fix it is to authenticate yourself using the "dds auth login" command and then run dds gui to look at it.

Copy link
Member

@i-oden i-oden left a comment

Choose a reason for hiding this comment

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

This looks great, you've done an awesome job! 🎉

I've added a bunch of comments and sometimes they may be in the wrong place so sorry about that, but I think it's fairly understandable what I mean. If not, just ask!

Also, I didn't dive in to all the code details atm, I mainly went on functionality now, so I'll do another review, but this review is already quite wordy so I think lets start there. I have focused on details though. I think before we continue with any more of the functionality (e.g. projects etc) we should decide on what we have atm.

@@ -168,6 +171,16 @@ def dds_main(click_ctx, verbose, log_file, no_prompt, token_path):
# Create context object
click_ctx.obj = {"NO_PROMPT": no_prompt, "TOKEN_PATH": token_path}

### GUI COMMAND ###

@dds_main.command(name="gui")
Copy link
Member

Choose a reason for hiding this comment

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

Should be able to make an "executable" for only GUI right? Which in this case would start the GUI command after clicking the file?

Copy link
Member

Choose a reason for hiding this comment

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

I just want to make sure that the GUI actually avoids commands all together

Copy link
Author

Choose a reason for hiding this comment

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

Should be the case, will look into that though. Right now it uses the click context for getting the token path, so we would just need some util for getting that.

Copy link
Author

Choose a reason for hiding this comment

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

@i-oden from the textual documentation it is suggested to use https://textual.textualize.io/how-to/package-with-hatch/#installing-the-calculator, but other options seems to work as well Textualize/textual#4512


### Issues with the PyQt implementation

The idea was to use PyQt6 as a framework for building the GUI for the DDS but Pyqt dont work on alpine and hence would not install in the container enviroment. In addition to this, there is benfifits using a TUI (Terminal UI) as some users are **only** able to run dds in the terminal. There is no loss in functionallity switching from pyqt to textualize. Textualize is confirmed to work with the current docker setup.
Copy link
Member

Choose a reason for hiding this comment

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

We have been discussing switching from Alpine -- if we think that PyQT is better than we should switch.
Re: some users only being able to run the dds in the terminal -- as long as the users don't have to run any commands to start the GUI (as in they can, but they don't have to), then I'm ok with Textualize.

Copy link
Author

Choose a reason for hiding this comment

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

  • After working with both frameworks I would not say that pyqt is better than textualize or vice versa, they are good at different things and functionality wise both would work fine.
  • It generally seems to be some issues sometimes with the pyqt build.
  • As per previous discussion, will look at stating textualize without terminal.

Copy link
Author

Choose a reason for hiding this comment

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

Update on the pyqt build: There is additional problems, with builds timing out running the instalment of pyqt on say python:3.12 image.

FROM python:3.12

RUN apt-get update && apt-get install -y \
    g++ \
    gcc \
    make \
    cmake \
    musl-dev \
    libffi-dev \
    qt6-base-dev \
    qt6-base-private-dev 


ENV PATH="/usr/lib/qt6/bin:${PATH}"

RUN pip install PyQt6

self.user_info = {"Not authenticated": "Please login to DDS."}

if self.user_info:
self.add_column("Key")
Copy link
Member

Choose a reason for hiding this comment

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

We need to think of either another display or changing to something else than "Key" and "Value"

Copy link
Author

Choose a reason for hiding this comment

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

Should be possible to have a table display without a header

Copy link
Author

Choose a reason for hiding this comment

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

Or use a list view or something.

if self.user_info:
self.add_column("Key")
self.add_column("Value")
for key, value in self.user_info.items():
Copy link
Member

Choose a reason for hiding this comment

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

I'd also like us to rearrage the order of these at some point so that they are displayed in the following order:

  1. username
  2. role
  3. name
  4. primary email
  5. all emails

Copy link
Author

Choose a reason for hiding this comment

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

Will leave right now until we decide on how to display.

### Comments

- For some cli functions it's enough to just add a return statement in the method
- The authentication would need to be either reformated or adding a parallel authentication for the gui --> could be a better solution to rewrite the authenticatin flow all together
Copy link
Member

Choose a reason for hiding this comment

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

Yes we don't want the parallel authentication, we want to reduce the amount of duplicate code as much as possible, so I agree that the better solution is to refactor the authentication flow

Copy link
Author

Choose a reason for hiding this comment

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

We would need to have a discussion about the whole auth flow of the application


### Text

There is no support for different fontsizes in textual.
Copy link
Member

Choose a reason for hiding this comment

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

This ties into one of my other comments -- the bar at the bottom. The size itself isn't a huge problem, but we definitely need to make those buttons clearer by moving them somewhere else and also possibly changing some other layout if not hte font size

Copy link
Author

Choose a reason for hiding this comment

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

We could probably make a sidebar, but generally textualize is much more limited when it comes to customisation, compared to what we might be used with from web development. I don't think the bar itself is a problem, you get used to it quite fast, but I agree that it can be complicated when first using, or if you are not experienced with the system.

Group commands (in this case user) is availible through the footer bindings and have a layout using a sidebar corresponding to commands. The sidebar can have a title (now "DDS Sidebar") and a help button displaying a modal with markdown. This type of layput could be applied to all command groups.

![image](group_page.jpeg)
![iamge](help.jpeg)
Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand what this image shows

Copy link
Author

Choose a reason for hiding this comment

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

Which part? The help or "group page"?

Copy link
Member

Choose a reason for hiding this comment

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

The help I think
image

Copy link
Author

Choose a reason for hiding this comment

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

It shows the help pop up and an example of how markdown looks in textualize

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