Skip to content

Commit

Permalink
Refactored and css class added for Kaggle
Browse files Browse the repository at this point in the history
  • Loading branch information
danlester committed Mar 19, 2019
1 parent 4ec63bd commit 83f257a
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 26 deletions.
6 changes: 4 additions & 2 deletions RELEASE.md
@@ -1,7 +1,8 @@
- To release a new version of jupyter_innotater on PyPI:

Update _version.py (set release version, remove 'dev')
git add the _version.py file and git commit
Update __meta__.py (set release version, remove 'dev')
Also change version number in package.json
git add the __meta__.py file and git commit
`python setup.py sdist upload`
`python setup.py bdist_wheel upload`
`git tag -a X.X.X -m 'comment'`
Expand All @@ -10,6 +11,7 @@ git add and git commit
git push
git push --tags


- To release a new version of jupyter-innotater on NPM:

```
Expand Down
9 changes: 7 additions & 2 deletions jupyter-innotater/js/lib/embed.js
Expand Up @@ -4,6 +4,11 @@
// dynamic baseURL for the static assets and may load some css that would
// already be loaded by the notebook otherwise.

// This file is currently being required by index.js entry point too

// Export widget models and views, and the npm package version number.
module.exports = require('./widget.js');
module.exports['version'] = require('../package.json').version;
var _ = require('lodash');

module.exports = require('./innotaterwidget.js');
_.extend( module.exports, require('./imagewidget.js') );
module.exports['version'] = require('../package.json').version;
Expand Up @@ -7,8 +7,6 @@ var _ = require('lodash');
var $ = require('jquery');


//var drawing_pad = require('./drawing-pad');


// Custom Model. Custom widgets models must at least provide default values
// for model attributes, including
Expand All @@ -29,14 +27,14 @@ var $ = require('jquery');

var InnotaterImagePadModel = controls.ImageModel.extend({
defaults: _.extend(controls.ImageModel.prototype.defaults(), {
_model_name: 'InnotaterImagePadModel',
/*_model_name: 'InnotaterImagePadModel',
_view_name: 'InnotaterImagePadView',
_model_module: 'jupyter-innotater',
_view_module: 'jupyter-innotater',
_model_module_version: '0.1.0',
_view_module_version: '0.1.0',
rect: [0,0,0,0],
is_bb_source: false
_view_module_version: '0.1.0', */
/*rect: [0,0,0,0],
is_bb_source: false */
})
});

Expand Down
3 changes: 1 addition & 2 deletions jupyter-innotater/js/lib/index.js
Expand Up @@ -8,5 +8,4 @@
__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/jupyter-innotater/';

// Export widget models and views, and the npm package version number.
module.exports = require('./widget.js');
module.exports['version'] = require('../package.json').version;
module.exports = require('./embed.js');
52 changes: 52 additions & 0 deletions jupyter-innotater/js/lib/innotaterwidget.js
@@ -0,0 +1,52 @@
var widgets = require('@jupyter-widgets/base');
var controls = require('@jupyter-widgets/controls');

require("./style.css");

var _ = require('lodash');
//var $ = require('jquery');



// Custom Model. Custom widgets models must at least provide default values
// for model attributes, including
//
// - `_view_name`
// - `_view_module`
// - `_view_module_version`
//
// - `_model_name`
// - `_model_module`
// - `_model_module_version`
//
// when different from the base class.


var InnotaterModel = controls.VBoxModel.extend({
defaults: _.extend(controls.VBoxModel.prototype.defaults(), {
/* _model_name: 'InnotaterModel',
_view_name: 'InnotaterView',
_model_module: 'jupyter-innotater',
_view_module: 'jupyter-innotater',
_model_module_version: '0.1.0',
_view_module_version: '0.1.0' */
})
});


// Custom View. Renders the widget model.
var InnotaterView = controls.VBoxView.extend({

InnotaterView: function() {
InnotaterView.__super__.apply(this, arguments);
}

});

module.exports = {
InnotaterView: InnotaterView,
InnotaterModel: InnotaterModel
};



7 changes: 7 additions & 0 deletions jupyter-innotater/js/lib/style.css
Expand Up @@ -10,3 +10,10 @@ canvas.jupyter-innotater-imagepad {
canvas.jupyter-innotater-imagepad.is_bb_source {
cursor: crosshair;
}

/* Kaggle Overrides */

.innotater-base .widget-hbox {
width: 90% !important;
display: flex !important;
}
2 changes: 1 addition & 1 deletion jupyter-innotater/js/package.json
@@ -1,6 +1,6 @@
{
"name": "jupyter-innotater",
"version": "0.1.0",
"version": "0.1.1",
"description": "An Inline Data Annotator for Jupyter",
"author": "danlester",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion jupyter-innotater/jupyter_innotater/__init__.py
@@ -1,4 +1,4 @@
from .widget import *
from .innotaterwidget import *

from .__meta__ import __version__

Expand Down
5 changes: 3 additions & 2 deletions jupyter-innotater/jupyter_innotater/__meta__.py
Expand Up @@ -10,7 +10,8 @@ def _get_version(version_info):
return version


# meta data
# meta data - change dev to final for release
# also change in package.json

version_info = (0, 1, 0, 'final', 0)
version_info = (0, 1, 1, 'dev', 0)
__version__ = _get_version(version_info)
2 changes: 1 addition & 1 deletion jupyter-innotater/jupyter_innotater/data.py
@@ -1,4 +1,4 @@
from .image import ImagePad
from .imagewidget import ImagePad
from ipywidgets import Checkbox, Select, Text
import re
from pathlib import Path
Expand Down
@@ -1,16 +1,16 @@
import ipywidgets as widgets
from ipywidgets import HBox, VBox, IntSlider, Checkbox, Button
from traitlets import Int, observe
from ipywidgets import HBox, VBox, IntSlider, Button
from traitlets import Int, observe, Unicode
from .manager import DataManager

@widgets.register
class Innotater(VBox):
#_view_name = Unicode('InnotaterView').tag(sync=True)
#_model_name = Unicode('InnotaterModel').tag(sync=True)
#_view_module = Unicode('jupyter-innotater').tag(sync=True)
#_model_module = Unicode('jupyter-innotater').tag(sync=True)
#_view_module_version = Unicode('~0.1.0').tag(sync=True)
#_model_module_version = Unicode('~0.1.0').tag(sync=True)
_view_name = Unicode('InnotaterView').tag(sync=True)
_model_name = Unicode('InnotaterModel').tag(sync=True)
_view_module = Unicode('jupyter-innotater').tag(sync=True)
_model_module = Unicode('jupyter-innotater').tag(sync=True)
_view_module_version = Unicode('~0.1.0').tag(sync=True)
_model_module_version = Unicode('~0.1.0').tag(sync=True)

index = Int().tag(sync=True)

Expand All @@ -30,6 +30,8 @@ def __init__(self, inputs, targets):
self.input_widgets = [dw.get_widget() for dw in self.datamanager.get_inputs()]
self.target_widgets = [dw.get_widget() for dw in self.datamanager.get_targets()]

self.add_class('innotater-base');

super().__init__([HBox([VBox(self.input_widgets), VBox(self.target_widgets)]), HBox([self.prevbtn, slider, self.nextbtn])])

jsl = widgets.jslink((slider, 'value'), (self, 'index'))
Expand Down
3 changes: 2 additions & 1 deletion jupyter-innotater/setup.py
Expand Up @@ -53,7 +53,8 @@
classifiers = ['Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
]
include_package_data = True
data_files = [
Expand Down

0 comments on commit 83f257a

Please sign in to comment.