-
Notifications
You must be signed in to change notification settings - Fork 44
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
Chore/plot tool cleanup #79
Conversation
simulations/simulation_runner.py
Outdated
@@ -76,10 +75,14 @@ def plot(self): | |||
for chains in vals_chain: | |||
edgelist.append(utils.edge(chains, 2, 'blue', 'solid')) | |||
|
|||
message_lables = {} |
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.
spelling --> "labels"
Looks like some sanity added! :) What arguments are you trying to add?
If you use 'store_true' it'll be False unless the flag is used. I imagine this might be what you were wondering |
@djrtwo Added a class This moves us closer to being able to easily add binary, as we just have to implement a In any case, this moves simulation runner a lot closer to being totally data-structure-agnostic. The last remaining function that isn't data structure is One possible way of doing so it making it so we don't call I don't love this solution, as it will either b) have a different validator for each data structure (though we can make ) a) require us to implement something like the Also, gif creation now works by default if you add a |
Not sure if it needs to inherit from PlotTool at all. Might be totally unnecessary. |
Inheritance on this depends on how much code is generic to plotting in general. Haven't taken a deep look to assess... As for ^^ just read your next paragraph and saw you proposed this. Can we pass the work onto the view rather tahn the validator? Validator consults its View to update it's safety stuff Not sure if that's clear. we can discuss more later |
Let me know if/when you want me to review the codez |
Holy shit, i just looked at |
casper/network.py
Outdated
|
||
|
||
class Network: | ||
"""Simulates a network that allows for message passing between validators.""" | ||
def __init__(self, validator_set): | ||
def __init__(self, validator_set, display=True, save=False): |
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.
Looks like network isn't using these two new params
@djrtwo a review now would be awesome. Looking forward to hearing what ya think about the inheritance stuff vs. just importing and using the plot_tool stuff. Also, the GIF stuff probably can be dramatically cleaned up (but it works, and maybe that's enough for now!). Thanks! |
Also, having That being said, I'm hopping on a flight in 15 minutes. If we agree on this - I'll start implementing! Let me know @djrtwo |
GO FOR IT!
…On Fri, Oct 27, 2017 at 2:38 PM, Nate Rush ***@***.***> wrote:
Also, having Validator.update_estimate_safety() seems good. I'm not sure
if checking safety (simple binary vs iterative blockchain) belongs in the
validator or the view. It seems like both make sense to some degree.
That being said, view is going to have to be implemented for both data
structures. If we push the work to view, we can keep the validators
totally agnostic to data structure, which would be nice :)
I'm hopping on a flight in 15 minutes. If we agree on this - I'll start
implementing! Let me know @djrtwo <https://github.com/djrtwo>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#79 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABXf-6LBRPs42HGpHFn3y3QgEQFli8Qlks5swjFHgaJpZM4QG7bH>
.
|
Did I make it in time? message said 14 minutes ago...
…On Fri, Oct 27, 2017 at 2:53 PM, danny ryan ***@***.***> wrote:
GO FOR IT!
On Fri, Oct 27, 2017 at 2:38 PM, Nate Rush ***@***.***>
wrote:
> Also, having Validator.update_estimate_safety() seems good. I'm not sure
> if checking safety (simple binary vs iterative blockchain) belongs in the
> validator or the view. It seems like both make sense to some degree.
>
> That being said, view is going to have to be implemented for both data
> structures. If we push the work to view, we can keep the validators
> totally agnostic to data structure, which would be nice :)
>
> I'm hopping on a flight in 15 minutes. If we agree on this - I'll start
> implementing! Let me know @djrtwo <https://github.com/djrtwo>
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#79 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABXf-6LBRPs42HGpHFn3y3QgEQFli8Qlks5swjFHgaJpZM4QG7bH>
> .
>
|
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.
- a handful of comments
- I see what you mean in that PlotTool could be some functions you import... I think it's fine as is, and it is responsible for knowing about save_paths and report_number and stuff. It rides the line as to overdoing the OO thing.
- Lint! It's much better than some past PRs but there are some low hanging fruit like unnecessary new lines and stuff.
casper/plot_tool.py
Outdated
iterator += 1 | ||
if iterator == frame_count_limit: | ||
break | ||
def make_gif(self, frame_count_limit=IMAGE_LIMIT, gif_name="mygif.gif", frame_duration=0.2): |
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.
default fame_duration seems a bit too quick. I would use 0.4 or 0.5.
@@ -44,18 +44,26 @@ def main(): | |||
'--report-interval', type=int, default=config.getint("ReportInterval"), | |||
help='specifies the interval in rounds at which to plot results' | |||
) | |||
parser.add_argument( |
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.
The combo of these two params makes it so vlad doesn't have to click anything for the simulations to move forward :)
Just hide-display and open up the saved gif
self.message_labels = {} | ||
|
||
|
||
def update(self, message_paths=None, sent_messages=None, new_messages=None): |
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 like this method a lot.
casper/network.py
Outdated
@@ -1,6 +1,6 @@ | |||
"""The network module .... """ | |||
from casper.view import View | |||
import casper.plot_tool as plot_tool | |||
from casper.plot_tool import PlotTool |
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.
imported but not used
casper/plot_tool.py
Outdated
|
||
graph = nx.Graph() | ||
if save: | ||
graph_path = os.path.dirname(os.path.abspath(__file__)) + '/../graphs/' |
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.
Move logic to _setup_graph_paths
or something. I like to keep __init__
looking clean. It's the method you should be able to look at to get a quick high level view of the object.
casper/plot_tool.py
Outdated
graph.add_edges_from([(bets, bets)]) | ||
self.report_number = 0 | ||
|
||
# if there isn't a graph folder, make one! |
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.
Remove notes
casper/plot_tool.py
Outdated
for message in nodes: | ||
if message not in message_colors: | ||
node_color_map[message] = 'white' | ||
else: |
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.
use elif
here instead of else
and then a deeper indent
color_mag=self.color_mag, | ||
edges=edgelist | ||
message_labels = {} | ||
for block in self.network.global_view.messages: |
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.
We're doing a lot of the same work in BlockchainPlotTool.plot
as we are doing in this report
method. Can/should the test_lang offload the gathering of stuff to the plot_tool?
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.
Good call, probably most of it can be refactored into . I'll rework this in a new PR after we get this + the other PR merged.
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.
Cool, open up an issue so it doesn't get overlooked
@@ -112,7 +112,4 @@ def check_estimate_safety(self): | |||
|
|||
# Return the number of faults we can tolerate, which is one less |
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.
move comments over to the left
# Return the number of faults we can tolerate, which is one less | ||
# than the number that need to equivocate. | ||
# Return the number of faults we can tolerate, which is one less | ||
# than the number that need to equivocate. |
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.
here
Cleans up the plot tool just a bit. Moves the language from bets -> messages. Also, b/c we now pass in the messages labels, this should be general enough for binary as well w/out any change to the plot tool.
We can now use this
display
option instead of thereport
option in a couple places (in both the simulation runner and the testing language). I'm not totally sure how to make the migration over, though - I tried to add arguments to the parser, but was thrashing (new fav word :) ) around for a while. Something about parsing boolean command line args. Would love to get your thoughts @djrtwoAlso, the
make_gif
function is probably broken as of now -- but it probably can be refactored an simplified in any case.