Skip to content

Commit

Permalink
Attempts to understand jupyterlab
Browse files Browse the repository at this point in the history
  • Loading branch information
danlester committed Jul 26, 2019
1 parent 9e14cb8 commit dc742a7
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 44 deletions.
2 changes: 1 addition & 1 deletion jupyter-innotater/js/lib/customwidgets.js
Expand Up @@ -8,7 +8,7 @@ var _ = require('lodash');
var $ = require('jquery');


var FocusTextView = widgets.TextView.extend({
var FocusTextView = controls.TextView.extend({

events: function () {
var d = FocusTextView.__super__.events(this, arguments);
Expand Down
6 changes: 3 additions & 3 deletions jupyter-innotater/js/lib/embed.js
Expand Up @@ -7,9 +7,9 @@
// This file is currently being required by index.js entry point too

// Export widget models and views, and the npm package version number.
var _ = require('lodash');
// var _ = require('lodash');

module.exports = require('./innotaterwidget.js');
_.extend( module.exports, require('./imagewidget.js') );
_.extend( module.exports, require('./customwidgets.js') );
// _.extend( module.exports, require('./imagewidget.js') );
// _.extend( module.exports, require('./customwidgets.js') );
module.exports['version'] = require('../package.json').version;
31 changes: 18 additions & 13 deletions jupyter-innotater/js/lib/innotaterwidget.js
Expand Up @@ -19,21 +19,22 @@ var $ = require('jquery');
//
// when different from the base class.

var version = require('../package.json').version;
let version = require('../package.json').version;
let semver_range = '~' + version;

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


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

initialize: function() {
Expand All @@ -48,7 +49,9 @@ var InnotaterView = controls.VBoxView.extend({
var self = this;
InnotaterView.__super__.render.apply(this, arguments);

self.el.setAttribute('tabindex', '0');
console.log("RENDER JI");

/* self.el.setAttribute('tabindex', '0');
if (window.location.hostname == "www.kaggleusercontent.com") {
this.el.classList.add('innotater-kaggle');
Expand All @@ -59,7 +62,7 @@ var InnotaterView = controls.VBoxView.extend({
self.el.addEventListener('keypress', function(e) {
self.handle_keypress(e);
});
}
} */
},

handle_keypress: function(event) {
Expand All @@ -72,9 +75,11 @@ var InnotaterView = controls.VBoxView.extend({
});

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





20 changes: 11 additions & 9 deletions jupyter-innotater/js/lib/labplugin.js
@@ -1,24 +1,26 @@
"use strict";
//Object.defineProperty(exports, "__esModule", { value: true });

var innotater = require('./embed.js');

// "@jupyter-widgets/controls": "^1.5.0",

// "@jupyter-widgets/base": "^2.0",

var base = require('@jupyter-widgets/base');

const innotaterPlugin = {
module.exports = [{
id: 'jupyter-innotater',
requires: [base.IJupyterWidgetRegistry],
autoStart: true,
activate: function(app, widgets) {
console.log("JL Innotater activated");
console.log(innotater.version);

widgets.registerWidget({
name: 'jupyter-innotater',
name: 'jupyterinnotater',
version: innotater.version,
exports: innotater
});
},
autoStart: true
};

exports.default = innotaterPlugin;
}
}];

console.log("JL Innotater loaded");
4 changes: 2 additions & 2 deletions jupyter-innotater/js/package.json
Expand Up @@ -39,8 +39,8 @@
"webpack-build-notifier": "^0.1.30"
},
"dependencies": {
"@jupyter-widgets/base": "^1.0.0",
"@jupyter-widgets/controls": "^1.0.0",
"@jupyter-widgets/base": "^1.1 || ^2",
"@jupyter-widgets/controls": "^1.5",
"d3": "^4.10.2",
"lodash": "^4.17.4"
}
Expand Down
12 changes: 7 additions & 5 deletions jupyter-innotater/jupyter_innotater/__init__.py
Expand Up @@ -4,12 +4,14 @@
from .innotaterwidget import *
from .__meta__ import __version__

from .data import *
from .combine import *
#from .data import *
#from .combine import *

__all__ = ['GroupedInnotation', 'RepeatInnotation'] \
+ ['ImageInnotation', 'BoundingBoxInnotation', 'MultiClassInnotation', 'BinaryClassInnotation', 'TextInnotation'] \
+ ['Innotater']
# __all__ = ['GroupedInnotation', 'RepeatInnotation'] \
# + ['ImageInnotation', 'BoundingBoxInnotation', 'MultiClassInnotation', 'BinaryClassInnotation', 'TextInnotation'] \
# + ['Innotater']

__all__ = ['Innotater']

def _jupyter_nbextension_paths():
return [{
Expand Down
2 changes: 2 additions & 0 deletions jupyter-innotater/jupyter_innotater/__meta__.py
Expand Up @@ -15,3 +15,5 @@ def _get_version(version_info):

version_info = (0, 1, 6, 'final', 0)
__version__ = _get_version(version_info)

semver_range = '~%s.%s.%s' % (version_info[:3])
4 changes: 2 additions & 2 deletions jupyter-innotater/jupyter_innotater/imagewidget.py
Expand Up @@ -8,8 +8,8 @@ class ImagePad(widgets.Image):
_model_name = Unicode('InnotaterImagePadModel').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.6').tag(sync=True)
_model_module_version = Unicode('~0.1.6').tag(sync=True)
_view_module_version = Unicode('~0.1.9').tag(sync=True)
_model_module_version = Unicode('~0.1.9').tag(sync=True)

# rect = List(trait=Int).tag(sync=True)
rects = List(trait=Int).tag(sync=True)
Expand Down
17 changes: 10 additions & 7 deletions jupyter-innotater/jupyter_innotater/innotaterwidget.py
@@ -1,21 +1,24 @@
import ipywidgets as widgets
from ipywidgets import HBox, VBox, IntSlider, Button, Checkbox
from ipywidgets import DOMWidget, HBox, VBox, IntSlider, Button, Checkbox
from traitlets import Int, observe, Unicode, Bool
from .manager import DataManager
from .__meta__ import semver_range


@widgets.register
class Innotater(VBox):
class Innotater(VBox): #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.6').tag(sync=True)
_model_module_version = Unicode('~0.1.6').tag(sync=True)
#_model_name = Unicode('InnotaterModel').tag(sync=True)
_view_module = Unicode('jupyterinnotater').tag(sync=True)
#_model_module = Unicode('jupyterinnotater').tag(sync=True)
_view_module_version = Unicode(semver_range).tag(sync=True)
#_model_module_version = Unicode(semver_range).tag(sync=True)

index = Int().tag(sync=True)
keyboard_shortcuts = Bool(False).tag(sync=True)

class nothing:

def __init__(self, inputs, targets, indexes=None, keyboard_shortcuts=True):

self.path = ''
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
@@ -1,6 +1,6 @@
# This requirements.txt is only really for binder
ipywidgets==7.4.2
widgetsnbextension==3.4.2
ipywidgets==7.5.0
widgetsnbextension==3.5.0
notebook==5.7.8
numpy==1.16.2
pandas==0.24.2
Expand Down

0 comments on commit dc742a7

Please sign in to comment.