Skip to content

Commit

Permalink
fmk - updating PelicunResults to create response.csv if remote
Browse files Browse the repository at this point in the history
  • Loading branch information
fmckenna committed Aug 26, 2024
1 parent eeaffee commit 0cbc71b
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions ResultsPelicun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,34 +388,42 @@ int ResultsPelicun::runPelicunAfterHPC(QString &resultsDirName,
QString &runDirName,
QString &appDirName){

qDebug() << "after: " << resultsDirName << " \n runDirName: " << runDirName << " \nappDirNAme:" << appDirName;

// create the workdir and copy the two result files there
//
// create workdir & copy dakotaTab.out & scInput there
//

if (!QDir(runDirName).exists()) {
QDir().mkdir(runDirName);
}

QDir runDir(runDirName);
QDir resultsDir(resultsDirName);
QDir downloadDir(resultsDirName); downloadDir.cdUp(); // templateDir.cd("templatedir");

QString downloadedTemplateDir = downloadDir.absoluteFilePath("templatedir");
QString runTemplateDir = runDir.absoluteFilePath("templatedir");
QDir templateDir(runTemplateDir);

runDir.rename(downloadedTemplateDir, runTemplateDir);

QFile::copy(resultsDir.absoluteFilePath("dakotaTab.out"),
runDir.absoluteFilePath("dakotaTab.out"));

QString tmpDirName = runDir.absoluteFilePath("templatedir");
if (!QDir(tmpDirName).exists()) {
QDir().mkdir(tmpDirName);
}
QDir tmpDir(tmpDirName);

QFile::copy(resultsDir.absoluteFilePath("dakota.json"),
tmpDir.absoluteFilePath("dakota.json"));
QDir tmpDir(runTemplateDir);
QFile::copy(templateDir.absoluteFilePath("scInput.json"),
runDir.absoluteFilePath("scInput.json"));

//
// run the loss assessment
//

QDir scriptDir(appDirName);
scriptDir.cd("applications");
scriptDir.cd("Workflow");
QString pySCRIPT = scriptDir.absoluteFilePath("sWHALE.py");
QString createResponseCSV = scriptDir.absoluteFilePath("createResponseCSV.py");
QString registryFile = scriptDir.absoluteFilePath("WorkflowApplications.json");
QString inputFileName = tmpDir.absoluteFilePath("dakota.json");
QString inputFileName = runDir.absoluteFilePath("scInput.json");

QProcess *proc = new QProcess();
SimCenterPreferences *preferences = SimCenterPreferences::getInstance();
Expand All @@ -433,14 +441,30 @@ int ResultsPelicun::runPelicunAfterHPC(QString &resultsDirName,

#ifdef Q_OS_WIN
python = QString("\"") + python + QString("\"");
QStringList argsCSV{createResponseCSV,"--input_file",inputFileName};
proc->execute(python, argsCSV);
QStringList args{pySCRIPT, "loss_only",inputFileName,registryFile};
proc->execute(python, args);

#else

// note the above not working under linux because basrc not being called so no env variables!!

qDebug() << "Python: " << python;
QString command = QString("source $HOME/.bash_profile; \"") + python + QString("\" \"") +
QString sourceBash("");
QDir homeDir(QDir::homePath());
if (homeDir.exists(".bash_profile")) {
sourceBash = QString("source $HOME/.bash_profile; \"");
} else if (homeDir.exists(".bashrc")) {
sourceBash = QString("source $HOME/.bashrc; \"");
} else if (homeDir.exists(".zprofile")) {
sourceBash = QString("source $HOME/.zprofile; \"");
} else if (homeDir.exists(".zshrc")) {
sourceBash = QString("source $HOME/.zshrc; \"");
} else
this->errorMessage( "No .bash_profile, .bashrc, .zprofile or .zshrc file found. This may not find Dakota or OpenSees");

QString command = sourceBash + python + QString("\" \"") +
createResponseCSV + QString("\" --inputFile \"") + inputFileName +
QString("\" > /Users/fmckenna/output.log 2>&1; \"") + python + QString("\" \"") +
pySCRIPT + QString("\" \"loss_only\" \"") + inputFileName + QString("\" \"") +
registryFile + QString("\"");

Expand Down

0 comments on commit 0cbc71b

Please sign in to comment.