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

[ENH] Pull YAML feed of notifications on startup, refactor notifications #3933

Merged
merged 3 commits into from
Aug 30, 2019

Conversation

irgolic
Copy link
Member

@irgolic irgolic commented Jul 11, 2019

Should be merged after biolab/orange-canvas-core#15.

Issue

Likely the final pull request implementing #3372.

Description of changes
  • Download and parse list of notifications in YAML format.
  • Refactored notifications so as to expose a simpler interface to the programmer.
  • Fix preferences access while parsing YAML (QSettings dictionary interface)
Includes
  • Code changes
  • Tests
  • Documentation

Orange/canvas/__main__.py Outdated Show resolved Hide resolved
Orange/canvas/__main__.py Outdated Show resolved Hide resolved
Orange/canvas/__main__.py Outdated Show resolved Hide resolved
Orange/canvas/application/canvasmain.py Outdated Show resolved Hide resolved
@irgolic irgolic removed the request for review from robertcv July 17, 2019 11:00
@irgolic irgolic force-pushed the yaml-notifications branch 2 times, most recently from e7c1bd5 to d10e74f Compare July 29, 2019 12:21
"""
Return the currently displayed widget.
# get singleton instance
self = cls()
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer a

   def __init__(self):
       raise TypeError(
           "`NotificationServer` is a singleton and cannot be instantiated. "
           "`Use NotificationServer.instance()` instead"
       )

    @classmethod
    def instance(cls) -> NotificationServer:
        """
        Return the single instance of the NotificationServer class.

        Returns
        -------
        instance: NotificationServer
        """
        if cls.__instance is None:
            cls.__instance = NotificationServer.__new__(NotificationServer)
            super(NotificationServer, cls.__instance).__init__()
        return cls.__instance

and use a NotificationServer.instance() to get the instance. It's clearer and does not need a metaclass (which is too heavy handed for this).

Does the NotificationServer actually need to be a Singleton. From what I can see it is (first) created in main() and is passed to the first main window from whence it propagates further to new windows. That only leaves thepull_notifications() in __main__ which could easily take the instance created in main() as a parameter.

It is not hard to envision multiple separate queues.

Copy link
Contributor

Choose a reason for hiding this comment

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

I seem to have missed #3933 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

@ales-erjavec, I think that we could still avoid singletons. If an instance is created in main and simply attached to something (module?) that is accessible anywhere, it would still address my concern.

Copy link
Member Author

Choose a reason for hiding this comment

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

Like so?

Orange/util.py Outdated Show resolved Hide resolved
Orange/canvas/utils/overlay.py Outdated Show resolved Hide resolved
@irgolic irgolic force-pushed the yaml-notifications branch 5 times, most recently from 9ace1cc to 4bfd759 Compare August 7, 2019 10:12
@irgolic irgolic force-pushed the yaml-notifications branch 4 times, most recently from da882dd to c9d31a6 Compare August 23, 2019 08:12
@codecov
Copy link

codecov bot commented Aug 23, 2019

Codecov Report

Merging #3933 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #3933   +/-   ##
=======================================
  Coverage   85.26%   85.26%           
=======================================
  Files         385      385           
  Lines       68762    68762           
=======================================
  Hits        58630    58630           
  Misses      10132    10132

@irgolic irgolic changed the title [WIP][ENH] Pull YAML feed of notifications on startup, refactor notifications [ENH] Pull YAML feed of notifications on startup, refactor notifications Aug 23, 2019
Orange/util.py Outdated
import warnings

try:
from PyQt5.QtCore import pyqtWrapperType
Copy link
Contributor

Choose a reason for hiding this comment

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

While we (probably?) don't support PyQt4 anymore it would still be better to use AnyQt for imports...

@@ -20,3 +20,4 @@ python-louvain>=0.13
requests
openTSNE>=0.3.0
pandas
pyyaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Contributor

Choose a reason for hiding this comment

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

Found it: __main__.py L26

@lanzagar lanzagar merged commit 5435a3b into biolab:master Aug 30, 2019
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.

4 participants