-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Grace
committed
Feb 20, 2024
1 parent
c71e801
commit 7480fd6
Showing
38 changed files
with
4,169 additions
and
498 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,11 @@ | |
/dist | ||
/node_modules | ||
npm-debug.log* | ||
|
||
/es | ||
/lib | ||
|
||
/bonxai/js/node_modules | ||
/bonxai/js/dist | ||
|
||
notebooks/my_awesome_model/ |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.egg-info/ | ||
.ipynb_checkpoints/ | ||
dist/ | ||
build/ | ||
*.py[cod] | ||
node_modules/ | ||
|
||
# Compiled javascript | ||
bonxai/nbextension/ | ||
bonxai/labextension/ | ||
|
||
# OS X | ||
.DS_Store |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
graft bonxai/nbextension | ||
graft bonxai/labextension | ||
|
||
graft js | ||
graft tests | ||
prune **/node_modules | ||
|
||
include bonxai.json | ||
|
||
include LICENSE | ||
include setup.py | ||
include setup.cfg | ||
include pyproject.toml | ||
include install.json | ||
|
||
# Patterns to exclude from any directory | ||
global-exclude *~ | ||
global-exclude *.pyc | ||
global-exclude *.pyo | ||
global-exclude .git | ||
global-exclude .ipynb_checkpoints | ||
global-exclude *.map |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# bonxai | ||
|
||
A Custom Jupyter Widget Library | ||
|
||
## Installation | ||
|
||
To install use pip: | ||
|
||
$ pip install bonxai | ||
|
||
For a development installation (requires [Node.js](https://nodejs.org) and [Yarn version 1](https://classic.yarnpkg.com/)), | ||
|
||
$ git clone https://github.com//bonxai.git | ||
$ cd bonxai | ||
$ pip install -e . | ||
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix bonxai | ||
$ jupyter nbextension enable --py --sys-prefix bonxai | ||
|
||
When actively developing your extension for JupyterLab, run the command: | ||
|
||
$ jupyter labextension develop --overwrite bonxai | ||
|
||
Then you need to rebuild the JS when you make a code change: | ||
|
||
$ cd js | ||
$ yarn run build | ||
|
||
You then need to refresh the JupyterLab page when your javascript changes. |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Release | ||
|
||
Before doing a release, check to see if there are any outstanding changes or untracked files: | ||
|
||
``` | ||
git status | ||
git clean -fdxn | ||
``` | ||
|
||
Commit changes, and make sure that any untracked files can be deleted. Then clean the repository: | ||
|
||
``` | ||
git clean -fdx # actually delete untracked files | ||
``` | ||
|
||
## Javascript release | ||
|
||
To release a new version of bonxai on NPM, first register for an NPM account [here](https://www.npmjs.com/), then log in with `yarn login`. Then: | ||
|
||
1. Update `js/package.json` with the new npm package version | ||
2. Build and publish the npm package inside the `js/` directory: | ||
|
||
``` | ||
cd js/ | ||
yarn install | ||
yarn publish | ||
cd .. | ||
``` | ||
|
||
## Python release | ||
|
||
To release a new version of bonxai on PyPI, first make sure that the `build` package is installed: `pip install build`. | ||
|
||
1. Update `bonxai/_version.py`: | ||
- Update `__version__` | ||
- Update `NPM_PACKAGE_RANGE` if necessary | ||
2. Commit changes to `_version.py` and tag the release | ||
``` | ||
git add bonxai/_version.py | ||
git tag -a X.X.X -m 'comment' | ||
``` | ||
3. Generate Python packages and upload to PyPI: | ||
``` | ||
python -m build | ||
twine check dist/* | ||
twine upload dist/* | ||
``` | ||
4. Update `_version.py` (add 'dev' and increment minor) | ||
``` | ||
git commit -a -m 'Back to dev' | ||
git push | ||
git push --tags | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"load_extensions": { | ||
"bonxai/extension": true | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from ._version import __version__ | ||
|
||
from .widget import * | ||
|
||
|
||
def _jupyter_labextension_paths(): | ||
"""Called by Jupyter Lab Server to detect if it is a valid labextension and | ||
to install the widget | ||
Returns | ||
======= | ||
src: Source directory name to copy files from. Webpack outputs generated files | ||
into this directory and Jupyter Lab copies from this directory during | ||
widget installation | ||
dest: Destination directory name to install widget files to. Jupyter Lab copies | ||
from `src` directory into <jupyter path>/labextensions/<dest> directory | ||
during widget installation | ||
""" | ||
return [{ | ||
'src': 'labextension', | ||
'dest': 'bonxai', | ||
}] | ||
|
||
|
||
def _jupyter_nbextension_paths(): | ||
"""Called by Jupyter Notebook Server to detect if it is a valid nbextension and | ||
to install the widget | ||
Returns | ||
======= | ||
section: The section of the Jupyter Notebook Server to change. | ||
Must be 'notebook' for widget extensions | ||
src: Source directory name to copy files from. Webpack outputs generated files | ||
into this directory and Jupyter Notebook copies from this directory during | ||
widget installation | ||
dest: Destination directory name to install widget files to. Jupyter Notebook copies | ||
from `src` directory into <jupyter path>/nbextensions/<dest> directory | ||
during widget installation | ||
require: Path to importable AMD Javascript module inside the | ||
<jupyter path>/nbextensions/<dest> directory | ||
""" | ||
return [{ | ||
'section': 'notebook', | ||
'src': 'nbextension', | ||
'dest': 'bonxai', | ||
'require': 'bonxai/extension' | ||
}] |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Module version | ||
__version__ = '0.1.0a0' | ||
|
||
NPM_PACKAGE_RANGE='^0.1.0' |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ipywidgets as widgets | ||
from traitlets import Unicode | ||
from ._version import NPM_PACKAGE_RANGE | ||
|
||
# See js/lib/example.js for the frontend counterpart to this file. | ||
|
||
@widgets.register | ||
class HelloWorld(widgets.DOMWidget): | ||
"""An example widget.""" | ||
|
||
# Name of the widget view class in front-end | ||
_view_name = Unicode('HelloView').tag(sync=True) | ||
|
||
# Name of the widget model class in front-end | ||
_model_name = Unicode('HelloModel').tag(sync=True) | ||
|
||
# Name of the front-end module containing widget view | ||
_view_module = Unicode('bonxai').tag(sync=True) | ||
|
||
# Name of the front-end module containing widget model | ||
_model_module = Unicode('bonxai').tag(sync=True) | ||
|
||
# Version of the front-end module containing widget view | ||
_view_module_version = Unicode(NPM_PACKAGE_RANGE).tag(sync=True) | ||
# Version of the front-end module containing widget model | ||
_model_module_version = Unicode(NPM_PACKAGE_RANGE).tag(sync=True) | ||
|
||
# Widget specific property. | ||
# Widget properties are defined as traitlets. Any property tagged with `sync=True` | ||
# is automatically synced to the frontend *any* time it changes in Python. | ||
# It is synced back to Python from the frontend *any* time the model is touched. | ||
value = Unicode('Hello World!').tag(sync=True) |
Oops, something went wrong.