Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from ranking-agent/pip
Browse files Browse the repository at this point in the history
Making gamma_viewer a pip package
  • Loading branch information
maximusunc authored May 21, 2020
2 parents 721f1d3 + d8075e2 commit 7ce6f58
Show file tree
Hide file tree
Showing 17 changed files with 287 additions and 122 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.DS_Store
node_modules
.vscode
GammaViewer/static
gamma_viewer/static
*.egg-info
__pycache__
__pycache__
release
*.ipynb
.ipynb_checkpoints
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2020 CoVar Applied Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include gamma_viewer/static *.*
include gamma_viewer.json
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,33 @@

Upload a Translator standard message into a jupyter notebook and view it in a useful analytic user interface.

## JS Setup
```
cd js
npm install
npm run build
cd ..
## Installation
```bash
pip install gamma-viewer
```

*You need to setup the JS before the Python because it needs the bundled JS.*
## Python Setup
```
python setup.py develop
```
_You might need to also manually `pip install notebook`_
## Local Setup
Activate your python environment of choice.
This package also requires you have nodejs and npm installed.
```bash
git clone git@github.com:ranking-agent/gamma-viewer.git
cd gamma-viewer
pip install -e .
jupyter nbextension install --py --symlink --sys-prefix gamma_viewer
jupyter nbextension enable --py --sys-prefix gamma_viewer

## Usage
```
jupyter notebook
```
- Open example.ipynb
- Run code block

## Usage
```python
from gamma_viewer import GammaViewer
from IPython.display import display
import json

with open('translator_standard_message.json', 'r') as f:
res = json.load(f)

view = GammaViewer(props={"data":res})
display(view)
```
28 changes: 28 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How To Make A Release

```bash
mkdir release
cd release
rm -rf gamma-viewer

git clone git@github.com:ranking-agent/gamma-viewer.git
cd gamma-viewer
```

You may also want to consider making a fresh environment.
```bash
python -m venv ~/.venv/gamma_viewer
source ~/.venv/gamma_viewer/bin/activate
pip install -e .
```

You need to have setuptools, wheel, and twine installed via pip.

## Release on PyPi
Make sure you bump the version number in setup.py
```bash
git clean -dfx
python setup.py sdist bdist_wheel
twine upload dist/*
```
Then make a pull request with the bumped version as well as make a release tag
57 changes: 0 additions & 57 deletions example.ipynb

This file was deleted.

5 changes: 5 additions & 0 deletions gamma_viewer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"load_extensions": {
"gamma_viewer/extension": true
}
}
6 changes: 3 additions & 3 deletions GammaViewer/__init__.py → gamma_viewer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Initialize jupyter nb extension path."""
from .gamma_viewer import GammaViewer
from .gamma_viewer import *


def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
'src': 'static',
'dest': 'GammaViewer',
'require': 'GammaViewer/bundle'
'dest': 'gamma_viewer',
'require': 'gamma_viewer/extension'
}]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GammaViewer(Component):
def __init__(self, **kwargs):
"""Initialize python wrapper and forward messages from notebook."""
# This needs to match the name in the entry js file
target_name = 'react.example'
target_name = 'react.gamma_viewer'
super(GammaViewer, self).__init__(target_name=target_name, **kwargs)
self.on_msg(self._handle_msg)

Expand Down
2 changes: 1 addition & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function load_ipython_extension () {
'base/js/namespace',
'base/js/events',
], (Jupyter, events) => {
JupyterReact.init(Jupyter, events, 'react.example', { components: App });
JupyterReact.init(Jupyter, events, 'react.gamma_viewer', { components: App });
});
}

Expand Down
2 changes: 1 addition & 1 deletion js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "react-jupyter-widget-template",
"version": "0.0.1",
"name": "gamma_viewer",
"version": "0.1.0",
"description": "React extension inside Jupyter notebooks",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/ranking-agent/gamma-viewer.git"
},
"author": "Max Wang",
"license": "ISC",
"license": "MIT",
"homepage": "https://github.com/ranking-agent/gamma-viewer.git#readme",
"bugs": {
"url": "https://github.com/ranking-agent/gamma-viewer.git/issues"
Expand Down
6 changes: 3 additions & 3 deletions js/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const config = {
],
},
output: {
path: path.resolve(__dirname, '../GammaViewer', 'static'),
publicPath: '../GammaViewer/static',
filename: 'bundle.js',
path: path.resolve(__dirname, '../gamma_viewer', 'static'),
publicPath: '../gamma_viewer/static',
filename: 'extension.js',
libraryTarget: 'umd',
},
resolve: {
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setuptools~=41.2.0
twine~=3.1.1
wheel~=0.34.2
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jupyter~=1.0.0
jupyter-react~=0.1.3
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[bdist_wheel]
universal=1

[metadata]
license_file = LICENSE
Loading

0 comments on commit 7ce6f58

Please sign in to comment.