-
Notifications
You must be signed in to change notification settings - Fork 19
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
Graph debugger #97
Open
pridawn
wants to merge
15
commits into
Mondego:master
Choose a base branch
from
pridawn:GraphDebugger
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Graph debugger #97
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7c001db
initial commit
d3d6177
initial commit
5b85b5e
Changed Graph Actor to a process
3952d41
webservice created
4b86341
further changes
d61cfd8
Further changes
f325cd7
creating and starting a flask server on version manager init
241feca
minor changes
b47bbe0
added flask to version graph
17870cf
added basic frontend functionality for the debugger
310e5ce
more changes to graph layout and added debug to threaded socket server
a516065
Merge branch 'master' into GraphDebugger
rohan-achar c8e42c4
Added state of other app to the graph
c9dce03
Merge branch 'GraphDebugger' of https://github.com/pridawn/spacetime …
4b9ecd1
initial code for a GOT-based logger for GOT apps
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,12 @@ | |
from uuid import uuid4 | ||
from abc import ABCMeta, abstractmethod | ||
from multiprocessing import Process, Queue | ||
from spacetime.managers.version_graph import Graph | ||
from spacetime.managers.version_graph import VersionGraphProcess,Graph | ||
import spacetime.utils.utils as utils | ||
from spacetime.utils.enums import Event, VersionBy | ||
import time | ||
from threading import Thread | ||
|
||
|
||
class VersionManagerProcess(Process): | ||
|
||
|
@@ -385,16 +387,24 @@ def dump(self, folder, graph): | |
count = len(os.listdir(folder)) | ||
open(os.path.join(folder, "heap{}.dot".format(count)), "w").write(gstr) | ||
|
||
|
||
class FullStateVersionManager(VersionManager): | ||
def __init__(self, appname, types, dump_graph, instrument_record): | ||
|
||
def __init__(self, appname, types, dump_graph, instrument_record, debug=False): | ||
|
||
self.types = types | ||
self.type_map = {tp.__r_meta__.name: tp for tp in types} | ||
self.version_graph = Graph() | ||
self.debug = debug | ||
self.state_to_app = dict() | ||
self.app_to_state = dict() | ||
self.logger = utils.get_logger("%s_FullStateVersionManager" % appname) | ||
self.dump_graphs = dump_graph | ||
self.instrument_record = instrument_record | ||
self.version_graph_head = "ROOT" | ||
if self.debug: | ||
self.version_graph = VersionGraphProcess() | ||
else: | ||
self.version_graph = Graph() | ||
|
||
def set_app_marker(self, appname, end_v): | ||
self.state_to_app.setdefault(end_v, set()).add(appname) | ||
|
@@ -404,10 +414,11 @@ def receive_data(self, appname, versions, package, from_external=True): | |
if start_v == end_v: | ||
# The versions are the same, lets ignore. | ||
return True | ||
if start_v != self.version_graph.head.current: | ||
if start_v != self.version_graph_head: | ||
self.resolve_conflict(start_v, end_v, package, from_external) | ||
else: | ||
self.version_graph.continue_chain(start_v, end_v, package) | ||
self.version_graph_head = end_v | ||
self.maintain(appname, end_v) | ||
return True | ||
|
||
|
@@ -418,22 +429,24 @@ def retrieve_data(self, appname, version): | |
|
||
def retrieve_data_nomaintain(self, version): | ||
merged = dict() | ||
if version not in self.version_graph.nodes: | ||
return merged, [version, version] | ||
|
||
for delta in self.version_graph[version:]: | ||
merged = utils.merge_state_delta(merged, delta) | ||
return merged, [version, self.version_graph.head.current] | ||
if not merged: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to make the equivalent check in Graph class in getitem to return an empty list if the start version does not exist. |
||
return merged, [version, version] | ||
return merged, [version, self.version_graph_head] | ||
|
||
def data_sent_confirmed(self, app, version): | ||
if version[0] != version[1]: | ||
self.maintain(app, version[1]) | ||
|
||
def resolve_conflict(self, start_v, end_v, package, from_external): | ||
new_v = self.version_graph.head.current | ||
new_v = self.version_graph_head | ||
change, _ = self.retrieve_data_nomaintain(start_v) | ||
t_new_merge, t_conflict_merge = self.operational_transform( | ||
start_v, change, package, from_external) | ||
merge_v = str(uuid4()) | ||
self.version_graph_head = merge_v | ||
self.version_graph.continue_chain(start_v, end_v, package) | ||
self.version_graph.continue_chain(new_v, merge_v, t_new_merge) | ||
self.version_graph.continue_chain(end_v, merge_v, t_conflict_merge) | ||
|
@@ -457,9 +470,10 @@ def maintain(self, appname, end_v): | |
super().maintain( | ||
self.state_to_app, self.app_to_state, | ||
self.version_graph, appname, end_v, utils.merge_state_delta) | ||
if self.instrument_record: | ||
self.instrument_record.put( | ||
("MEMORY", "{0}\t{1}\t{2}\n".format(time.time(), len(self.version_graph.nodes), len(self.version_graph.edges)))) | ||
#if self.instrument_record: | ||
pridawn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#self.instrument_record.put( | ||
#("MEMORY", "{0}\t{1}\t{2}\n".format(time.time(), len(self.version_graph.nodes), len(self.version_graph.edges)))) | ||
|
||
|
||
class TypeVersionManager(VersionManager): | ||
def __init__(self, appname, types, dump_graph): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One manager should work. Why so many managers?