-
Notifications
You must be signed in to change notification settings - Fork 1.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
[feat] refactor data storage to allow saving on a per-window basis #862
base: master
Are you sure you want to change the base?
Changes from all commits
6b46661
860a426
edc4fd2
1c556b7
daacf25
a22c842
ea846c7
9b0f589
ff05aa7
efc049e
cb5cb9f
7cbb7c4
c478290
f1d9638
4649983
e248459
665259f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
clean: | ||
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. I'm somewhat against adding yet another scripting flow to the visdom codebase. This should either be part of the |
||
rm -rf ./test_data/* | ||
|
||
serve_test: | ||
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5 | ||
|
||
serve_test_jpwa: | ||
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5 -cache_type JPWA | ||
|
||
serve_test_jpe: | ||
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5 -cache_type JPE | ||
|
||
serve_test_jpw: | ||
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5 -cache_type JPW | ||
|
||
|
||
test_save.py: | ||
python3 test_save.py | ||
test_cache.py: | ||
python3 test_cache.py | ||
.PHONY: test_cache.py test_save.py |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# | ||
# This source code is licensed under the license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
# __version__ = 'test' | ||
|
||
import os.path | ||
import requests | ||
|
@@ -405,7 +406,7 @@ def __init__( | |
'base_url should not end with / as it is appended automatically' | ||
|
||
self.ipv6 = ipv6 | ||
self.env = env | ||
self.env = env | ||
self.env_list={f'{env}'} # default env | ||
self.send = send | ||
self.event_handlers = {} # Haven't registered any events | ||
|
@@ -576,12 +577,12 @@ def on_message(ws, message): | |
try: | ||
handler(message) | ||
except Exception as e: | ||
import traceback | ||
tbmsg = traceback.format_exc() | ||
logger.warn( | ||
'Visdom failed to handle a handler for {}: {}' | ||
''.format(message, e) | ||
'Visdom failed to handle a handler for {}: {}.' | ||
'\n traceback:{}'.format(message, e, tbmsg) | ||
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. This is a nice-to-have addition |
||
) | ||
import traceback | ||
traceback.print_exc() | ||
|
||
def on_error(ws, error): | ||
if hasattr(error, "errno") and error.errno == errno.ECONNREFUSED: | ||
|
@@ -665,6 +666,17 @@ def _send(self, msg, endpoint='events', quiet=False, from_log=False, create=True | |
created with a random name. If `create=False`, `win=None` indicates the | ||
operation should be applied to all windows. | ||
""" | ||
# if endpoint == 'window': | ||
# print(f'[endpoint]{endpoint}') | ||
# import inspect,traceback | ||
# traceback.print_stack() | ||
# from pprint import pprint | ||
# # pprint(msg) | ||
# print(msg.get('layout').__repr__()[:10]) | ||
# print(msg.get('height')) | ||
# print(msg.get('width')) | ||
# traceback.print_tb(inspect.currentframe()) | ||
# import pdb;pdb.set_trace() | ||
if msg.get('eid', None) is None: | ||
msg['eid'] = self.env | ||
self.env_list.add(self.env) | ||
|
@@ -801,7 +813,7 @@ def get_env_list(self): | |
This function returns a list of all of the env names that are currently | ||
in the server. | ||
""" | ||
if self.offline: | ||
if self.offline: | ||
return list(self.env_list) | ||
else: | ||
return json.loads(self._send({}, endpoint='env_state', quiet=True)) | ||
|
@@ -889,7 +901,7 @@ def replay_log(self, log_filename): | |
|
||
# Content | ||
|
||
def text(self, text, win=None, env=None, opts=None, append=False): | ||
def text(self, text, win=None, env=None, opts=None, append=False,extra={}): | ||
""" | ||
This function prints text in a box. It takes as input an `text` string. | ||
No specific `opts` are currently supported. | ||
|
@@ -1694,7 +1706,7 @@ def line(self, Y, X=None, win=None, env=None, opts=None, update=None, | |
assert X.ndim == 1 or X.ndim == 2, 'X should have 1 or 2 dim' | ||
else: | ||
X = np.linspace(0, 1, Y.shape[0]) | ||
|
||
if Y.ndim == 2 and X.ndim == 1: | ||
X = np.tile(X, (Y.shape[1], 1)).transpose() | ||
|
||
|
@@ -2180,7 +2192,7 @@ def sunburst(self, labels, parents, values=None, win=None, env=None, opts=None): | |
line_width=opts.get("marker_width") | ||
|
||
assert len(parents.tolist())==len(labels.tolist()), "length of parents and labels should be equal" | ||
|
||
data_dict=[{ | ||
'labels': labels.tolist(), | ||
"parents":parents.tolist(), | ||
|
@@ -2196,7 +2208,7 @@ def sunburst(self, labels, parents, values=None, win=None, env=None, opts=None): | |
|
||
data_dict[0]['values']=values.tolist() | ||
|
||
data=data_dict | ||
data=data_dict | ||
return self._send({ | ||
'data': data, | ||
'win': win, | ||
|
@@ -2397,7 +2409,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No | |
""" | ||
This function draws interactive network graphs. It takes list of edges as one of the arguments. | ||
The user can also provide custom edge Labels and node Labels in edgeLabels and nodeLabels respectively. | ||
Along with that we have different parameters in opts for making it more user friendly. | ||
Along with that we have different parameters in opts for making it more user friendly. | ||
|
||
Args: | ||
edges : list, required | ||
|
@@ -2419,7 +2431,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No | |
except: | ||
raise RuntimeError( | ||
"networkx must be installed to plot Graph figures") | ||
|
||
G = nx.Graph() | ||
G.add_edges_from(edges) | ||
node_data = list(G.nodes()) | ||
|
@@ -2434,7 +2446,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No | |
if nodeLabels is not None: | ||
assert len(nodeLabels) == len(node_data),\ | ||
"length of nodeLabels does not match with the length of nodes {len1} != {len2}".format(len1 = len(nodeLabels), len2 = len(node_data)) | ||
|
||
for i in range(len(node_data)): | ||
if i != node_data[i]: | ||
raise RuntimeError("The nodes should be numbered from 0 to n-1 for n nodes! {} node is missing!".format(i)) | ||
|
@@ -2455,15 +2467,15 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No | |
edge["target"] = int(link_data[i][1]) | ||
edge["label"] = str(edgeLabels[i]) if edgeLabels is not None else str(link_data[i][0])+"-"+str(link_data[i][1]) | ||
edges.append(edge) | ||
|
||
for i in range(len(node_data)): | ||
node = {} | ||
node["name"] = int(node_data[i]) | ||
node["label"] = str(nodeLabels[i]) if nodeLabels is not None else str(node_data[i]) | ||
if opts['scheme'] == 'different': | ||
node["club"] = int(i) | ||
nodes.append(node) | ||
|
||
|
||
data = [{ | ||
'content': {"nodes": nodes, "edges": edges}, | ||
|
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.
IIRC this was trying to prevent text panes from submitting on enter. Plus, the goal is to send keypress events to the backend, not necessarily to have them render up-front here.
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.
Ah I see. I was putting forms into visdom window, and .preventDefault would make the form inputting fairly laggy, hence commented out.
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.
Perhaps there's value in a new
FormPane
component, likely a parent class for thePropertiesPane
. This would then be able to accomplish what you're attempting in #868, but in a cleaner way