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

PySide6 Compatibility #1002

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

PySide6 Compatibility #1002

wants to merge 37 commits into from

Conversation

shanto268
Copy link

@shanto268 shanto268 commented Nov 18, 2024

What are the issues this pull addresses (issue numbers / links)?

Porting Qiskit Metal from PySide2 to PySide6 so that it can work natively on M* Macs (Apple Silicon).

Issues addressed:

Did you add tests to cover your changes (yes/no)?

No. N/A

Did you update the documentation accordingly (yes/no)?

Yes

Did you read the CONTRIBUTING document (yes/no)?

Yes

Summary

Fixed changes from PR #908 to pass automated CI workflows and tests, ensuring compatibility with updated dependencies, environment configurations, and the latest (11/17/2024) main branch.

Details and comments

  1. Built on top of changes made by @obrienpja in PR #908.

  2. Changes to QWidget_PlaceholderText and QTableView_AllComponents:

    • Refactored the QWidget_PlaceholderText class to ensure proper initialization and compatibility with PySide6.
    • Resolved issues with placeholder text styling by updating palette usage to align with PySide6 standards.
    • Updated QTableView_AllComponents to correctly inherit and integrate with QWidget_PlaceholderText, ensuring both functionality and visual styling work seamlessly.
    • Fixed initialization errors and ensured that the placeholder label behaves as intended when no components are available.
  3. Requirements and environment updates:

    • Updated the environment.yml file to use stable, OS-agnostic dependencies for Python 3.10.
    • Added missing dependencies, such as pyaedt, to ensure a consistent build across different operating systems.
    • Ensured that all dependencies align with the workflows and requirements in the lab's testing environment.
  4. Testing and validation:

    • Verified that the changes integrate seamlessly with the existing workflows and CI processes used in our lab.
    • Tested the updated branch against the current main branch workflows to confirm identical behavior.
    • All CI tests now pass successfully across all supported platforms (Windows, macOS, Ubuntu) and Python versions (3.9 and 3.10).

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ obrienpja
✅ priti-ashvin-shah-ibm
❌ shanto268
You have signed the CLA already but the status is still pending? Let us recheck it.

@zlatko-minev
Copy link
Collaborator

Thank you, @shanto268! The tests are running. This is a giant PR, so it would be good to have more eyes on it than just you and me. Has anyone else from your lab tried this? I think after merging this, we could bump the Qiskit Metal version from 0.1.5 to 0.2. I just want to make sure it runs.

@shanto268
Copy link
Author

Thanks! All tests have passed now, thankfully.

I totally agree—it indeed is a big PR, so having more eyes on it is a great idea. I’ll be using this version myself and asking my lab mates to do the same over the next couple of weeks. If everything runs smoothly, I’ll report back.

I’d also like to invite the great people—@PP501 and @DavidSomm—of the SQDMetal team to see if they can help beta test this version as well.

@zlatko-minev
Copy link
Collaborator

Awesome, that would be superb! Thank you everyone. Please don't be shy to post any comments here.

@zlatko-minev
Copy link
Collaborator

Nice

@zlatko-minev
Copy link
Collaborator

Linking pip install issue #1000

@PositroniumJS
Copy link
Contributor

PositroniumJS commented Dec 27, 2024

I tried to use these changes with python 3.12 on Windows, for it to be installed, I modified the version of the packages (I give my requirements.txt file below), this is my feedback:

  1. the first time, I can open the gui without any problem, except the following error messages in the console of the gui metal: line: 0, func: None(), file: None WARNING: endResetModel called on QSortFilterProxyModel(0x1dd7a634b60) without calling beginResetModel first [_handle_qt_messages._qt_message_handler]

  2. all subsequent times that I try to run this code (even after restarting my computer), it crashes without any error message. I managed to find out that it crashes when running self.main_window.show() in main_window.py

  3. I tried to do the same in WSL, likewise the gui opened the first time with the same error messages in the console (when clicking on the arrow to close the gui, the big window closed but the small one kept reopening itself, I had to use Ctrl+C in the terminal to close it), then again, impossible to launch the gui again, but this time I get the message Segmentation fault in the terminal

Deleting and recreating the venv is not solving the issue.

I used this code to test the gui:

from qiskit_metal import designs, draw, MetalGUI, Dict, open_docs
design = designs.DesignPlanar()
gui = MetalGUI(design)

requirements.txt

addict==2.4.0
descartes==1.1.0
gdspy==1.6.13
geopandas==0.12.2
ipython==8.30.0
matplotlib==3.9.3
numpy==1.26.4
pandas==1.5.3
pint==0.20.1
pyEPR-quantum==0.9.0
pygments==2.18.0
pyside6
qdarkstyle==3.1
qutip==4.7.6
scipy==1.12.0
shapely==2.0.6
scqubits==3.1.0
gmsh==4.11.1
pyaedt==0.13.0
pyyaml==6.0.2
cython<3.0.0

I have not tried with a lower version of python.

I do not know if someone else can manage to reproduce this bug. Feel free to tell me how to provide more details if necessary, in particular how to get the error messages of Qt.

@PositroniumJS
Copy link
Contributor

I tried on Windows with Python 3.10.11, the exact requirements.txt of this branch except that I replace pyEPR-quantum by the version 0.9.0 and on a fresh kernel, on the first run I get:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], [line 1](vscode-notebook-cell:?execution_count=1&line=1)
----> [1](vscode-notebook-cell:?execution_count=1&line=1) from qiskit_metal import designs, draw, MetalGUI, Dict, open_docs
      [2](vscode-notebook-cell:?execution_count=1&line=2) design = designs.DesignPlanar()
      [3](vscode-notebook-cell:?execution_count=1&line=3) design.overwrite_enabled = True

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\qiskit_metal\__init__.py:116
    [112](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:112)         import matplotlib.pyplot as plt
    [113](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:113)         plt.ion()  # interactive
--> [116](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:116) __setup_Qt_backend()
    [117](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:117) del __setup_Qt_backend
    [119](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:119) ## Setup logging

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\qiskit_metal\__init__.py:113, in __setup_Qt_backend()
    [111](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:111) # pylint: disable=redefined-outer-name
    [112](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:112) import matplotlib.pyplot as plt
--> [113](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/qiskit_metal/__init__.py:113) plt.ion()

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\matplotlib\pyplot.py:554, in ion()
    [552](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/matplotlib/pyplot.py:552) stack.callback(ion if isinteractive() else ioff)
    [553](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/matplotlib/pyplot.py:553) matplotlib.interactive(True)
--> [554](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/matplotlib/pyplot.py:554) install_repl_displayhook()
    [555](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/matplotlib/pyplot.py:555) return stack

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\matplotlib\pyplot.py:157, in install_repl_displayhook()
    [155](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/matplotlib/pyplot.py:155) ipython_gui_name = backend2gui.get(get_backend())
    [156](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/matplotlib/pyplot.py:156) if ipython_gui_name:
--> [157](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/matplotlib/pyplot.py:157)     ip.enable_gui(ipython_gui_name)

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\ipykernel\zmqshell.py:491, in ZMQInteractiveShell.enable_gui(self, gui)
    [488](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/zmqshell.py:488) from .eventloops import enable_gui as real_enable_gui
    [490](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/zmqshell.py:490) try:
--> [491](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/zmqshell.py:491)     real_enable_gui(gui)
    [492](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/zmqshell.py:492)     self.active_eventloop = gui
    [493](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/zmqshell.py:493) except ValueError as e:

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\ipykernel\eventloops.py:597, in enable_gui(gui, kernel)
    [594](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:594) else:
    [595](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:595)     if gui.startswith("qt"):
    [596](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:596)         # Prepare the kernel here so any exceptions are displayed in the client.
--> [597](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:597)         make_qt_app_for_kernel(gui, kernel)
    [599](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:599) loop = loop_map[gui]
    [600](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:600) if (
    [601](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:601)     loop and kernel.eventloop is not None and kernel.eventloop is not loop  # type:ignore[unreachable]
    [602](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:602) ):

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\ipykernel\eventloops.py:568, in make_qt_app_for_kernel(gui, kernel)
    [565](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:565) from IPython.external.qt_for_kernel import QtCore
    [566](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:566) from IPython.lib.guisupport import get_app_qt4
--> [568](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:568) kernel.app = get_app_qt4([" "])
    [569](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/ipykernel/eventloops.py:569) kernel.app.qt_event_loop = QtCore.QEventLoop(kernel.app)

File c:\Users\account\Python_venv\qiskit-metal-10\lib\site-packages\IPython\lib\guisupport.py:115, in get_app_qt4(*args, **kwargs)
    [113](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/IPython/lib/guisupport.py:113) """Create a new qt4 app or return an existing one."""
    [114](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/IPython/lib/guisupport.py:114) from IPython.external.qt_for_kernel import QtGui
--> [115](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/IPython/lib/guisupport.py:115) app = QtGui.QApplication.instance()
    [116](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/IPython/lib/guisupport.py:116) if app is None:
    [117](file:///C:/Users/account/Python_venv/qiskit-metal-10/lib/site-packages/IPython/lib/guisupport.py:117)     if not args:

AttributeError: module 'PySide6.QtPrintSupport' has no attribute 'QApplication'

and when relaunching the code without restarting the kernel I get the usual death of the jupyter cell without any error message

@zlatko-minev
Copy link
Collaborator

zlatko-minev commented Dec 31, 2024

I have updated this branch with the latest merged PRs, resolved GUI setup issues related to resources, and corrected several text typos, thanks to @PositroniumJS. I plan to merge this in the next two weeks.

@shanto268 and @PositroniumJS, are you both comfortable with proceeding with the merge at this point?

After the merge, I will bump the major version of Qiskit Metal. Great job, everyone!

@zlatko-minev zlatko-minev self-requested a review December 31, 2024 13:25
@PositroniumJS
Copy link
Contributor

@zlatko-minev on a fresh python 3.10.11 venv I still face problems:
On the first import of qiskit-metal inside a jupyter notebook, I get an interference with matplotlib, but on the second import the error is solved:

AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 import qiskit_metal as metal
      2 from qiskit_metal import designs, draw
      3 from qiskit_metal import MetalGUI, Dict, open_docs

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\qiskit_metal\__init__.py:116
    112         import matplotlib.pyplot as plt
    113         plt.ion()  # interactive
--> 116 __setup_Qt_backend()
    117 del __setup_Qt_backend
    119 ## Setup logging

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\qiskit_metal\__init__.py:113, in __setup_Qt_backend()
    111 # pylint: disable=redefined-outer-name
    112 import matplotlib.pyplot as plt
--> 113 plt.ion()

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\matplotlib\pyplot.py:554, in ion()
    552 stack.callback(ion if isinteractive() else ioff)
    553 matplotlib.interactive(True)
--> 554 install_repl_displayhook()
    555 return stack

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\matplotlib\pyplot.py:157, in install_repl_displayhook()
    155 ipython_gui_name = backend2gui.get(get_backend())
    156 if ipython_gui_name:
--> 157     ip.enable_gui(ipython_gui_name)

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\ipykernel\zmqshell.py:491, in ZMQInteractiveShell.enable_gui(self, gui)
    488 from .eventloops import enable_gui as real_enable_gui
    490 try:
--> 491     real_enable_gui(gui)
    492     self.active_eventloop = gui
    493 except ValueError as e:

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\ipykernel\eventloops.py:597, in enable_gui(gui, kernel)
    594 else:
    595     if gui.startswith("qt"):
    596         # Prepare the kernel here so any exceptions are displayed in the client.
--> 597         make_qt_app_for_kernel(gui, kernel)
    599 loop = loop_map[gui]
    600 if (
    601     loop and kernel.eventloop is not None and kernel.eventloop is not loop  # type:ignore[unreachable]
    602 ):

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\ipykernel\eventloops.py:568, in make_qt_app_for_kernel(gui, kernel)
    565 from IPython.external.qt_for_kernel import QtCore
    566 from IPython.lib.guisupport import get_app_qt4
--> 568 kernel.app = get_app_qt4([" "])
    569 kernel.app.qt_event_loop = QtCore.QEventLoop(kernel.app)

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\IPython\lib\guisupport.py:115, in get_app_qt4(*args, **kwargs)
    113 """Create a new qt4 app or return an existing one."""
    114 from IPython.external.qt_for_kernel import QtGui
--> 115 app = QtGui.QApplication.instance()
    116 if app is None:
    117     if not args:

AttributeError: module 'PySide6.QtPrintSupport' has no attribute 'QApplication'

Then when I try to launch the GUI, in the console I get this:

03:07PM 31s CRITICAL [_qt_message_handler]: line: 0, func: None(), file: None  WARNING: endResetModel called on QSortFilterProxyModel(0x2dc08222640) without calling beginResetModel first

I have two windows that open but they are "not responding" and totally blank

@vegaonline
Copy link

@shanto268, even after installation of Pyside6, I am getting
self.logger.warning( 541 "WARNING: No capacitance bodies added to the model other " 542 "than those connected to ground. ElmerFEM cannot run a " 543 "capacitance extraction analysis without any bodies. ")
and ultimately final error points to
self.logger.warning( 541 "WARNING: No capacitance bodies added to the model other " 542 "than those connected to ground. ElmerFEM cannot run a " 543 "capacitance extraction analysis without any bodies. ").

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.

7 participants