Skip to content

Commit

Permalink
More improvements to deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Shawver committed Oct 5, 2014
1 parent 249d25a commit a062304
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 456 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.md
include LICENSE

recursive-include qgrid/assets *.*
recursive-include qgridjs *.*
27 changes: 19 additions & 8 deletions qgrid/qgrid.py → qgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from textwrap import dedent
import uuid
import json
import pkgutil
import IPython.html.nbextensions as nb_ext

from IPython.display import display_html, display_javascript

Expand Down Expand Up @@ -77,10 +79,10 @@
"""
)

class QuantopianGrid(object):
def __init__(self, data_frame, remote):
class qgrid(object):
remote_mode = True
def __init__(self, data_frame):
self.data_frame = data_frame
self.remote = remote
self.div_id = str(uuid.uuid4())

self.df_copy = data_frame.copy()
Expand Down Expand Up @@ -113,10 +115,10 @@ def _ipython_display_(self):
column_types_json = json.dumps(self.column_types)
data_frame_json = self.df_copy.to_json(orient='records', date_format='iso', double_precision=self.precision)

if self.remote:
cdn_base_url = "https://rawgit.com/quantopian/SlickDataFrame/master/nbextensions"
if qgrid.remote_mode:
cdn_base_url = "https://rawgit.com/quantopian/qgrid/master/nbextensions/qgridjs"
else:
cdn_base_url = "/nbextensions"
cdn_base_url = "/nbextensions/qgridjs"

raw_html = SLICK_GRID_CSS.format(div_id=self.div_id, cdn_base_url=cdn_base_url)
raw_js = SLICK_GRID_JS.format(cdn_base_url=cdn_base_url,
Expand All @@ -129,14 +131,23 @@ def _ipython_display_(self):
except Exception, err:
display_html('ERROR: {}'.format(str(err)), raw=True)

def qgrid(dataframe, remote=True):
return QuantopianGrid(dataframe, remote)
def set_remote_mode(remote_mode=True):
qgrid.remote_mode = remote_mode

def load_ipython_extension(ipython):
"""
Entrypoint for ipython. Add objects to the user's namespace by adding them
to the dictionary passed to ipython.push.
"""

js_pkg = pkgutil.get_loader("qgridjs")
if js_pkg != None:
qgridjs_path = js_pkg.filename
nb_ext.install_nbextension(qgridjs_path, overwrite=True, symlink=False, verbose=0)
set_remote_mode(False)
else:
set_remote_mode(True)

ipython.push(
{
'qgrid': qgrid
Expand Down
472 changes: 26 additions & 446 deletions qgrid_demo.ipynb

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
description='An extension for viewing pandas DataFrames in IPython notebook.',
author='Quantopian Inc.',
author_email='[email protected]',
packages=find_packages(),
packages=['qgridjs'],
py_modules = ['qgrid'],
license='Apache 2.0',
include_package_data=True,
zip_safe=False,
Expand Down

0 comments on commit a062304

Please sign in to comment.