Skip to content

Commit

Permalink
Merge pull request #113 from JustinBonus/master
Browse files Browse the repository at this point in the history
Fix maxRunTime / mac OS usage
  • Loading branch information
fmckenna authored Apr 12, 2024
2 parents 08baeb9 + 2ec79c2 commit 1f85aad
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 25 deletions.
17 changes: 10 additions & 7 deletions EVENTS/MPM/MPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,11 @@ MPM::MPM(RandomVariablesContainer *theRandomVariableIW, QWidget *parent)



#ifdef _WIN32
//#if defined(Q_OS_WIN) || defined(Q_OS_WIN32) || defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
// #ifdef _WIN32
#if defined(_WIN32) || defined(__linux__)
// Only allow 3D visualization on Windows and Linux for now, Mac had issues with Qt3D
// Try to check the most reliable set of preprocessor definitions to detect the OS on common OS
// https://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor
// -----------------------------------------------------------------------------------
// Create a 3D window and container widget and set the 3D window as its layout
// Based on code by Alex44, 2018; https://stackoverflow.com/questions/23231012/how-to-render-in-qt3d-in-standard-gui-application)
Expand Down Expand Up @@ -1171,8 +1174,8 @@ MPM::MPM(RandomVariablesContainer *theRandomVariableIW, QWidget *parent)
horizontalPanelLayout->addWidget(scrollArea);

// horizontalPanelLayout->addWidget(visualizationGroup);
#ifdef _WIN32
//#if defined(Q_OS_WIN) || defined(Q_OS_WIN32) || defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
// #ifdef _WIN32
#if defined(_WIN32) || defined(__linux__)
horizontalPanelLayout->addWidget(container);
#endif
// QVBoxLayout *layout = new QVBoxLayout();
Expand All @@ -1186,8 +1189,8 @@ MPM::MPM(RandomVariablesContainer *theRandomVariableIW, QWidget *parent)
int index = stackedWidget->currentIndex();
mpmBodies->setDigitalTwin(index);
mpmBoundaries->setDigitalTwin(index);
#ifdef _WIN32
// #if defined(Q_OS_WIN) || defined(Q_OS_WIN32) || defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
// #ifdef _WIN32
#if defined(_WIN32) || defined(__linux__)
updateDigitalTwin(index);
#endif
});
Expand Down Expand Up @@ -1703,7 +1706,7 @@ bool MPM::outputAppDataToJSON(QJsonObject &jsonObject) {
// jsonObject["ApplicationData"] = dataObj;

jsonObject["programFile"] = "fbar"; // <- ClaymoreUW MPM executable filename on remote machine. Can be changed depending on compiled optimizations, versions, digital twin, etc.
jsonObject["maxRunTime"] = "02:00:00"; // <- Maximum run time for the simulation, timeout if exceeded
jsonObject["maxRunTime"] = "24:00:00"; // <- Maximum run time for the simulation, timeout if exceeded
return true;
}
bool MPM::inputAppDataFromJSON(QJsonObject &jsonObject) {
Expand Down
164 changes: 149 additions & 15 deletions EVENTS/MPM/ResultsMPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,29 +491,87 @@ ResultsMPM::onPlotPressureClicked(void)
{
int dialogHeight = 450;
int dialogWidth = 850;

QVBoxLayout *plotLayout = new QVBoxLayout();

QWebEngineView *plotView = new QWebEngineView();
plotView->page()->setBackgroundColor(Qt::transparent);
plotLayout->addWidget(plotView);

plotView->setMinimumWidth(dialogWidth);
plotView->setMinimumHeight(dialogHeight);

QString ext = ".webp";
QString plotPath = mainModel->caseDir() + QDir::separator()
+ "output" + QDir::separator()
+ profileNameP->currentText()
+ ext;
QString ext = ".png";
for (int i=0; i<2; ++i) {
if (i == 0) ext = ".webp";
if (i == 1) ext = ".html";
QString intermediateFolder = "";
for (int j=0; j<3; ++j)
{
if (j == 0) intermediateFolder = "";
if (j == 1) intermediateFolder = "sensors";
if (j == 2) intermediateFolder = "results";
if (j == 3) intermediateFolder = ""; // TODO: Just use the preferences for this.

QString plotDir = mainModel->caseDir() + QDir::separator()
+ "output" + QDir::separator()
+ intermediateFolder + QDir::separator();
// If directory doesn't exist then skip to the next one.
if (!QDir(plotDir).exists())
{
qDebug() << "ResultsMPM::onPlotPressureClicked - Checked for results.zip in " << plotDir << ", but folder does not exist. Skipping...";
continue;
}

if(QFileInfo::exists(plotPath))
{
plotView->load(QUrl::fromLocalFile(plotPath));
plotView->setWindowFlag(Qt::WindowStaysOnTopHint);
plotView->show();
plotView->activateWindow();
plotView->raise();
QString zipPath = mainModel->caseDir() + QDir::separator()
+ "output" + QDir::separator()
+ intermediateFolder + QDir::separator()
+ "results.zip";

if (j == 3)
{
// Remoteworkdir
zipPath = SimCenterPreferences::getInstance()->getRemoteAppDir() + QDir::separator()
+ "results.zip";
}
if (QFileInfo::exists(zipPath))
{
QString program = "tar";
QStringList arguments;
// Extract results.zip file from zipPath (either in the GUI set caseDir/output/{'','sensors','results}, variants in brackets, or in RemoteWorkDir when retrieving run from DesignSafe. Extract to plotDir
arguments << "-xzf" << zipPath << "-c" << plotDir;
QProcess *process = new QProcess();
process->start(program, arguments);
process->waitForStarted();
process->waitForFinished(-1);
if (process->exitStatus() == QProcess::CrashExit)
{
qDebug() << "ResultsMPM::onPlotPressureClicked - The unzip process has crashed.";
}
else if (process->exitStatus() == QProcess::NormalExit)
{
qDebug() << "ResultsMPM::onPlotPressureClicked - The unzip process has finished running.";
}
else
{
qDebug() << "ResultsMPM::onPlotPressureClicked - The unzip process has finished running with an unknown exit status.";
}
process->deleteLater();
}

QString plotPath = mainModel->caseDir() + QDir::separator()
+ "output" + QDir::separator()
+ intermediateFolder + QDir::separator()
+ profileNameP->currentText()
+ ext;
if (QFileInfo::exists(plotPath))
{
// Check if results.zip here, if so, extract it.

plotView->load(QUrl::fromLocalFile(plotPath));
plotView->setWindowFlag(Qt::WindowStaysOnTopHint);
plotView->show();
plotView->activateWindow();
plotView->raise();
}
}
}
}

Expand Down Expand Up @@ -620,6 +678,82 @@ ResultsMPM::plotSensors(MPM* host)
qDebug() << "ResultsMPM::plotSensors - scriptPath: " << scriptPath;
qDebug() << "ResultsMPM::plotSensors - scriptName: " << scriptName;

// We want to ensure that results.zip is extracted into individual sensor files for processing
// Check the user specified case director for the results.zip
// Also check most likely local directories for the results.zip file
// Also check the remote work directory for the results.zip file
// Extract to
QString intermediateFolder = "";
for (int j=0; j<4; ++j)
{
if (j == 0) intermediateFolder = "."; // RemoteWorkDir
if (j == 1) intermediateFolder = "sensors"; // LocalWorkDir
if (j == 2) intermediateFolder = "results"; // LocalWorkDir
if (j == 3) intermediateFolder = "."; // LocalWorkDir

QString plotDir = sensorsPath; // + intermediateFolder + QDir::separator(); // Save the extracted files to the sensors directory.
// NOTE: The sensors directory is where the sensor time-series files are stored.
// The plots are stored in the output directory once created.

// If directory doesn't exist then skip to the next one.
if (!QDir(plotDir).exists())
{
qDebug() << "ResultsMPM::plotSensors - Checked if the folder to extract to exists: " << plotDir << ", but folder does not exist. Skipping...";
continue;
}

QString zipDir = SimCenterPreferences::getInstance()->getLocalWorkDir() + QDir::separator();
if (j == 0)
{
zipDir = SimCenterPreferences::getInstance()->getRemoteWorkDir() + QDir::separator();
}
else
{
zipDir = mainModel->caseDir() + QDir::separator()
+ "output" + QDir::separator()
+ intermediateFolder + QDir::separator();
}

QString zipPath = zipDir + "results.zip";
if (!QDir(zipDir).exists())
{
qDebug() << "ResultsMPM::plotSensors - Checked if folder " << zipDir << " exists, but folder does not exist. Skipping...";
continue;
}

if (QFileInfo::exists(zipPath))
{
QString program = "tar"; // "unzip"; // TODO: consider cross-platform compatibility.
QStringList arguments;
// Extract results.zip file from zipPath (either in the GUI set caseDir/output/{'','sensors','results}, variants in brackets, or in RemoteWorkDir when retrieving run from DesignSafe. Extract to plotDir
// plotDir must exist, and the zipPath must exist.
arguments << "-xzf" << zipPath << "-C" << plotDir;
QProcess *process = new QProcess();
process->start(program, arguments);
process->waitForStarted();
process->waitForFinished(-1);
if (process->exitStatus() == QProcess::CrashExit)
{
qDebug() << "ResultsMPM::plotSensors - The unzip process has crashed.";
}
else if (process->exitStatus() == QProcess::NormalExit)
{
qDebug() << "ResultsMPM::plotSensors - The unzip process has finished running.";
process->deleteLater();
break;
}
else
{
qDebug() << "ResultsMPM::plotSensors - The unzip process has finished running with an unknown exit status.";
}
process->deleteLater();
} else {
qDebug () << "ERROR - ResultsMPM::plotSensors - Cannot find the results.zip file in the checked directory: " << plotDir;
}
}



QString sensorsList = "";
QDir sensorsDir(sensorsPath);
if (sensorsDir.exists())
Expand Down
12 changes: 10 additions & 2 deletions WorkflowAppHydroUQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,16 @@ WorkflowAppHydroUQ::setMainWindow(MainWindowWorkflowApp* window) {
miniMPM->initialize();
}

QString appName = "simcenter-claymore-ls6-1.0.0u2"; // Lonestar6
QList<QString> queues; queues << "gpu-a100"; // These are later changed to "normal" and "fast" in the tool based on number of cores/processors? Should fix this
const bool DEV_MODE = false; // Set to true for development mode, false for production mode
QString appName;
QList<QString> queues;
if (DEV_MODE) {
appName = "ClaymoreUW-ls6.bonusj-1.0.0"; // Lonestar6 dev app for ClaymoreUW MPM, Justin Bonus (bonusj)
queues << "gpu-a100"; // These are later changed to "normal" and "fast" in the tool based on number of cores/processors? Should fix this
} else {
appName = "simcenter-claymore-ls6-1.0.0u2"; // Lonestar6 public app for ClaymoreUW MPM
queues << "gpu-a100"; // These are later changed to "normal" and "fast" in the tool based on number of cores/processors? Should fix this
}
SC_RemoteAppTool *miniMPMTool = new SC_RemoteAppTool(appName, queues, theRemoteService, miniMPM, theToolDialog); // lonestar6

theToolDialog->addTool(miniMPMTool, "Digital Twin (MPM)");
Expand Down
2 changes: 1 addition & 1 deletion makeDMG.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ echo "To check status"
echo "xcrun altool --notarization-info ID -u $appleID -p $appleAppPassword"
echo ""
echo "Finally staple the dmg"
echo "xcrun stapler staple \"$APP_NAME\" $DMG_FILENAME"
echo "xcrun stapler staple \"$APP_NAME\" $DMG_FILENAME"

0 comments on commit 1f85aad

Please sign in to comment.