-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
e53e676
to
779d16a
Compare
e7c1bd5
to
d10e74f
Compare
d10e74f
to
7185bcc
Compare
Orange/canvas/utils/overlay.py
Outdated
""" | ||
Return the currently displayed widget. | ||
# get singleton instance | ||
self = cls() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like so?
9ace1cc
to
4bfd759
Compare
4bfd759
to
af847bd
Compare
da882dd
to
c9d31a6
Compare
Codecov Report
@@ Coverage Diff @@
## master #3933 +/- ##
=======================================
Coverage 85.26% 85.26%
=======================================
Files 385 385
Lines 68762 68762
=======================================
Hits 58630 58630
Misses 10132 10132 |
c9d31a6
to
15a36de
Compare
Orange/util.py
Outdated
import warnings | ||
|
||
try: | ||
from PyQt5.QtCore import pyqtWrapperType |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this used?
There was a problem hiding this comment.
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
15a36de
to
efc38ea
Compare
Should be merged after biolab/orange-canvas-core#15.
Issue
Likely the final pull request implementing #3372.
Description of changes
Includes