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

Fix undefined ModelAladin issue #37

Merged
merged 19 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
recursive-include ipyaladin/static *.*
graft ipyaladin/nbextension
graft ipyaladin/labextension

graft js
graft tests
prune **/node_modules

include ipyaladin.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
57 changes: 14 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
ipyaladin
=========
# ipyaladin

Description
-----------
## Description

A bridge between Jupyter and Aladin Lite, enabling interactive sky visualization in IPython notebooks.

Expand All @@ -12,60 +10,33 @@ With a couple of lines, you can display Aladin Lite, center it on the target of

![ipyaladin example](ipyaladin-screencast.gif)

Examples
--------
## Examples

Some example notebooks can be found in the [examples directory](examples).

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/cds-astro/ipyaladin/master?filepath=examples)) You can also try it directly [in mybinder](https://mybinder.org/v2/gh/cds-astro/ipyaladin/master?filepath=examples), without installing anything.
[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/bmatthieu3/ipyaladin/fix-model-aladin). You can also try it directly [in mybinder](https://mybinder.org/v2/gh/bmatthieu3/ipyaladin/fix-model-aladin), without installing anything.

Installation
------------
## Installation

To install use pip:

$ pip install ipyaladin

Then, make sure to enable widgetsnbextension:
For a development installation (requires [Node.js](https://nodejs.org) and [Yarn version 1](https://classic.yarnpkg.com/)),

$ jupyter nbextension enable --py widgetsnbextension

Finally, enable ipyaladin:

$ jupyter nbextension enable --py --sys-prefix ipyaladin

There is also an experimental conda package that can be installed with:

$ conda install -c tboch ipyaladin


For a development installation (requires npm) you can either do:

$ git clone https://github.com/cds-astro/ipyaladin
$ git clone https://github.com/cds-astro/ipyaladin.git
$ cd ipyaladin
$ pip install -e .
$ jupyter nbextension install --py --symlink --sys-prefix ipyaladin
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix ipyaladin
$ jupyter nbextension enable --py --sys-prefix ipyaladin

or directly use the compile.sh script:

$ git clone https://github.com/cds-astro/ipyaladin
$ cd ipyaladin
$ ./compile.sh

Note:
Sometimes the module installation crash because of a conflict with an older occurence of itself, if so to solve this problem go to: ~/anaconda3/share/jupyter/nbextensions
Then suppress the ipyaladin corrupted file.
When actively developing your extension for JupyterLab, run the command:

Running in JupyterLab (experimental)
------------------------------------
$ jupyter labextension develop --overwrite ipyaladin

To enable ipyaladin in JupyterLab:
Then you need to rebuild the JS when you make a code change:

$ git clone https://github.com/cds-astro/ipyaladin
$ cd ipyaladin
$ python -m pip install [-e] .
$ cd ipyaladin/js
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager .
$ cd js
$ yarn run build

Now when you start JupyterLab you will be prompted to rebuild the extension. Choose 'Rebuild' and all the ipyaladin examples should now work.
You then need to refresh the JupyterLab page when your javascript changes.
71 changes: 53 additions & 18 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,53 @@
- To release a new version of ipyaladin on PyPI:

Update _version.py (set release version, remove 'dev')
git add and git commit
python setup.py sdist upload
python setup.py bdist_wheel upload
git tag -a X.X.X -m 'comment'
Update _version.py (add 'dev' and increment minor)
git add and git commit
git push
git push --tags

- To release a new version of ipyaladin on NPM:

# nuke the `dist` and `node_modules`
git clean -fdx
npm install
npm publish
# 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 ipyaladin 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 ipyaladin on PyPI, first make sure that the `build` package is installed: `pip install build`.

1. Update `ipyaladin/_version.py`:
- Update `__version__`
- Update `NPM_PACKAGE_RANGE` if necessary
2. Commit changes to `_version.py` and tag the release
```
git add ipyaladin/_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
```
5 changes: 5 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
npm install --global yarn
pip install -e .
jupyter nbextension install --py --symlink --overwrite --sys-prefix ipyaladin
jupyter nbextension enable --py --sys-prefix ipyaladin
jupyter labextension develop ipyaladin --overwrite
2 changes: 2 additions & 0 deletions binder/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
astropy
astroquery
1 change: 1 addition & 0 deletions binder/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.8.8
8 changes: 3 additions & 5 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/sh

cd js
npm install
cd ..
npm install yarn
pip install -e .
jupyter nbextension install --py --symlink --sys-prefix ipyaladin
jupyter nbextension install --py --symlink --overwrite --sys-prefix ipyaladin
jupyter nbextension enable --py --sys-prefix ipyaladin

jupyter labextension develop ipyaladin --overwrite
7 changes: 4 additions & 3 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "ipyaladin" %}
{% set version = "0.1.4" %}
{% set version = "0.1.10" %}
{% set file_ext = "tar.gz" %}
{% set hash_type = "sha256" %}
{% set hash_value = "64f684a8c24f574e35f1285c0ca40e45fc28c4e9dca7a304b7b46f1e25607492" %}
Expand All @@ -20,7 +20,9 @@ build:
requirements:
build:
- python
- setuptools
- jupyter_packaging
- jupyterlab
- setuptools >=40.8.0
- ipywidgets >=6.0.0
run:
- python
Expand All @@ -44,4 +46,3 @@ about:
extra:
recipe-maintainers:
- tboch

4 changes: 4 additions & 0 deletions conda-recipe/post-link.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@echo off

Rem Activate ipyaladin for simple notebooks
"%PREFIX%\Scripts\jupyter-nbextension.exe" --py --symlink --overwrite --sys-prefix ipyaladin > NUL 2>&1 && if errorlevel 1 exit 1
"%PREFIX%\Scripts\jupyter-nbextension.exe" enable ipyaladin --py --sys-prefix > NUL 2>&1 && if errorlevel 1 exit 1
Rem Activate ipyaladin extension for jupyter lab
"%PREFIX%\Scripts\jupyter-labextension.exe" develop ipyaladin --overwrite > NUL 2>&1 && if errorlevel 1 exit 1
7 changes: 5 additions & 2 deletions conda-recipe/post-link.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
"${PREFIX}/bin/jupyter-nbextension" enable ipyaladin --py --sys-prefix

# Activate ipyaladin for simple notebooks
"${PREFIX}/bin/jupyter-nbextension" --py --symlink --overwrite --sys-prefix ipyaladin
"${PREFIX}/bin/jupyter-nbextension" enable --py --sys-prefix ipyaladin
# Activate ipyaladin extension for jupyter lab
"${PREFIX}/bin/jupyter-labextension" develop ipyaladin --overwrite
11 changes: 0 additions & 11 deletions environment.yml

This file was deleted.

5 changes: 5 additions & 0 deletions install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "ipyaladin",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package ipyaladin"
}
5 changes: 5 additions & 0 deletions ipyaladin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"load_extensions": {
"ipyaladin/extension": true
}
}
39 changes: 37 additions & 2 deletions ipyaladin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
from ._version import version_info, __version__
from ._version import __version__

from .aladin_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': 'ipyaladin',
}]


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': 'static',
'src': 'nbextension',
'dest': 'ipyaladin',
'require': 'ipyaladin/extension'
}]
7 changes: 3 additions & 4 deletions ipyaladin/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#version_info = (0, 1, 0, 'dev')
version_info = (0, 1, 9)
__version__ = '.'.join(map(str, version_info))

# Module version
__version__ = '0.1.10'

NPM_PACKAGE_RANGE='^0.1.10'
26 changes: 17 additions & 9 deletions ipyaladin/aladin_widget.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
from ipywidgets import (widgets)
import ipywidgets as widgets
from traitlets import (Float, Unicode, Bool, List, Dict, default)
from ._version import NPM_PACKAGE_RANGE

# See js/lib/example.js for the frontend counterpart to this file.

@widgets.register
class Aladin(widgets.DOMWidget):
"""An example widget."""

# Name of the widget view class in front-end
_view_name = Unicode('AladinView').tag(sync=True)

# Name of the widget model class in front-end
_model_name = Unicode('AladinModel').tag(sync=True)

""" Definition of the AladinLite widget in the python kernel """
class Aladin(widgets.DOMWidget):
_view_name = Unicode('ViewAladin').tag(sync=True)
_model_name = Unicode('ModelAladin').tag(sync=True)

# Name of the front-end module containing widget view
_view_module = Unicode('ipyaladin').tag(sync=True)
_model_module = Unicode('ipyaladin').tag(sync=True)

_view_module_version = Unicode('0.1.9').tag(sync=True)
_model_module_version = Unicode('0.1.9').tag(sync=True)
# Name of the front-end module containing widget model
_model_module = Unicode('ipyaladin').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)

# Aladin options must be declared here (as python class's attributes),
# so that they can be synchronized from the python side to the javascript side
Expand Down
11 changes: 11 additions & 0 deletions js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ipyaladin

Package Install
---------------

**Prerequisites**
- [node](http://nodejs.org/)

```bash
npm install --save ipyaladin2
```
8 changes: 8 additions & 0 deletions js/amd-public-path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// In an AMD module, we set the public path using the magic requirejs 'module' dependency
// See https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#module
// Since 'module' is a requirejs magic module, we must include 'module' in the webpack externals configuration.
import * as module from 'module';
const url = new URL(module.uri, document.location)
// Using lastIndexOf('/')+1 gives us the empty string if there is no '/', so pathname becomes '/'
url.pathname = url.pathname.slice(0,url.pathname.lastIndexOf('/')+1);
__webpack_public_path__ = `${url.origin}${url.pathname}`;
Loading