Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico

Page created by Rose James
 
CONTINUE READING
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
Python GUI and RAD
   Ivan Sinkarenko (BE-CO-APS)
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
Agenda
• Context
• Python GUIs
• Rapid Application Development with ComRAD
• PyQt distribution
• PyQt widget library
• ComRAD in detail
• Outlook

                                              2
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
Context
 • ~500 operational applications developed
   over 18 years
   • 10% JavaFX                                           Physicists,
   • 90% Java Swing                           Software    operators,
                                             developers   hardware
                                                           experts

• In 2018, Python and PyQt were chosen as
  the first-class citizen GUI technology

                                                                        3
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
Context: Accelerator GUIs

                            4
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
Python GUIs
• Standalone PyQt development
  • Users have freedom of exploration
  • We provide tools to streamline development
• Rapid Application Development
  •   Useful for rapid prototyping, throw-away applications
  •   Applicable to regular applications
  •   Perfect for low- (or no-) code use-cases
  •   RAD framework on top of standalone PyQt development parts

                                                                  5
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
CO Multi-purpose RAD - ComRAD

                                6
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
7
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
ComRAD: Design goals
 • Make it easy for newcomers
   • Use PyQt and Qt Designer integration, allow no-code use-cases
 • Reuse proven technologies
   • PyDM, Qt Designer
 • Follow good architecture
   • Presentation & logic separation
 • Do not create lock-in
   • Let evolve the application from ComRAD-bound to pure PyQt
 • Account for expert users
   • Workflow beyond Qt Designer should be smooth (code-first approach)

                                                                          8
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
Python GUI stack
                                                              ComRAD
            Tooling:
    IDE, acc-py, pip, pylint,                     Fabian
                                                      Custom widgets        IvanPyDM
           pytest, …
                                     Control libraries:
                                                                       PyQt (5.12)
                                     pyjapc, pyccda, …
                                 Phil
                                Python (acc-py)                             Qt (5.12)

                                    OS (CentOS 7), System libraries

                                                                                        9
Python GUI and RAD Ivan Sinkarenko (BE-CO-APS) - CERN Indico
PyQt distribution

                    10
PyQt distribution
• Prebuilt PyQt-Qt-SIP-Qscintilla bundle accessible on NFS
• Built for acc-py Python

• After activation you get all Qt, PyQt and acc-py executables
   • qmake, uic, pyuic5, designer, python, acc-py, …
• Integrates Qt Designer plugins

                                                                 11
PyQt distribution
• Tailors Qt Designer for integration with ComRAD

                                              Only visible from ComRAD Designer

                                                                              12
PyQt widgets

               13
Widgets

          14
Widget library
• One project for custom accelerator widgets
   • Codebase, documentation, examples & tests are separated into subdirectories
   • Contributions are welcome!
   • https://wikis.cern.ch/display/ACCPY/Widgets
• Library is built with ComRAD in mind
   • To efficiently evolve ComRAD application into a standalone PyQt application,
     we have the same widget in both places
   • In fact, ComRAD widgets are wrappers around this library widgets
• Pushed forward by Fabian
• First tenant - derivative PyQtGraph widget (Graph)
                                                                                15
Graph: inspired by JDataViewer
                                                 Multiple Y axis

   New Data representations for Fixed displays

Improved Live data handling
                                                                   16
17
Use-case: Linac 4 Source Autopilot
                                     18
ComRAD

         19
ComRAD: Facts
• Handles things for you:
   •   Connecting widgets to the control system
   •   Custom widgets common in accelerator applications
   •   Main window to render your dashboards
   •   Tailored integration with Qt Designer => ComRAD Designer
• All of it is discoverable via single “comrad” command
   • comrad run, comrad designer, comrad examples, …
• Bundles interactive examples
• https://wikis.cern.ch/display/ACCPY/Rapid+Application+Development

                                                                  20
21
ComRAD: In the field
• Earlier this year, ComRAD has run for few months in Mini CC to test
  the stability
• People start showing interest to ComRAD in the labs
• We’re working to bring ComRAD into the control room of ABT in the
  near future

                                                                        22
23
Outlook

          24
Outlook: PyQt distribution
• PyQt training in the end of Jan 2020
• PyQt distribution is ready now
• We’ll look for alternative to NFS

                                         25
Outlook: PyQt widgets
• PyQt widget library to be released in December
   • With Graph widget only
• We’ll be integrating more widgets in 2020
• Further work on the Graph

                                                   26
Outlook: ComRAD
• ComRAD beta in Jan 2020
  • Support for ComRAD Designer, PyJAPC, RBAC, standard PyQt widgets +
    custom Graph, examples browser
• New widgets in parallel with Widget library
• Other features: value-based colors, logging
• ComRAD Designer improvements and migration assistance is the
  longer-term goal

                                                                         27
Thank you!

             28
ComRAD: Design goals (Part 2)
• Make it attractive for existing RAD users
   • Ensure smooth transition to the new RAD solution for existing project

                                                                             29
PyQt distribution
• https://wikis.cern.ch/display/ACCPY/PyQt+distribution
• Current prerequisites
   • CC7
   • Access to NFS
   • PyQt5 Python namespace is reserved for us

• Side-project: Docker
   • Docker images with PyQt, built against system Python
   • For use in CI, machines without NFS, or different OS (e.g. Ubuntu)

                                                                          30
Graph
• Improvements to standard PyQtGraph
   • Fixing bugs / quirks in behavior
   • Improving the API and documentation
• Bundles Qt Designer plugin
• Is integrated with ComRAD

                                           31
ComRAD: Interactive
examples

                      32
ComRAD: Workflow
• Develop your dashboards
  • Visual development with “comrad designer”
  • Can mix with Python code
  • Or do everything completely in code…

• Launch your dashboards
  • “comrad run”
  • No need to instantiate QApplication manually, like in other PyQt apps

• Hot reload during development

                                                                            33
ComRAD: Visual customization
• Leverages Qt’s QSS engine

                               34
ComRAD: Assisted migration (Future)
• Scripts can assist in converting file formats where direct translation of
  features is possible
• In most cases will still require human intervention
• Use-cases:
   • Migrate from Inspector to ComRAD
   • Migrate from ComRAD to PyQt

                                                                         35
ComRAD
• Connecting widgets to the control system

                                             36
ComRAD
• Custom widgets common in accelerator applications

                           Standard Qt Widgets

                                ComRAD “C-” widgets

                                                      37
ComRAD
• Main window to render your dashboards

                                          38
ComRAD
• Tailored integration with Qt Designer => ComRAD Designer

                                                             39
40
PyQt distribution
• Integrates Qt Designer plugins (PyQt, Qscintilla)
   • Something that is not achievable with pip

                                                      41
You can also read