Skip to content

Commit

Permalink
Add onComputeInitialized. Minor code cleanup. Closes #1818 (#1821)
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb committed Jul 29, 2020
1 parent 79390c1 commit c4ea35d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ define([
overlay.on('click', async () => {
const {id, config} = await this.promptComputeConfig();
try {
await this.createInteractiveSession(id, config);
this.session = await this.createInteractiveSession(id, config);
const features = this.getCapabilities();
if (features.save) {
DeepForge.registerAction('Save', 'save', 10, () => this.save());
}
overlay.remove();
this.onComputeInitialized(this.session);
} catch (err) {
const title = 'Compute Creation Error';
const body = 'Unable to create compute. Please verify the credentials are correct.';
Expand All @@ -44,6 +45,9 @@ define([
});
}

onComputeInitialized(/*session*/) {
}

getCapabilities() {
return {
suspend: this.isOveridden('getEditorState') &&
Expand Down Expand Up @@ -91,7 +95,7 @@ define([
}

async createInteractiveSession(computeId, config) {
this.session = await Session.new(computeId, config);
return await Session.new(computeId, config);
}

destroy() {
Expand All @@ -103,6 +107,15 @@ define([

updateNode(/*desc*/) {
}

onActivate() {
}

onDeactivate() {
}

onWidgetContainerResize(/*width, height*/) {
}
}

return InteractiveEditorWidget;
Expand Down
15 changes: 8 additions & 7 deletions src/visualizers/widgets/TensorPlotter/TensorPlotterWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ define([
}

async createInteractiveSession(computeId, config) {
this.session = await Session.new(computeId, config);
this.initSession();
this.artifactLoader.session = this.session;
const session = await Session.new(computeId, config);
this.initSession(session);
this.artifactLoader.session = session;
return session;
}

async getAuthenticationConfig (dataInfo) {
Expand All @@ -85,11 +86,11 @@ define([
}
}

async initSession () {
await this.session.whenConnected();
async initSession (session) {
await session.whenConnected();
const initCode = await this.getInitializationCode();
await this.session.addFile('utils/init.py', initCode);
await this.session.addFile('utils/explorer_helpers.py', HELPERS_PY);
await session.addFile('utils/init.py', initCode);
await session.addFile('utils/explorer_helpers.py', HELPERS_PY);
}

async execPy(code) {
Expand Down

0 comments on commit c4ea35d

Please sign in to comment.