Skip to content

Commit

Permalink
Simulation support: don't require all our solvers to be installed any…
Browse files Browse the repository at this point in the history
…more (closes #2234).
  • Loading branch information
agarny committed Nov 27, 2019
2 parents 734637c + 266db8d commit a5087ee
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 77 deletions.
1 change: 1 addition & 0 deletions doc/downloads/index.js
Expand Up @@ -40,6 +40,7 @@ var jsonData = { "versions": [
{ "change": "<strong>General:</strong> added (initial) support for <a href=\"https://www.python.org/\">Python</a> (see issue <a href=\"https://github.com/opencor/opencor/issues/1255\">#1255</a>). Replaced our use of <a href=\"https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/PackageMakerUserGuide/Introduction/Introduction.html\">PackageMaker</a> with that of productbuild on <a href=\"https://en.wikipedia.org/wiki/MacOS\">macOS</a> (see issue <a href=\"https://github.com/opencor/opencor/issues/2210\">#2210</a>)." },
{ "change": "<strong>Python support:</strong> now update the environment variable <code>PATH</code> using <code>\\</code> rather than <code>/</code> on Windows (see issue <a href=\"https://github.com/opencor/opencor/issues/2219\">#2219</a>). Merged our duplicated code (see issue <a href=\"https://github.com/opencor/opencor/issues/2225\">#2225</a>)." },
{ "change": "<strong>SED-ML support:</strong> added support left and right triangle symbols (see issue <a href=\"https://github.com/opencor/opencor/issues/2173\">#2173</a>)." },
{ "change": "<strong>Simulation support:</strong> don't require all our solvers to be installed anymore (see issue <a href=\"https://github.com/opencor/opencor/issues/2234\">#2234</a>)." },
{ "change": "<strong>Simulation Experiment view:</strong> properly handle the Graph Panel properties (see issue <a href=\"https://github.com/opencor/opencor/issues/2171\">#2171</a>). Make sure that curves are plotted with all of their original settings when reloading a SED-ML file (see issue <a href=\"https://github.com/opencor/opencor/issues/2176\">#2176</a>). Make sure that all of a solver's properties get saved to a SED-ML file (see issue <a href=\"https://github.com/opencor/opencor/issues/2185\">#2185</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded the <a href=\"https://www.openssl.org/\">OpenSSL</a> library to version 1.1.1d (see issue <a href=\"https://github.com/opencor/opencor/issues/2157\">#2157</a>). Upgraded <a href=\"http://www.llvm.org/\">LLVM</a>+<a href=\"http://clang.llvm.org/\">Clang</a> to version 9.0.0 (see issue <a href=\"https://github.com/opencor/opencor/issues/2161\">#2161</a>). Upgraded the <a href=\"http://computation.llnl.gov/projects/sundials\">SUNDIALS</a> library to version 5.0.0 (see issue <a href=\"https://github.com/opencor/opencor/issues/2198\">#2198</a>). Upgraded <a href=\"https://riverbankcomputing.com/software/qscintilla/intro\">QScintilla</a> to version 2.11.3 (see issue <a href=\"https://github.com/opencor/opencor/issues/2208\">#2208</a>). Upgraded <a href=\"https://www.mesa3d.org/\">Mesa</a> to version 19.2.6 (see issue <a href=\"https://github.com/opencor/opencor/issues/2230\">#2230</a>)." }
]
Expand Down
2 changes: 1 addition & 1 deletion src/misc/closesimulation.cpp.inl
Expand Up @@ -17,7 +17,7 @@ static PyObject * closeSimulation(PyObject *pSelf, PyObject *pArgs)
auto simulation = static_cast<SimulationSupport::Simulation *>(wrappedSimulation->_objPointerCopy);

if (!Core::centralWidget()->closeFile(simulation->fileName())) {
PyErr_SetString(PyExc_IOError, qPrintable(QObject::tr("unable to close the simulation")));
PyErr_SetString(PyExc_IOError, qPrintable(QObject::tr("unable to close the simulation.")));

return nullptr;
}
Expand Down
28 changes: 14 additions & 14 deletions src/misc/furtherinitialize.cpp.inl
Expand Up @@ -117,7 +117,7 @@ QString Simulation::furtherInitialize() const
}

if (!propertySet) {
simulationError(QObject::tr("the requested solver property (%1) could not be set").arg(id),
simulationError(QObject::tr("the requested solver property (%1) could not be set.").arg(id),
Error::InvalidSimulationEnvironment);

return false;
Expand All @@ -133,7 +133,7 @@ QString Simulation::furtherInitialize() const
}
#ifdef GUI_SUPPORT

simulationError(QObject::tr("the requested solver (%1) could not be found").arg(nlaSolverName),
simulationError(QObject::tr("the requested solver (%1) could not be found.").arg(nlaSolverName),
Error::InvalidSimulationEnvironment);

return false;
Expand All @@ -143,7 +143,7 @@ QString Simulation::furtherInitialize() const
#ifndef GUI_SUPPORT

if (mustHaveNlaSolver && !hasNlaSolver) {
return QObject::tr("the requested solver (%1) could not be found").arg(nlaSolverName);
return QObject::tr("the requested solver (%1) could not be found.").arg(nlaSolverName);
}
#endif
}
Expand Down Expand Up @@ -360,28 +360,28 @@ QString Simulation::furtherInitialize() const

if (xParameter == nullptr) {
if (yParameter == nullptr) {
simulationError(QObject::tr("the requested curve (%1) could not be set (the variable %2 in component %3 and the variable %4 in component %5 could not be found)").arg(QString::fromStdString(sedmlCurve->getId()),
xCellmlVariable,
xCellmlComponent,
yCellmlVariable,
yCellmlComponent),
simulationError(QObject::tr("the requested curve (%1) could not be set (the variable %2 in component %3 and the variable %4 in component %5 could not be found).").arg(QString::fromStdString(sedmlCurve->getId()),
xCellmlVariable,
xCellmlComponent,
yCellmlVariable,
yCellmlComponent),
Error::InvalidSimulationEnvironment);

return false;
}

simulationError(QObject::tr("the requested curve (%1) could not be set (the variable %2 in component %3 could not be found)").arg(QString::fromStdString(sedmlCurve->getId()),
xCellmlVariable,
xCellmlComponent),
simulationError(QObject::tr("the requested curve (%1) could not be set (the variable %2 in component %3 could not be found).").arg(QString::fromStdString(sedmlCurve->getId()),
xCellmlVariable,
xCellmlComponent),
Error::InvalidSimulationEnvironment);

return false;
}

if (yParameter == nullptr) {
simulationError(QObject::tr("the requested curve (%1) could not be set (the variable %2 in component %3 could not be found)").arg(QString::fromStdString(sedmlCurve->getId()),
yCellmlVariable,
yCellmlComponent),
simulationError(QObject::tr("the requested curve (%1) could not be set (the variable %2 in component %3 could not be found).").arg(QString::fromStdString(sedmlCurve->getId()),
yCellmlVariable,
yCellmlComponent),
Error::InvalidSimulationEnvironment);

return false;
Expand Down
6 changes: 3 additions & 3 deletions src/misc/initializesolver.cpp.inl
Expand Up @@ -33,12 +33,12 @@ QString Simulation::initializeSolver(const libsedml::SedListOfAlgorithmParameter

if (solverInterface == nullptr) {
#ifdef GUI_SUPPORT
simulationError(QObject::tr("the requested solver (%1) could not be found").arg(pKisaoId),
simulationError(QObject::tr("the requested solver (%1) could not be found.").arg(pKisaoId),
Error::InvalidSimulationEnvironment);

return false;
#else
return QObject::tr("the requested solver (%1) could not be found").arg(pKisaoId);
return QObject::tr("the requested solver (%1) could not be found.").arg(pKisaoId);
#endif
}

Expand Down Expand Up @@ -103,7 +103,7 @@ QString Simulation::initializeSolver(const libsedml::SedListOfAlgorithmParameter
}

if (!propertySet) {
simulationError(QObject::tr("the requested solver property (%1) could not be set").arg(parameterKisaoId),
simulationError(QObject::tr("the requested solver property (%1) could not be set.").arg(parameterKisaoId),
Error::InvalidSimulationEnvironment);

return false;
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/dataStore/DataStore/i18n/DataStore_fr.ts
Expand Up @@ -16,4 +16,11 @@
<translation>Données :</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<source>invalid value.</source>
<translation>valeur invalide.</translation>
</message>
</context>
</TS>
Expand Up @@ -129,7 +129,7 @@ static int DataStoreValuesDict_ass_subscript(PyObject *pValuesDict,
return 0;
}

PyErr_SetString(PyExc_TypeError, "Invalid value");
PyErr_SetString(PyExc_TypeError, qPrintable(QObject::tr("invalid value.")));

return -1;
}
Expand Down
Expand Up @@ -346,8 +346,8 @@ void FileBrowserWindowWidget::goToOtherItem(QStringList &pItems,
// Go to the previous/next item and move the last item from our list of
// items to our list of other items

// First, we must stop keeping track of the change of item otherwise it's
// going to mess things up
// First, we must stop tracking the change of item otherwise it's going to
// mess things up

disconnect(selectionModel(), &QItemSelectionModel::currentChanged,
this, &FileBrowserWindowWidget::itemChanged);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/pluginmanager.cpp
Expand Up @@ -120,11 +120,11 @@ PluginManager::PluginManager(bool pGuiMode) :

if (pluginInfo != nullptr) {
// Keep track of the plugin itself, should it be selectable and
// requested by the user (if we are in GUI mode) or have CLI support
// (if we are in CLI mode)
// requested by the user (if we are in GUI mode), or have CLI
// support or is a solver (if we are in CLI mode)

if ( ( pGuiMode && pluginInfo->isSelectable() && Plugin::load(pluginName))
|| (!pGuiMode && pluginInfo->hasCliSupport())) {
|| (!pGuiMode && (pluginInfo->hasCliSupport() || (pluginInfo->category() == PluginInfo::Category::Solver)))) {
// Keep track of the plugin's dependencies

neededPlugins << pluginsInfo.value(pluginName)->fullDependencies();
Expand Down
Expand Up @@ -556,10 +556,6 @@
<source>none</source>
<translation>aucun</translation>
</message>
<message>
<source>%1:</source>
<translation>%1 :</translation>
</message>
<message>
<source>the model needs both an ODE and an NLA solver, but none are available</source>
<translation>le modèle a besoin à la fois d&apos;un solveur EDO et d&apos;un solveur ALN, mais aucun n&apos;est disponible</translation>
Expand Down Expand Up @@ -640,32 +636,44 @@
<source>Error:</source>
<translation>Erreur :</translation>
</message>
<message>
<source>&lt;span %1&gt;&lt;strong&gt;[%2:%3] %4:&lt;/strong&gt; %5.&lt;/span&gt;</source>
<translation>&lt;span %1&gt;&lt;strong&gt;[%2:%3] %4 :&lt;/strong&gt; %5.&lt;/span&gt;</translation>
</message>
<message>
<source>&lt;span %1&gt;&lt;strong&gt;%2:&lt;/strong&gt; %3.&lt;/span&gt;</source>
<translation>&lt;span %1&gt;&lt;strong&gt;%2 :&lt;/strong&gt; %3.&lt;/span&gt;</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<source>unable to get the simulation&apos;s runtime</source>
<translation>incapable d&apos;obtenir le modèle d&apos;exécution de la simulation</translation>
<source>unable to close the simulation.</source>
<translation>incapable de fermer la simulation.</translation>
</message>
<message>
<source>the requested solver (%1) could not be found.</source>
<translation>le solveur demandé (%1) n&apos;a pas pu être trouvé.</translation>
</message>
<message>
<source>unable to close the simulation</source>
<translation>incapable de fermer la simulation</translation>
<source>the requested solver property (%1) could not be set.</source>
<translation>la propriété demandée (%1) du solveur n&apos;a pas pu être spécifiée.</translation>
</message>
<message>
<source>the requested solver (%1) could not be found</source>
<translation>le solveur demandé (%1) n&apos;a pas pu être trouvé</translation>
<source>the requested curve (%1) could not be set (the variable %2 in component %3 and the variable %4 in component %5 could not be found).</source>
<translation>la courbe demandée (%1) n&apos;a pas pu être spécifiée (la variable %2 dans le composant %3 et la variable %4 dans le composant %5 n&apos;ont pas pu être trouvées).</translation>
</message>
<message>
<source>the requested solver property (%1) could not be set</source>
<translation>la propriété demandée (%1) du solveur n&apos;a pas pu être spécifiée</translation>
<source>the requested curve (%1) could not be set (the variable %2 in component %3 could not be found).</source>
<translation>la courbe demandée (%1) n&apos;a pas pu être spécifiée (la variable %2 dans le composant %3 n&apos;a pas pu être trouvée).</translation>
</message>
<message>
<source>the requested curve (%1) could not be set (the variable %2 in component %3 and the variable %4 in component %5 could not be found)</source>
<translation>la courbe demandée (%1) n&apos;a pas pu être spécifiée (la variable %2 dans le composant %3 et la variable %4 dans le composant %5 n&apos;ont pas pu être trouvées)</translation>
<source>[%1:%2] %3: %4.</source>
<translation type="unfinished">[%1:%2] %3 : %4.</translation>
</message>
<message>
<source>the requested curve (%1) could not be set (the variable %2 in component %3 could not be found)</source>
<translation>la courbe demandée (%1) n&apos;a pas pu être spécifiée (la variable %2 dans le composant %3 n&apos;a pas pu être trouvée)</translation>
<source>%1: %2.</source>
<translation type="unfinished">%1 : %2.</translation>
</message>
</context>
</TS>
Expand Up @@ -50,10 +50,26 @@ static PyObject * simulation(const QString &pFileName,
SimulationSupport::Simulation *simulation = pSimulationExperimentViewWidget->simulation(pFileName);

if (simulation != nullptr) {
if (simulation->runtime() == nullptr) {
// The simulation is missing a runtime, so raise a Python exception

PyErr_SetString(PyExc_ValueError, qPrintable(QObject::tr("unable to get the simulation's runtime")));
// Check if something is wrong with our simulation and, if so, raise a
// Python exception
// Note: there may be several issues, but only the first one needs to be
// raised since Python obviously gives control back to the user as
// soon as an exception is raised...

SimulationSupport::SimulationIssues simulationIssues = simulation->issues();

if (!simulationIssues.isEmpty()) {
auto simulationIssue = simulationIssues.first();

if ((simulationIssue.line() != 0) && (simulationIssue.column() != 0)) {
PyErr_SetString(PyExc_ValueError, qPrintable(QObject::tr("[%1:%2] %3: %4.").arg(simulationIssue.line())
.arg(simulationIssue.column())
.arg(simulationIssue.typeAsString(),
Core::formatMessage(simulationIssue.message().toHtmlEscaped()))));
} else {
PyErr_SetString(PyExc_ValueError, qPrintable(QObject::tr("%1: %2.").arg(simulationIssue.typeAsString(),
Core::formatMessage(simulationIssue.message().toHtmlEscaped()))));
}

return nullptr;
}
Expand Down

0 comments on commit a5087ee

Please sign in to comment.