Skip to content
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

Add PerspectiveManager remote API for Python, Tornado server example #743

Merged
merged 1 commit into from
Sep 28, 2019

Conversation

sc1f
Copy link
Contributor

@sc1f sc1f commented Sep 27, 2019

This PR adds the PerspectiveManager class, which parses JSON messages from a client perspective and allows for operations in perspective-python on a dataset in python memory, streamed through a WebSocket to a client perspective operating in the browser.

This configuration is not subject to browser memory constraints or the 2GB WebAssembly memory limit, and takes advantage of TBB for parallel processing on the server side. Configuration has been tested locally with 10 million rows, streamed with zero lag to the browser.

Additionally, this has the side benefit of allowing us to serve dataframes and Numpy array-based datasets to the client through the python API.

@codecov-io
Copy link

Codecov Report

Merging #743 into master will decrease coverage by 2.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #743      +/-   ##
==========================================
- Coverage   93.36%   91.32%   -2.05%     
==========================================
  Files          61       63       +2     
  Lines        2970     3169     +199     
==========================================
+ Hits         2773     2894     +121     
- Misses        197      275      +78
Impacted Files Coverage Δ
perspective/node/__init__.py 27.27% <0%> (-45.46%) ⬇️
perspective/table/_callback_cache.py 84.61% <0%> (-6.3%) ⬇️
perspective/tests/node/test_node.py 27.77% <0%> (-3.48%) ⬇️
perspective/table/table.py 94.94% <0%> (ø) ⬆️
perspective/table/__init__.py 100% <0%> (ø) ⬆️
perspective/tests/table/test_update.py 100% <0%> (ø) ⬆️
perspective/tests/table/test_table_pandas.py 100% <0%> (ø) ⬆️
perspective/tests/table/test_manager.py 99.14% <0%> (ø)
perspective/table/manager.py 60.56% <0%> (ø)
perspective/table/view.py 81.08% <0%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82155a7...f9ac42c. Read the comment docs.

@texodus
Copy link
Member

texodus commented Sep 28, 2019

Thanks for the PR! Looks great!

@texodus texodus merged commit a5fd196 into master Sep 28, 2019
@texodus texodus deleted the py-psp-api branch September 28, 2019 16:10
import pandas as pd
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '..'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wouldnt do this

# call the underlying method on the Table or View
getattr(table_or_view, method)(callback, *msg.get("args", []))
else:
print("callback not found for remote call {}".format(msg))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid prints, use logging if you want to print

if msg["cmd"] == "view_method":
del self._views[msg["name"]]
except Exception as error:
print(self._make_error_message(msg["id"], error))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove print

else:
print("callback not found for remote call {}".format(msg))
except Exception as error:
print(self._make_error_message(msg["id"], error))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove print

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants