-
Notifications
You must be signed in to change notification settings - Fork 53
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
PTV-1315 Fix AlignmentSet viewer #2501
base: develop
Are you sure you want to change the base?
Changes from 19 commits
6ca7e5c
c918671
acb152e
91ae02c
bd57026
bb54451
d1885db
fb5e493
d505ca6
0bfc5a9
2b80522
e4a5e2b
8f6bb25
7d49f12
cd58cf5
af4524a
eeaa4bf
cff7f08
abd0057
de8fc7e
5dc8ef6
11e1f54
505b59f
6559f7b
5ae7ca1
f3d16aa
c79a888
b6e0e90
0412355
8364701
5b4a457
f7cc9dd
4a382e4
7ae5fc8
687a147
4c3e873
0369e62
e30fc6b
86fa014
c9feac9
cb89ffe
a819699
43ee556
c241c8a
6170784
bab2335
d56e40e
9ea17c4
d1d796f
a690d54
a8a0d79
d2c482c
b07e84d
5a01d4a
152e8a6
4ce8d52
a904655
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "stylelint-config-standard" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
define([ | ||
'react' | ||
], ( | ||
React | ||
) => { | ||
'use strict'; | ||
|
||
const { createElement: e, Component } = React; | ||
|
||
/** | ||
* A class to display an error message. | ||
* | ||
* This is a simple error viewer. It does not show extended information like | ||
* stacktrace, or richer data from Service clients, like the error code. | ||
* It should handle service client errors, any error based on the Error class, | ||
* any object which has a "message" property, and a simple string. | ||
*/ | ||
class ErrorMessage extends Component { | ||
render() { | ||
const error = this.props.error; | ||
let message; | ||
if (typeof error === 'object' && error !== null) { | ||
if (error.error && error.error.message) { | ||
// handle errors thrown by kbase service clients | ||
message = error.error.message; | ||
} else if (error.message) { | ||
// Standard Error objects or descendants, or those which act like one in this regard. | ||
message = error.message; | ||
} else { | ||
message = 'Unknown Error'; | ||
} | ||
} else if (typeof error === 'string') { | ||
message = error; | ||
} else { | ||
message = 'Unknown Error'; | ||
} | ||
|
||
return e('div', { | ||
className: 'alert alert-danger' | ||
}, [ | ||
'Error: ', | ||
message | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could remove both the |
||
]); | ||
} | ||
} | ||
|
||
return ErrorMessage; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
/* | ||
kbaseGenericSetViewer | ||
|
||
A widget which can display a data object visualization for several types of objects | ||
in the "KBaseSets" type module. | ||
|
||
The primary task of this viewer is to look up the object type it is provided, and, based | ||
on the type of the object, either dispatch to the set viewer if it is supported, or | ||
display a warning that the type is not supported if it isn't. | ||
|
||
Support is indicated in the module-level `SET_TYPE_TO_MODULE_MAPPING`. | ||
|
||
At present just ReadsAlignmentSet and AssemblySet are supported; others should display | ||
an error message, or are handled by other viewers. | ||
|
||
Note that this widget is a wrapper dispatching to the specific viewer, most of the | ||
implementation is in the React components referred two in the AMD dependencies. The only | ||
UI supported herein is the loading indicator and an error message, if necessary. | ||
|
||
The original intention of this viewer was to support all of the types implemented in KBaseSets, | ||
but that work has not yet been completed: | ||
|
||
Also, see: https://github.com/kbase/NarrativeViewers/blob/dd1eeeba0ba1faacd6c3596a9413109aeb82e32e/ui/narrative/methods/view_generic_set/spec.json#L21 | ||
|
||
Below is the status of each KBaseSet type: | ||
|
||
Implemented in this viewer: | ||
|
||
KBaseSets.ReadsAlignmentSet | ||
SetAPI.get_reads_alignment_set_v1 | ||
|
||
KBaseSets.AssemblySet | ||
SetAPI.get_assembly_set_v1 | ||
|
||
Implemented in other viewers: | ||
|
||
KBaseSets.DifferentialExpressionMatrixSet | ||
SetAPI.get_differential_expression_matrix_set_v1 | ||
Implemented by: | ||
https://github.com/kbase/NarrativeViewers/blob/dd1eeeba0ba1faacd6c3596a9413109aeb82e32e/ui/narrative/methods/view_differential_expression_matrix_set/spec.json | ||
and this viewer does not work | ||
|
||
KBaseSets.ExpressionSet | ||
SetAPI.get_expression_set_v1 | ||
Implemented by: | ||
https://github.com/kbase/NarrativeViewers/blob/dd1eeeba0ba1faacd6c3596a9413109aeb82e32e/ui/narrative/methods/view_rnaseq_sample_expression/spec.json | ||
and that viewer doesn't work | ||
|
||
KBaseSets.ReadsSet | ||
SetAPI.get_reads_set_v1 | ||
Implemented by: | ||
https://github.com/kbase/NarrativeViewers/blob/dd1eeeba0ba1faacd6c3596a9413109aeb82e32e/ui/narrative/methods/view_reads_set/spec.json | ||
and the current viewer works | ||
|
||
KBaseSets.SampleSet | ||
SetAPI.sample_set_to_samples_info (I think) | ||
Implemented by: | ||
https://github.com/kbase/NarrativeViewers/tree/master/ui/narrative/methods/view_sample_set | ||
but not that this viewer does not utilize the SetAPI, which was implemented against the search, which | ||
has never been fully implemented for search. Also Samples and RNASeqSamples seem to be conflated | ||
a bit in SetAPI. | ||
|
||
Not implemented anywhere: | ||
|
||
KBaseSets.FeatureSetSet | ||
SetAPI.get_feature_set_set_v1 | ||
can't find any data, or any app which outputs this type, or accepts as input (according to the app browser) | ||
|
||
KBaseSets.GenomeSet | ||
SetAPI.get_genome_set_v1 | ||
|
||
*/ | ||
define([ | ||
'react', | ||
'kb_common/jsonRpc/genericClient', | ||
'kb_service/utils', | ||
'widgets/function_output/KBaseSets/types/ReadsAlignmentSet', | ||
'widgets/function_output/KBaseSets/types/AssemblySet', | ||
'react_components/ErrorMessage', | ||
'widgets/function_output/KBaseSets/SetLoader', | ||
|
||
// For effect | ||
'bootstrap' | ||
], ( | ||
React, | ||
ServiceClient, | ||
ServiceUtils, | ||
ReadsAlignmentSet, | ||
AssemblySet, | ||
ErrorMessage, | ||
SetLoader | ||
) => { | ||
'use strict'; | ||
|
||
const { createElement: e, Component } = React; | ||
|
||
// Note that any modules referenced must be imported above, and that such modules | ||
// must be components implemented as defined in `react_components/genericSets`. | ||
const SET_TYPE_TO_MODULE_MAPPING = { | ||
'KBaseSets.ReadsAlignmentSet': { | ||
module: ReadsAlignmentSet, | ||
method: 'get_reads_alignment_set_v1' | ||
}, | ||
'KBaseSets.AssemblySet': { | ||
module: AssemblySet, | ||
method: 'get_assembly_set_v1' | ||
} | ||
}; | ||
|
||
/* | ||
Implements a React component which primarily dispatches to the component which | ||
matches the type of object provided in the prop 'objectRef'. | ||
*/ | ||
class Dispatcher extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
status: null, | ||
// setType: null, | ||
// error: null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm comments |
||
}; | ||
} | ||
|
||
async componentDidMount() { | ||
this.setState({ | ||
status: 'loading' | ||
}); | ||
|
||
try { | ||
const workspace = new ServiceClient({ | ||
url: this.props.workspaceURL, | ||
module: 'Workspace', | ||
token: this.props.token | ||
}); | ||
|
||
const [infos] = await workspace.callFunc('get_object_info_new', [{ | ||
objects: [{ | ||
ref: this.props.objectRef | ||
}] | ||
}]); | ||
|
||
// Get a nicer object info (an object rather than array) | ||
const objectInfo = ServiceUtils.objectInfoToObject(infos[0]); | ||
|
||
// Make a versionless object type id for lookup in the set of supported | ||
// set types defined above. | ||
const objectType = [objectInfo.typeModule, objectInfo.typeName].join('.'); | ||
|
||
const mapping = SET_TYPE_TO_MODULE_MAPPING[objectType]; | ||
if (!mapping) { | ||
this.setState({ | ||
status: 'error', | ||
error: new Error(`Unsupported set type: ${this.state.setType}`) | ||
}); | ||
return; | ||
} | ||
|
||
this.setState({ | ||
status: 'loaded', | ||
setType: objectType, | ||
module: mapping.module, | ||
method: mapping.method | ||
}); | ||
} catch (error) { | ||
console.error('Error getting object info', error); | ||
this.setState({ | ||
status: 'error', | ||
error | ||
}); | ||
} | ||
} | ||
|
||
renderError() { | ||
return e(ErrorMessage, { | ||
error: this.state.error | ||
}); | ||
} | ||
|
||
renderLoaded() { | ||
return e(SetLoader, { | ||
token: this.props.token, | ||
workspaceURL: this.props.workspaceURL, | ||
serviceWizardURL: this.props.serviceWizardURL, | ||
objectRef: this.props.objectRef, | ||
method: this.state.method, | ||
module: this.state.module | ||
}); | ||
|
||
// return e(this.state.module, { | ||
// token: this.props.token, | ||
// workspaceURL: this.props.workspaceURL, | ||
// serviceWizardURL: this.props.serviceWizardURL, | ||
// objectRef: this.props.objectRef | ||
// }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm comments |
||
} | ||
|
||
render() { | ||
switch (this.state.status) { | ||
case null: | ||
case 'loading': | ||
return e('div', null, 'Loading...'); | ||
case 'error': | ||
return this.renderError(); | ||
case 'loaded': | ||
return this.renderLoaded(); | ||
} | ||
} | ||
} | ||
|
||
return Dispatcher; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit misleadingly named as it actually moves kbase node modules elsewhere; it doesn't install npm modules if they aren't already there. Can you rename it something more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Had hoped it was clear that the "-node-modules" suffix implies that it installs stuff from "node_modules", rather than something like "-node-packages", which nom install does, but alas clearly not, and punning off of make install, which since it "installs" node modules into the narrative.
So, brand-new name: "copy-node-modules-into-ext-modules" captures that it is a "copy", that the subject is the "node modules" directory tree, and that they are being copied into the "ext_modules" directory, which is where node package UMD modules and related assets are installed, er, copied for usage in the front end.