Skip to content

Commit

Permalink
Merge pull request #224 from Kitware/pyfr-viz
Browse files Browse the repository at this point in the history
Pyfr steps
  • Loading branch information
TristanWright committed Mar 11, 2016
2 parents 6f21fbc + bfe9e59 commit db5e98a
Show file tree
Hide file tree
Showing 16 changed files with 619 additions and 4,915 deletions.
4,766 changes: 3 additions & 4,763 deletions dist/simput-pyfr.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"history": "1.17.0",
"react-router": "2.0.0",

"paraviewweb": "1.2.14",
"simput": "1.1.5",
"paraviewweb": "1.2.15",
"simput": "1.1.8",
"pvw-visualizer": "1.0.8",

"kw-web-suite": "1.0.7"
Expand Down
2 changes: 1 addition & 1 deletion server/hpccloud/server/models/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def update(self, user, simulation, name, metadata=None, description=None,
dirty = True
simulation['active'] = active

if disabled:
if disabled is not None:
dirty = True
simulation['disabled'] = disabled

Expand Down
5 changes: 5 additions & 0 deletions src/network/remoteClient/Simulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ export function getProjectSimulations(pId) {
return girder.listSimulations(pId);
}

export function updateDisabledSimulationSteps(simulation) {
invalidateSimulation(simulation);
return girder.editSimulation(simulation);
}

export function activateSimulationStep(simulation, active, disabled) {
// Update local data
simulation.active = active;
Expand Down
2 changes: 2 additions & 0 deletions src/network/remoteClient/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import {
getSimulationStep,
saveSimulation,
updateSimulationStep,
updateDisabledSimulationSteps,
} from './Simulation';

import {
Expand Down Expand Up @@ -186,6 +187,7 @@ export default {
activateSimulationStep,
getSimulationStep,
updateSimulationStep,
updateDisabledSimulationSteps,

/* Notifications */
invalidateSimulation,
Expand Down
27 changes: 11 additions & 16 deletions src/workflows/pyfr-exec/components/steps/Simulation/View/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,17 @@ export default React.createClass({
this.setState({ taskflowId });

this.subscription = TaskflowManager.monitorTaskflow(taskflowId, (pkt) => {
var allTerminated = true;
const actions = [];

pkt.jobs.forEach(job => {
if (job.name === 'pyfr' && (job.status === 'running' || job.status === 'complete')) {
actions.push(ACTIONS.visualize);
}
if (job.status !== 'terminated') {
allTerminated = false;
}
});

if (allTerminated && pkt.jobs.length) {
actions.push(ACTIONS.rerun);
} else {
// some running -> terminate
if (pkt.jobs.some(job => job.status === 'running') && pkt.jobs.some(job => job.name === 'pyfr')) {
actions.push(ACTIONS.terminate);
// every complete -> visualize
} else if (pkt.jobs.every(job => job.status === 'complete')) {
actions.push(ACTIONS.visualize);
// every terminated -> rerun
} else if (pkt.jobs.every(job => job.status === 'terminated')) {
actions.push(ACTIONS.rerun);
}

// Refresh ui
Expand All @@ -85,11 +80,11 @@ export default React.createClass({
},

visualizeTaskflow() {
client.activateSimulationStep(this.props.simulation, 'Visualization', 'Simulation')
client.activateSimulationStep(this.props.simulation, 'Visualization', null)
.then((resp) => {
this.context.router.replace({
pathname: this.props.location.pathname,
query: merge(this.props.location.query, { view: 'visualizer' }),
pathname: `View/Simulation/${this.props.simulation._id}/Visualization`,
query: merge(this.props.location.query, { view: 'default' }),
state: this.props.location.state,
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,20 @@ export default React.createClass({
this.setState({ taskflowId });

this.subscription = TaskflowManager.monitorTaskflow(taskflowId, (pkt) => {
var allTerminated = true;
const actions = [];

pkt.jobs.forEach(job => {
if (job.name === 'paraview' && job.status === 'running') {
actions.push(ACTIONS.visualize);
}
if (job.status !== 'terminated') {
allTerminated = false;
}
});
// name is paraview and status is running -> visualize
if (pkt.jobs.some(job => job.name === 'paraview' && job.status === 'running')) {
actions.push(ACTIONS.visualize);
}

if (allTerminated && pkt.jobs.length) {
actions.push(ACTIONS.rerun);
} else {
// some running -> terminate
if (pkt.jobs.some(job => job.status === 'running')) {
actions.push(ACTIONS.terminate);
// every status complete || terminated -> rerun
} else if (pkt.jobs.every(job => job.status === 'complete') ||
pkt.jobs.every(job => job.status === 'terminated')) {
actions.push(ACTIONS.rerun);
}

// Refresh ui
Expand All @@ -73,7 +71,7 @@ export default React.createClass({
},

visualizeTaskflow() {
client.activateSimulationStep(this.props.simulation, 'Visualization', 'Simulation')
client.activateSimulationStep(this.props.simulation, 'Visualization', null)
.then((resp) => {
this.context.router.replace({
pathname: this.props.location.pathname,
Expand Down
2 changes: 1 addition & 1 deletion src/workflows/pyfr/components/root/ViewSimulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default React.createClass({
menuList.push({
name,
label: PyFrModule.labels[name].default,
disabled: this.props.simulation.steps[name].metadata.disabled,
disabled: this.props.simulation.disabled && (this.props.simulation.disabled.indexOf(name) !== -1),
});
});

Expand Down
6 changes: 6 additions & 0 deletions src/workflows/pyfr/components/steps/Input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export default React.createClass({
try {
if (this.state.iniFile) {
const convertedData = this.props.convert(jsonData);
console.log(convertedData);
const content = convertedData.results['pyfr.ini'];
console.log('try to save content', content.length);
const blob = new Blob([content], { type: 'text/plain' });
Expand All @@ -140,6 +141,11 @@ export default React.createClass({
err => {
console.log('Error update ini content', err);
});
const simulationStepIndex = this.props.simulation.disabled.indexOf('Simulation');
if (simulationStepIndex !== -1) {
this.props.simulation.disabled.splice(simulationStepIndex, 1);
client.updateDisabledSimulationSteps(this.props.simulation);
}
} else {
console.log('no ini file');
}
Expand Down
159 changes: 159 additions & 0 deletions src/workflows/pyfr/components/steps/Simulation/Start/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import React from 'react';

import defaultServerParameters from '../../../../../../panels/run/defaults';
import RunEC2 from '../../../../../../panels/run/RunEC2';
import RunCluster from '../../../../../../panels/run/RunCluster';
import RunOpenStack from '../../../../../../panels/run/RunOpenStack';
import ButtonBar from '../../../../../../panels/ButtonBar';

import client from '../../../../../../network';
import deepClone from 'mout/src/lang/deepClone';
import merge from 'mout/src/object/merge';
import formStyle from 'HPCCloudStyle/ItemEditor.mcss';

export default React.createClass({

displayName: 'pyfr-exec/start-sim',

propTypes: {
location: React.PropTypes.object,
project: React.PropTypes.object,
simulation: React.PropTypes.object,
step: React.PropTypes.string,
taskFlowName: React.PropTypes.string,
view: React.PropTypes.string,
},

contextTypes: {
router: React.PropTypes.object,
},

getInitialState() {
return {
serverType: 'Traditional',
EC2: defaultServerParameters.EC2,
Traditional: defaultServerParameters.Traditional,
OpenStack: defaultServerParameters.OpenStack,
error: '',
};
},
dataChange(key, value, which) {
var profile = this.state[which];
profile[key] = value;
this.setState({ [which]: profile });
},
runSimulation(event) {
var taskflowId,
sessionId = btoa(new Float64Array(3).map(Math.random)).substring(0, 96);

client.createTaskflow(this.props.taskFlowName)
.then((resp) => {
var file = {
_id: this.props.simulation.metadata.inputFolder.files.ini,
name: 'pyfr.ini', // the ini file must be named this.
};
taskflowId = resp.data._id;
return client.editFile(file);
})
.then((resp) =>
client.startTaskflow(taskflowId, {
input: {
folder: {
id: this.props.simulation.metadata.inputFolder._id,
},
meshFile: {
id: this.props.simulation.metadata.inputFolder.files.mesh,
},
},
output: {
folder: {
id: this.props.simulation.metadata.outputFolder._id,
},
},
cluster: {
_id: this.state[this.state.serverType].profile,
},
})
)
.then((resp) =>
client.updateSimulationStep(this.props.simulation._id, this.props.step, {
view: 'run',
metadata: {
taskflowId, sessionId,
},
})
)
.then((resp) => {
var newSim = deepClone(this.props.simulation);
newSim.steps[this.props.step].view = 'run';
newSim.steps[this.props.step].metadata = {
taskflowId, sessionId,
};
client.invalidateSimulation(newSim);

this.context.router.replace({
pathname: this.props.location.pathname,
query: merge(this.props.location.query, {
view: 'run',
}),
state: this.props.location.state,
});
})
.catch((error) => {
this.setState({ error: error.data.message });
});
},

formAction(action) {
this[action]();
},

updateServerType(e) {
this.setState({ serverType: e.target.value });
},

render() {
var actions = [{ name: 'runSimulation', label: 'Run Simulation', icon: '' }],
serverForm;

switch (this.state.serverType) {
case 'EC2':
serverForm = <RunEC2 contents={this.state.EC2} onChange={this.dataChange} />;
break;
case 'Traditional':
serverForm = <RunCluster contents={this.state.Traditional} onChange={this.dataChange} />;
break;
case 'OpenStack':
serverForm = <RunOpenStack />;
break;
default:
serverForm = <span>no valid serverType: {this.state.serverType}</span>;
}

return (
<div>
<section className={formStyle.group}>
<label className={formStyle.label}>Region</label>
<select
className={formStyle.input}
value={this.state.serverType}
onChange={ this.updateServerType } >
<option value="Traditional">Traditional</option>
<option value="EC2">EC2</option>
<option value="OpenStack">OpenStack</option>
</select>
</section>
<section>
{serverForm}
</section>
<section className={formStyle.buttonGroup}>
<ButtonBar
visible={this.state[this.state.serverType].profile !== ''}
onAction={this.formAction}
actions={actions}
error={this.state.error}
/>
</section>
</div>);
},
});
Loading

0 comments on commit db5e98a

Please sign in to comment.