Skip to content

Commit

Permalink
Merge fa459d3 into ff03122
Browse files Browse the repository at this point in the history
  • Loading branch information
briehl committed Nov 21, 2017
2 parents ff03122 + fa459d3 commit 6b7ff5b
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 176 deletions.
20 changes: 6 additions & 14 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,24 @@
The Narrative Interface allows users to craft KBase Narratives using a combination of GUI-based commands, Python and R scripts, and graphical output elements.

This is built on the Jupyter Notebook v4.4.1 (more notes will follow).
### Version 3.5.2
- TASK-1089 - Import data slide out panel tracks what object is added to narrative. Add button turns into copy if objecct already exists. Add pop up when user copies and overrides exisiting object.
- TASK-1094 - Fix overlapping cells and buttons issue in Firefox
- TASK-1113/PUBLIC-148 - Import Panel scrolls if panel size is larger than screen size
- TASK-1088 - Data Pane maintains filters after refresh due to changes in narritve
- TASK-1114 - Add lock when editing name, that prevents data panel from refreshing with new data. Reliquenishes lock after 15 min if no activity.
- Style Fixes
- Fix bold font display inconsistencies between different browsers
- Move tooltip in datapanel from covering buttons to the top
- TASK-1158 - Standardize app and object cards in narrative and data panel


### Version 3.5.1
- TASK-1117 - Add importer for FBAModels to staging area
- TASK-1113/PUBLIC-148 - Import Panel scrolls if panel size is larger than screen size
- TASK-1114 - Add lock when editing name, that prevents data panel from refreshing with new data. Relinquishes lock after 15 min if no activity.
- TASK-1116 - Add PhenotypeSet importer to staging area
- TASK-1117 - Add importer for FBAModels to staging area
- TASK-1088 - Data Pane maintains filters after refresh due to changes in narrative
- TASK-1089 - Import data slide out panel tracks what object is added to narrative. "Add" button turns into "copy" if object already exists. Add pop up when user copies and overrides existing object.
- TASK-1094 - Fix overlapping cells and buttons issue in Firefox
- TASK-1113/PUBLIC-148 - Import Panel scrolls if panel size is larger than screen size
- TASK-1088 - Data Pane maintains filters after refresh due to changes in narrative
- Style Fixes
- Fix bold font display inconsistencies between different browsers
- Move tooltip in data panel from covering buttons to the top
- KBASE-4756 - Fix data type filtering in data panel slideout.
- PTV-225 - Fixes sorting by type in data panel
- PTV-225 - Fixes sorting by type in data panel
- PTV-535 - Fix RNA-seq viewer to properly handle multiple input types.
- PUBLIC-123 - Fix incorrect reaction counts in FBA Model viewer
- TASK-1158 - Standardize app and object cards in narrative and data panel

### Version 3.5.0
- TASK-1054 - Create a new loading window with a set of tasks to load and connect to (treats the problem of slowly loading websockets, still probably needs some adjusting).
Expand Down
2 changes: 1 addition & 1 deletion kbase-extension/static/kbase/config/staging_upload.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"id": "genbank_genome",
"name": "Genbank Genome"
"name": "GenBank Genome"
},
{
"id": "gff_genome",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* A simple widget intended to format and display errors that come from
* the narrative kernel (these are typically back-end errors that
* occur while running the function). The cause of these errors will
* probably be either errors with user inputs, or errors while
* probably be either errors with user inputs, or errors while
* communicating with the KBase API.
*
* @author Bill Riehl <wjriehl@lbl.gov>
Expand All @@ -18,32 +18,12 @@ define([
bootstrap,
$,
kbaseAccordion
) {
) {
'use strict';

return KBWidget({
/*
* (required) Your widget should be named in CamelCase.
*/
name: 'kbaseNarrativeError',
/*
* Extending kbaseAuthenticatedWidget lets you use auth tokens
* semi-automatically, assuming the page this is used in fires
* the loggedIn.kbase, loggedOut.kbase, and loggedInQuery events.
* These are usually fired by the kbaseLogin widget.
*
* this.user_id() = the logged in user id
* this.authToken() = the current authentication token
*/


/*
* (optional) Widgets should be semantically versioned.
* See http://semver.org
*/
version: '1.0.0',
/*
* (optional) Widgets are implied to include an options structure.
* It's useful to put default values here.
*/
options: {
error: {
'msg': 'An error occurred',
Expand All @@ -54,13 +34,13 @@ define([
},
/**
* (required) This is the only required function for a KBase Widget.
* @param {object} options - a structure containing the set of
* @param {object} options - a structure containing the set of
* options to be passed to this widget.
* @private
*/

init: function (options) {
this._super(options);

return this.render();
},
render: function () {
Expand Down Expand Up @@ -128,19 +108,16 @@ define([
.append($stackTraceAccordion);

new kbaseAccordion($stackTraceAccordion, {
elements: [
{
title: 'Detailed Error Message',
body: $('<pre>')
.addClass('kb-err-msg')
.append(esc(this.options.error.msg))
.append(format_tb(this.options.error)),
}
]
elements: [{
title: 'Detailed Error Message',
body: $('<pre>')
.addClass('kb-err-msg')
.append(esc(this.options.error.msg))
.append(format_tb(this.options.error)),
}]
}
);

return this;
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@
*/
/*global define*/
/*jslint white:true,browser:true*/
define (
[
'kbwidget',
'bootstrap',
'jquery',
'underscore',
'narrativeConfig',
'narrativeViewers',
'kbaseNarrativeCell',
'kb_service/utils'
], function(
KBWidget,
bootstrap,
$,
_,
Config,
Viewers,
kbaseNarrativeCell,
ServiceUtils
) {
define ([
'kbwidget',
'bootstrap',
'jquery',
'underscore',
'narrativeConfig',
'narrativeViewers',
'kbaseNarrativeCell',
'kb_service/utils'
], function(
KBWidget,
bootstrap,
$,
_,
Config,
Viewers,
kbaseNarrativeCell,
ServiceUtils
) {
'use strict';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<div class="row">
<div class="col-md-12">
<div id='upload-message'></div>
<div>Uploads will be canceled if this Narrative is closed!</div>
<div>Uploads in progress will be canceled if this Narrative is closed!</div>
</div>
</div>
</div>
<input type="hidden" name="destPath" value="/{{username}}"/>
<div class="dz-message" style="margin:3em 0">
<p>Drag and drop data files (or click) here!<br>
<p>Currently only supports Short Reads and Genome objects.
<p>Beta Preview - click the <i class="fa fa-question-circle"></i> for help.
<p>Drag and drop data files (or click) in this box to upload them to your staging area.<br><br>
<p>(Still in development -- more upload types will be added soon.)
<p>Click the <i class="fa fa-question-circle"></i> below for help.
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3>The currently loaded Narrative document is out of date.</h3>
</p>
{{#unless sameUser}}
<p>
You might consider getting in contact with <b>{{newVer.[10].name}}</b> before saving over their work.
You might consider getting in contact with <b>{{newVer.[5]}}</b> before saving over their work.
</p>
{{/unless}}
{{/unless}}
Expand Down
2 changes: 1 addition & 1 deletion scripts/narrative_backend_tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
export NARRATIVE_DIR=$(pwd)
python -m nose $@ --with-coverage --cover-html --cover-package=biokbase.narrative src/biokbase/narrative/tests/
python -m nose $@ --with-coverage --cover-html --cover-package=biokbase.narrative src/biokbase/narrative/tests
17 changes: 11 additions & 6 deletions src/biokbase/narrative/app_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import json
import biokbase.narrative.clients as clients
import biokbase.auth

"""
Some utility functions for running KBase Apps or Methods or whatever they are this week.
Expand Down Expand Up @@ -51,16 +52,20 @@ def system_variable(var):
except:
return None
elif var == 'token':
return os.environ.get('KB_AUTH_TOKEN', None)
token = biokbase.auth.get_auth_token()
if token == 'none':
return None
return token
elif var == 'user_id':
token = os.environ.get('KB_AUTH_TOKEN', None)
token = biokbase.auth.get_auth_token()
if token is None:
return None
m = re.match("un=(\w+)|", token)
if m is not None and len(m.groups()) == 1:
return m.group(1)
else:
try:
user_info = biokbase.auth.get_user_info(token)
return user_info.get('user', None)
except:
return None
# TODO: make this better with more exception handling.
else:
return None

Expand Down
23 changes: 15 additions & 8 deletions src/biokbase/narrative/tests/test_app_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tests for the app_util module
"""
import unittest
import biokbase.auth
from biokbase.narrative.app_util import (
check_tag,
system_variable,
Expand All @@ -12,6 +13,7 @@
from narrative_mock.mockclients import get_mock_client
import os
import mock
import util

__author__ = 'Bill Riehl <wjriehl@lbl.gov>'

Expand All @@ -24,12 +26,15 @@ def get_workspace_info(*args, **kwargs):
class AppUtilTestCase(unittest.TestCase):
@classmethod
def setUpClass(self):
config = util.TestConfig()
self.user_id = config.get('users', 'test_user')
self.user_token = util.read_token_file(config.get_path('token_files', 'test_user', from_root=True))

self.good_tag = "release"
self.bad_tag = "notATag"

# inject phony variables into the environment
self.user_id = "KBaseTest"
self.good_fake_token = "un={}|tokenid=12345|expiry=1592895594|client_id={}|token_type=bearer|SigningSubject=whaaaaaaaaaaat".format(self.user_id, self.user_id)
# self.user_id = "KBaseTest"
# self.good_fake_token = "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6"
self.bad_fake_token = "NotAGoodTokenLOL"
self.workspace = "valid_workspace"

Expand All @@ -44,8 +49,9 @@ def test_check_tag_bad_except(self):
check_tag(self.bad_tag, raise_exception=True)

def test_sys_var_user(self):
os.environ['KB_AUTH_TOKEN'] = self.good_fake_token
self.assertEquals(system_variable('user_id'), self.user_id)
if (self.user_token):
biokbase.auth.set_environ_token(self.user_token)
self.assertEquals(system_variable('user_id'), self.user_id)

def test_sys_var_no_ws(self):
if 'KB_WORKSPACE_ID' in os.environ:
Expand All @@ -57,8 +63,9 @@ def test_sys_var_workspace(self):
self.assertEquals(system_variable('workspace'), self.workspace)

def test_sys_var_token(self):
os.environ['KB_AUTH_TOKEN'] = self.good_fake_token
self.assertEquals(system_variable('token'), self.good_fake_token)
if (self.user_token):
biokbase.auth.set_environ_token(self.user_token)
self.assertEquals(system_variable('token'), self.user_token)

def test_sys_var_no_ws_id(self):
if 'KB_WORKSPACE_ID' in os.environ:
Expand All @@ -81,7 +88,7 @@ def test_sys_var_bad_token(self):
self.assertIsNone(system_variable('token'))

def test_sys_var_user_bad(self):
os.environ['KB_AUTH_TOKEN'] = self.bad_fake_token
biokbase.auth.set_environ_token(self.bad_fake_token)
self.assertIsNone(system_variable('user_id'))

def test_sys_var_user_none(self):
Expand Down
44 changes: 33 additions & 11 deletions src/biokbase/narrative/tests/test_widgetmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import mock
import os
from util import TestConfig
from narrative_mock.mockclients import get_mock_client

"""
Tests for the WidgetManager class
Expand All @@ -14,19 +15,13 @@

class WidgetManagerTestCase(unittest.TestCase):
@classmethod
@mock.patch('biokbase.narrative.widgetmanager.SpecManager')
def setUpClass(self, mock_sm):
def setUpClass(self):
config = TestConfig()
os.environ['KB_WORKSPACE_ID'] = '12345' # That's the same workspace as my luggage!
specs_list = config.load_json_file(config.get('specs', 'app_specs_file'))
specs_dict = dict()
for s in specs_list:
specs_dict[s['info']['id']] = s
mock_sm.return_value.app_specs = {
'release': specs_dict,
'beta': specs_dict,
'dev': specs_dict
}
app_specs_list = config.load_json_file(config.get('specs', 'app_specs_file'))
app_specs_dict = dict()
for s in app_specs_list:
app_specs_dict[s['info']['id']] = s
self.wm = WidgetManager()
self.good_widget = "kbaseTabTable"
self.bad_widget = "notAWidget"
Expand Down Expand Up @@ -81,5 +76,32 @@ def test_show_external_widget_list(self):
auth_required=True)
self.assertIsInstance(widget, IPython.core.display.Javascript)

@mock.patch('biokbase.narrative.widgetmanager.clients.get', get_mock_client)
def test_show_data_cell(self):
"""
Tests - should do the following:
def show_data_widget(self, upa, title=None, cell_id=None, tag="release"):
fail message with no upa
fail message with malformed upa
shouldn't care what title or cell_id are, but should test to make sure they wind up in
output code properly
fail if type spec'd app isn't present for some tag
otherwise, succeed and produce JS code.
test mocks.
"""
js_obj = self.wm.show_data_widget("18836/5/1", "some title", "no_id")
print(js_obj.data)
self.assertIsValidCellCode(js_obj, {}, "viewer", "kbaseGenomeView", "no_id", "some title")

def assertIsValidCellCode(self, js_obj, data, type, widget, cellId, title):
code_lines = js_obj.data.strip().split('\n')
print("wat{}wat".format(code_lines[0]))
self.assertTrue(code_lines[0].strip().startswith('element.html("<div id=\'kb-vis'))
self.assertEquals(code_lines[1].strip(), "require(['kbaseNarrativeOutputCell'], function(KBaseNarrativeOutputCell) {")
self.assertTrue(code_lines[2].strip().startswith(r"var w = new KBaseNarrativeOutputCell($('#kb-vis"))



if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 6b7ff5b

Please sign in to comment.