-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactor signals during evaluation #97
Comments
First off, as a disclaimer, I have never ever worked with signals before and am just now stumbling upon the subject. Therefore, please bear with me if this is obvious, but could the python core library module Ref: |
@neuneck IMHO: although Unix signals, which Python's As to the signal declaration issue, maybe we can use metaclasses to dynamically create class INode(metaclass=SignalMeta):
signals = ['evaluation-omitted', 'evaluation-started', 'evaluation-finished'] |
Thanks for the comments guys. I agree, the name should be changed to "event" that makes more sense and does not confuse it with the system "signals" as mentioned. I'm not quite sure about the proposed metaclass solution could work but I'll take a closer look at it next week (I'm not in the office this week). Another solution would be not to specify the arguments for an event at all. It might actually be ok to just state this information in the docstring. |
I agree on this. Currently the flowpipe logger cannot be integrated into other modules, like my own, because it uses it's own logger dependency. I think we should handle the logger part and the signal part apart from each other. |
@PaulSchweizer in your initial post you wrote about |
@TheElderMindseeker , currently the statistics only contain the evaluation time and a timestamp of the start time. n = MyNode().evaluate()
print n.stats
{
"eval_time": 0.123
} What do you think, would something like that suffice? Also, if there are any other stats you think we should gather, pease let me know. |
I'll submit a PR for this tomorrow |
The PR is submitted: #100 |
Changing stats reporter and log observer to event system
Signals
Signals are meant for external processes that want to observe the graph evaluation, mainly GUI applications or other visualizations and update their state according to the signals they receive.
Currently we have two different types of signals being emitted during
graph.evaluate
.Both of these were put in because I needed something quick. I don't like this and want to refactor this into a more generic Signal/Slot system while still keeping it very simple.
This is how it could be implemented:
flowpipe/signal.py:
flowpipe/node.py:
The client code would then do something like this:
Let me know what you think and what changes you'd suggest. Also, what other signals might be helpful.
LogObserver
We should remove the logger in the
flowpipe.__init__.py
and replace it with this in each module (if needed) and then just use that log directly:Users can create their own logs or messages from the signals, there is no need to wrap the logging the way we are wrapping it right now.
log_observer.py
should therefore be removed.StatsReporter
The original idea was to calculate statistics and report them to a db. These statistics could then be used to predict evaluation times and required resources for future evaluations of the same/similar graphs.
It never want past the idea stage though and besides that, flowpipe should not contain any such code anyways. If one would want to do something like this, the signals are the perfect solution to hook into the system and extract this information.
We should therefore remove the
stats_reporter.py
from the repo. This idea could instead be added to an example file for inspiration.The text was updated successfully, but these errors were encountered: