Skip to content

Commit

Permalink
Version 2.0.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny authored Jul 9, 2024
2 parents 884308e + 5489ce8 commit 79c3321
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 73 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abi-software/simulationvuer",
"version": "2.0.0",
"version": "2.0.1",
"private": false,
"scripts": {
"serve": "vite serve --host",
Expand Down
24 changes: 12 additions & 12 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<strong>Dataset <a :href="datasetUrl(dataset.id)" target="_blank">{{ dataset.id }}</a>:</strong> {{ dataset.description }}
</span>
<span v-if="typeof dataset.id !== 'number'">
<strong>ISAN:</strong> {{ dataset.description }} {{ typeof dataset.id }}
<strong>ISAN:</strong> {{ dataset.description }}
</span>
<hr />
<SimulationVuer :apiLocation="apiLocation" :id="dataset.id" :preferredSolver="dataset.preferredSolver" style="height: 640px;" />
<SimulationVuer :apiLocation="apiLocation" :id="dataset.id" style="height: 640px;" />
</div>
</div>
<hr />
Expand All @@ -38,16 +38,16 @@ export default {
return {
apiLocation: import.meta.env.VITE_API_LOCATION,
datasets: [
{ id: 0, label: "0", description: "Non-simulation dataset", preferredSolver: SimulationVuer.OSPARC_SOLVER },
{ id: 135, label: "135", description: "Computational analysis of the human sinus node action potential - Model development and effects of mutations", preferredSolver: SimulationVuer.OSPARC_SOLVER },
{ id: 157, label: "157", description: "Fabbri-based composite SAN model", preferredSolver: SimulationVuer.OSPARC_SOLVER },
{ id: 308, label: "308", description: "Kember Cardiac Nerve Model", preferredSolver: SimulationVuer.OSPARC_SOLVER },
{ id: 318, label: "318", description: "Multi-scale rabbit cardiac electrophysiology models", preferredSolver: SimulationVuer.OSPARC_SOLVER },
{ id: 320, label: "320", description: "Multi-scale human cardiac electrophysiology models", preferredSolver: SimulationVuer.OSPARC_SOLVER },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/135.omex", label: "ISAN-135", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/157.omex", label: "ISAN-157", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/lorenz.omex", label: "ISAN-Lorenz", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/tt04.omex", label: "ISAN-TT04", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER },
{ id: 0, label: "0", description: "Non-simulation dataset" },
{ id: 135, label: "135", description: "Computational analysis of the human sinus node action potential - Model development and effects of mutations" },
{ id: 157, label: "157", description: "Fabbri-based composite SAN model" },
{ id: 308, label: "308", description: "Kember Cardiac Nerve Model" },
{ id: 318, label: "318", description: "Multi-scale rabbit cardiac electrophysiology models" },
{ id: 320, label: "320", description: "Multi-scale human cardiac electrophysiology models" },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/135.omex", label: "ISAN-135", description: "COMBINE archive from PMR" },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/157.omex", label: "ISAN-157", description: "COMBINE archive from PMR" },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/lorenz.omex", label: "ISAN-Lorenz", description: "COMBINE archive from PMR" },
{ id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/tt04.omex", label: "ISAN-TT04", description: "COMBINE archive from PMR" },
],
id: 0,
ready: [],
Expand Down
103 changes: 45 additions & 58 deletions src/components/SimulationVuer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<p v-if="!hasValidSimulationUiInfo && !showUserMessage" class="default error"><span class="error">Error:</span> an unknown or invalid model was provided.</p>
<div class="main" v-if="hasValidSimulationUiInfo">
<div class="main-left">
<p class="default name">{{name}}</p>
<el-divider></el-divider>
<p class="default name" v-if="libopencor === undefined">{{name}}</p>
<el-divider v-if="libopencor === undefined"></el-divider>
<p class="default input-parameters">Input parameters</p>
<div class="input scrollbar">
<SimulationVuerInput v-for="(input, index) in simulationUiInfo.input"
Expand All @@ -19,16 +19,16 @@
/>
</div>
<div class="primary-button">
<el-button type="primary" size="small" @click="startSimulation()" v-if="!this.libopencor">Run Simulation</el-button>
<el-button type="primary" size="small" @click="startSimulation()" v-if="libopencor === undefined">Run Simulation</el-button>
</div>
<div class="secondary-button" v-if="uuid">
<el-button size="small" @click="runOnOsparc()">Run on oSPARC</el-button>
</div>
<div class="secondary-button">
<el-button size="small" @click="viewDataset()" v-if="typeof this.id === 'number'">View Dataset</el-button>
<el-button size="small" @click="viewDataset()" v-if="libopencor === undefined">View Dataset</el-button>
</div>
<div class="secondary-button">
<el-button size="small" @click="viewWorkspace()" v-if="typeof this.id !== 'number'">View Workspace</el-button>
<el-button size="small" @click="viewWorkspace()" v-if="libopencor !== undefined">View Workspace</el-button>
</div>
<p class="default note" v-if="uuid">Additional parameters are available on oSPARC</p>
</div>
Expand Down Expand Up @@ -89,20 +89,12 @@ export default {
type: String,
},
/**
* The ID of the simulation-based dataset.
* The ID of the simulation-based dataset, if it is a number, or the path
* to a PMR file, if it is a string.
*/
id: {
required: true,
},
/**
* The preferred solver to use for OpenCOR-based simulations. This property
* is optional and defaults to "oSPARC". The only value that is currently
* supported is "libOpenCOR". Any other value will default to "oSPARC".
*/
preferredSolver: {
type: String,
default: OSPARC_SOLVER,
},
},
data: function() {
// Retrieve some information about the dataset.
Expand Down Expand Up @@ -140,7 +132,6 @@ export default {
perfectScollbarOptions: {
suppressScrollX: true,
},
pmrBasedCombineArchive: false,
showUserMessage: false,
simulationResults: {},
simulationResultsId: {},
Expand Down Expand Up @@ -216,27 +207,14 @@ export default {
},
/**
* @vuese
* Run the simulation using libOpenCOR.
* Run a PMR-based COMBINE archive using libOpenCOR.
*/
runSimulation() {
if (this.instance === undefined) {
const fileNameOrUrl = this.pmrBasedCombineArchive ? PMR_URL + this.id : this.simulationUiInfo.simulation.opencor.resource;
const document = new this.libopencor.SedDocument(toRaw(this.fileManager).file(fileNameOrUrl));
// Customise the ending point and point interval of the simulation, if
// needed.
if ( !this.pmrBasedCombineArchive
&& (this.simulationUiInfo.simulation.opencor.endingPoint !== undefined)
&& (this.simulationUiInfo.simulation.opencor.pointInterval !== undefined)) {
const simulation = document.simulations().get(0);
simulation.setOutputEndTime(this.simulationUiInfo.simulation.opencor.endingPoint);
simulation.setNumberOfSteps(this.simulationUiInfo.simulation.opencor.endingPoint / this.simulationUiInfo.simulation.opencor.pointInterval);
}
// Retrieve an instance of the model.
const document = new this.libopencor.SedDocument(toRaw(this.fileManager).file(PMR_URL + this.id));
this.instance = document.instantiate();
document.delete();
Expand Down Expand Up @@ -301,7 +279,7 @@ export default {
// Make sure that the simulation UI information is valid.
this.hasValidSimulationUiInfo = validJson(this.simulationUiInfo, !this.pmrBasedCombineArchive);
this.hasValidSimulationUiInfo = validJson(this.simulationUiInfo, this.libopencor === undefined);
if (!this.hasValidSimulationUiInfo) {
return;
Expand All @@ -310,7 +288,7 @@ export default {
// Retrieve and keep track of the solver to be used for the simulation, if
// needed.
if (!this.pmrBasedCombineArchive) {
if (this.libopencor === undefined) {
this.simulationUiInfo.simulation.solvers.forEach((solver) => {
if ((solver.if === undefined) || evaluateValue(this, solver.if)) {
this.solver = solver;
Expand All @@ -330,14 +308,14 @@ export default {
// load libOpenCOR if we are dealing with an OpenCOR-based simulation and
// we want to use libOpenCOR.
if (this.pmrBasedCombineArchive) {
if (this.libopencor !== undefined) {
this.userMessage = "Running the model...";
this.showUserMessage = true;
this.$nextTick(() => {
this.runSimulation();
});
} else if (this.opencorBasedSimulation && (this.preferredSolver === LIBOPENCOR_SOLVER)) {
} else if (this.opencorBasedSimulation && (this.libopencor !== undefined)) {
this.userMessage = "Retrieving and running the model...";
this.showUserMessage = true;
Expand Down Expand Up @@ -583,6 +561,16 @@ export default {
];
});
},
/**
* @vuese
* Show an HTTP issue using the given `xmlhttp`.
* @arg `xmlhttp`
*/
showHttpIssue(xmlhttp) {
this.isSimulationValid = false;
this.showUserMessage = false;
this.errorMessage = xmlhttp.statusText.toLowerCase() + " (<a href='https://httpstatuses.com/" + xmlhttp.status + "/' target='_blank'>" + xmlhttp.status + "</a>)";
},
/**
* @vuese
* Check the progress of the simulation using the given `data`, a JSON object that contains the simulation job ID,
Expand Down Expand Up @@ -623,12 +611,10 @@ export default {
}
} else {
this.showUserMessage = false;
this.errorMessage = response.description;
this.errorMessage = response.description + "QWEQWEQWE";
}
} else {
this.isSimulationValid = false;
this.showUserMessage = false;
this.errorMessage = xmlhttp.statusText.toLowerCase() + " (<a href='https://httpstatuses.com/" + xmlhttp.status + "/' target='_blank'>" + xmlhttp.status + "</a>)";
this.showHttpIssue(xmlhttp);
}
}
};
Expand Down Expand Up @@ -664,12 +650,10 @@ export default {
this.checkSimulation(response.data);
} else {
this.showUserMessage = false;
this.errorMessage = response.description;
this.errorMessage = response.description + "ASDASDASD";
}
} else {
this.isSimulationValid = false;
this.showUserMessage = false;
this.errorMessage = xmlhttp.statusText.toLowerCase() + " (<a href='https://httpstatuses.com/" + xmlhttp.status + "/' target='_blank'>" + xmlhttp.status + "</a>)";
this.showHttpIssue(xmlhttp);
}
}
};
Expand Down Expand Up @@ -704,7 +688,7 @@ export default {
xmlhttp.send();
});
} else if (this.id !== 0) {
this.userMessage = "Retrieving OMEX file...";
this.userMessage = "Retrieving COMBINE archive from PMR...";
this.showUserMessage = true;
// Retrieve the OMEX file, extract the simulation UI JSON file from it and
Expand All @@ -716,24 +700,27 @@ export default {
xmlhttp.open("POST", this.apiLocation + "/pmr_file");
xmlhttp.setRequestHeader("Content-type", "application/json");
xmlhttp.onreadystatechange = () => {
if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
libOpenCOR().then((libopencor) => {
this.pmrBasedCombineArchive = true;
this.libopencor = libopencor;
this.fileManager = this.libopencor.FileManager.instance();
if (xmlhttp.readyState === 4) {
if (xmlhttp.status === 200) {
libOpenCOR().then((libopencor) => {
this.libopencor = libopencor;
this.fileManager = this.libopencor.FileManager.instance();
const fileContents = Uint8Array.from(atob(xmlhttp.response), (c) => c.charCodeAt(0));
const file = this.manageFile(PMR_URL + this.id, fileContents);
const fileContents = Uint8Array.from(atob(xmlhttp.response), (c) => c.charCodeAt(0));
const file = this.manageFile(PMR_URL + this.id, fileContents);
const decoder = new TextDecoder();
const simulationUiInfo = JSON.parse(decoder.decode(file.childFile("simulation.json").contents()));
const decoder = new TextDecoder();
const simulationUiInfo = JSON.parse(decoder.decode(file.childFile("simulation.json").contents()));
this.showUserMessage = false;
this.showUserMessage = false;
this.$nextTick(() => {
this.buildSimulationUi(simulationUiInfo);
this.$nextTick(() => {
this.buildSimulationUi(simulationUiInfo);
});
});
});
} else {
this.showUserMessage = false;
}
}
};
xmlhttp.send(JSON.stringify({path: this.id}));
Expand Down

0 comments on commit 79c3321

Please sign in to comment.