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

feat: use embedded qt browser for jdaviz standalone #3188

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

Conversation

maartenbreddels
Copy link
Collaborator

Description

This allows running jdaviz in its own browser (using qt) for the command line and the standalone version

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@maartenbreddels maartenbreddels changed the title Feat solara standalone feat: use embedded qt browser for jdaviz standalone Sep 10, 2024
@kecnry kecnry added this to the 4.0 milestone Sep 10, 2024
@kecnry kecnry added UI/UX😍 Build standalone Additional pylons labels Sep 10, 2024
@pllim
Copy link
Contributor

pllim commented Sep 10, 2024

Nope... Error: Error: Timed out waiting for: tcp:8765 for Ubuntu

@pllim pllim added the no-changelog-entry-needed changelog bot directive label Sep 10, 2024
jdaviz/cli.py Show resolved Hide resolved
@kecnry kecnry removed the Build standalone Additional pylons label Sep 10, 2024
@camipacifici
Copy link
Contributor

Starting server on http://localhost:60717
INFO: Started server process [19275]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://localhost:60717 (Press CTRL+C to quit)
Traceback (most recent call last):
File "/Users/cpacifici/opt/miniconda3/envs/pr3188/bin/jdaviz", line 8, in
sys.exit(_main())
^^^^^^^
File "/Users/cpacifici/opt/miniconda3/envs/pr3188/lib/python3.11/site-packages/jdaviz/cli.py", line 149, in _main
main(filepaths=args.filepaths, layout=layout, instrument=args.instrument, browser=args.browser,
File "/Users/cpacifici/opt/miniconda3/envs/pr3188/lib/python3.11/site-packages/jdaviz/cli.py", line 78, in main
run_solara(host=host, port=port, theme=theme, browser=browser)
File "/Users/cpacifici/opt/miniconda3/envs/pr3188/lib/python3.11/site-packages/jdaviz/cli.py", line 93, in run_solara
from qtpy.QtWidgets import QApplication
File "/Users/cpacifici/opt/miniconda3/envs/pr3188/lib/python3.11/site-packages/qtpy/init.py", line 287, in
raise QtBindingsNotFoundError from None
qtpy.QtBindingsNotFoundError: No Qt bindings could be found

:(

jdaviz/cli.py Outdated

app = QApplication([""])
web = QWebEngineView()
web.resize(1000, 1000)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what we should do here.

@kecnry kecnry added the Build standalone Additional pylons label Sep 10, 2024
@maartenbreddels
Copy link
Collaborator Author

maartenbreddels commented Sep 10, 2024

I included optional dependencies now @camipacifici , so running

$ pip install -e ".[qt]"

Should get you the correct dependencies.

jdaviz/cli.py Outdated Show resolved Hide resolved
@camipacifici
Copy link
Contributor

camipacifici commented Sep 10, 2024

Thank you! I had to install also PyQtWebEngine. After that, it launched!

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 1.13636% with 87 lines in your changes missing coverage. Please review.

Project coverage is 87.75%. Comparing base (24c4440) to head (4c5a7b9).

Files with missing lines Patch % Lines
jdaviz/qt.py 0.00% 69 Missing ⚠️
jdaviz/cli.py 5.26% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3188      +/-   ##
==========================================
- Coverage   88.12%   87.75%   -0.37%     
==========================================
  Files         127      128       +1     
  Lines       19574    19656      +82     
==========================================
  Hits        17249    17249              
- Misses       2325     2407      +82     

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

@maartenbreddels
Copy link
Collaborator Author

ValueError: Key backend: 'module://matplotlib_inline.backend_inline' is not a valid value for backend; supported values are ['gtk3agg', 'gtk3cairo', 'gtk4agg', 'gtk4cairo', 'macosx', 'nbagg', 'notebook', 'qtagg', 'qtcairo', 'qt5agg', 'qt5cairo', 'tkagg', 'tkcairo', 'webagg', 'wx', 'wxagg', 'wxcairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']
[PYI-12940:ERROR] Failed to execute script 'jdaviz-cli-entrypoint' due to unhandled exception!

Strange to see this error come back from #2944

@maartenbreddels maartenbreddels force-pushed the feat_solara_standalone branch 2 times, most recently from 9bf74d6 to 901b68c Compare September 12, 2024 13:33
jdaviz/cli.py Outdated Show resolved Hide resolved
@maartenbreddels maartenbreddels force-pushed the feat_solara_standalone branch 2 times, most recently from ee19839 to 7e48dfe Compare September 12, 2024 13:54
Comment on lines +26 to +28
if "--browser" not in args:
args.append("--browser")
args.append("qt")
Copy link
Member

Choose a reason for hiding this comment

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

since qt is an optional dependency (and we want to keep it that way), can this default to qt only if it is installed and otherwise use the system browser?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is only for the standalone, which is built in CI with qt installed. Or do you mean if people build in locally?

Copy link
Member

Choose a reason for hiding this comment

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

if anyone installs jdaviz (from pip for example) but not using the standalone installer, they still have access to the CLI, but may not have the qt optional dependencies.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But they would not use this file right, maybe you are confusing it with cli.py?

jdaviz/cli.py Outdated
Comment on lines 89 to 91
from qtpy.QtWidgets import QApplication
from qtpy.QtWebEngineWidgets import QWebEngineView
from qtpy import QtCore
Copy link
Member

Choose a reason for hiding this comment

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

if these fail to import, should we throw an error with instructions to install the optional dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, good idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've put this in qt.py

@kecnry
Copy link
Member

kecnry commented Dec 6, 2024

what do we need to do to get the tests passing, do we just make sure CI is installing qt or will it still fail on headless setups? It doesn't look like there are conflicts, but also might be worth rebasing since this sat for a while (sorry about that!)

@rosteen rosteen modified the milestones: 4.1, 4.2 Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build standalone Additional pylons no-changelog-entry-needed changelog bot directive UI/UX😍
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants