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 model version separate from package version #448

Merged
merged 3 commits into from
Apr 13, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
Expand Down
8 changes: 7 additions & 1 deletion ipympl/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
version_info = (0, 8, 8)
__version__ = '.'.join(map(str, version_info))
js_semver = '^0.10.5'


# The versions of protocol of communication with the frontend that this python verison knows
# how to speak. See counterpart in the src/version.ts file.
# These should not be changed unless we introduce changes to communication between
# frontend and backend.
__MODEL_VERSION__ = "1.0.0"
10 changes: 5 additions & 5 deletions ipympl/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
observe,
)

from ._version import js_semver
from ._version import __MODEL_VERSION__

cursors_str = {
cursors.HAND: 'pointer',
Expand Down Expand Up @@ -93,11 +93,11 @@ def connection_info():
class Toolbar(DOMWidget, NavigationToolbar2WebAgg):

_model_module = Unicode('jupyter-matplotlib').tag(sync=True)
_model_module_version = Unicode(js_semver).tag(sync=True)
_model_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_model_name = Unicode('ToolbarModel').tag(sync=True)

_view_module = Unicode('jupyter-matplotlib').tag(sync=True)
_view_module_version = Unicode(js_semver).tag(sync=True)
_view_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_view_name = Unicode('ToolbarView').tag(sync=True)

toolitems = List().tag(sync=True)
Expand Down Expand Up @@ -180,11 +180,11 @@ def _on_orientation_collapsed_changed(self, change):
class Canvas(DOMWidget, FigureCanvasWebAggCore):

_model_module = Unicode('jupyter-matplotlib').tag(sync=True)
_model_module_version = Unicode(js_semver).tag(sync=True)
_model_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_model_name = Unicode('MPLCanvasModel').tag(sync=True)

_view_module = Unicode('jupyter-matplotlib').tag(sync=True)
_view_module_version = Unicode(js_semver).tag(sync=True)
_view_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_view_name = Unicode('MPLCanvasView').tag(sync=True)

toolbar = Instance(Toolbar, allow_none=True).tag(sync=True, **widget_serialization)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
'pillow',
'traitlets<6',
'ipywidgets>=7.6.0,<8',
'matplotlib>=2.0.0,<4',
'matplotlib>=3.4.0,<4',
],
extras_require={
"docs": [
Expand Down
6 changes: 3 additions & 3 deletions src/mpl_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import * as utils from './utils';

import { MODULE_VERSION } from './version';
import { MODEL_VERSION } from './version';

import { ToolbarView } from './toolbar_widget';

Expand All @@ -30,8 +30,8 @@ export class MPLCanvasModel extends DOMWidgetModel {
_view_name: 'MPLCanvasView',
_model_module: 'jupyter-matplotlib',
_view_module: 'jupyter-matplotlib',
_model_module_version: '^' + MODULE_VERSION,
_view_module_version: '^' + MODULE_VERSION,
_model_module_version: MODEL_VERSION,
_view_module_version: MODEL_VERSION,
header_visible: true,
footer_visible: true,
toolbar: null,
Expand Down
6 changes: 3 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Widget } from '@phosphor/widgets';

import { IJupyterWidgetRegistry } from '@jupyter-widgets/base';

import { MODULE_NAME, MODULE_VERSION } from './version';
import { MODEL_VERSION, MODULE_NAME } from './version';

const EXTENSION_ID = 'matplotlib-jupyter:main';

Expand All @@ -31,7 +31,7 @@ function activateWidgetExtension(
): void {
registry.registerWidget({
name: MODULE_NAME,
version: MODULE_VERSION,
exports: () => import('./index'),
version: MODEL_VERSION,
exports: (): any => import('./index'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this gets rid of the typescript error, but is probably not the best way to do that.

});
}
6 changes: 3 additions & 3 deletions src/toolbar_widget.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DOMWidgetModel, DOMWidgetView } from '@jupyter-widgets/base';

import { MODULE_VERSION } from './version';
import { MODEL_VERSION } from './version';

import '../css/mpl_widget.css';

Expand All @@ -12,8 +12,8 @@ export class ToolbarModel extends DOMWidgetModel {
_view_name: 'ToolbarView',
_model_module: 'jupyter-matplotlib',
_view_module: 'jupyter-matplotlib',
_model_module_version: '^' + MODULE_VERSION,
_view_module_version: '^' + MODULE_VERSION,
_model_module_version: MODEL_VERSION,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure having the ^ does anything - and ipywidgets doesn't do this, so I removed it to be more similar to ipywidgets.

_view_module_version: MODEL_VERSION,
toolitems: [],
position: 'left',
button_style: '',
Expand Down
11 changes: 10 additions & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ const data = require('../package.json');
*
* The html widget manager assumes that this is the same as the npm package
* version number.
*
* See counterparts in the _version.py file
* These should not be changed unless we introduce changes to communication between
* frontend and backend.
*/
export const MODULE_VERSION = data.version;
export const MODEL_VERSION = '1.0.0';

/*
* The current package name.
*/
export const MODULE_NAME = data.name;

/*
* The package version
*/
export const MODULE_VERSION = data.version;