mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-29 16:40:20 -05:00
Preferences framework
Add preferences for HPC/Batch scheduler Add slurm and LSF support Add batch job monitor Support launcher specific user settings Use internal timer, not global view timer Add some more options to batch monitor Improve naming Add tests for job lists
This commit is contained in:
1 parent
eb66255a70
commit
a8dc7dedae
61 files changed
+2735
-165
No files matched your search
@@ -19,7 +19,9 @@
|
||||
#include "RimProcess.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferencesOpm.h"
|
||||
#include "RiaQStringFormatter.h"
|
||||
#include "RiaWslTools.h"
|
||||
#include "RimProcessMonitor.h"
|
||||
|
||||
#include "cafPdmFieldCapability.h"
|
||||
@@ -35,13 +37,13 @@ size_t RimProcess::m_nextProcessId = 1;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimProcess::RimProcess( bool logStdOutErr /*true*/, RimProcessMonitor* monitor )
|
||||
RimProcess::RimProcess( bool logStdOutErr, std::shared_ptr<RimProcessMonitor> monitor )
|
||||
: m_enableLogging( logStdOutErr )
|
||||
, m_qProcess( nullptr )
|
||||
{
|
||||
size_t defId = m_nextProcessId++;
|
||||
if ( monitor == nullptr )
|
||||
m_monitor = new RimProcessMonitor( defId, logStdOutErr );
|
||||
m_monitor = std::make_shared<RimProcessMonitor>( defId, logStdOutErr );
|
||||
else
|
||||
{
|
||||
m_monitor = monitor;
|
||||
@@ -61,6 +63,9 @@ RimProcess::RimProcess( bool logStdOutErr /*true*/, RimProcessMonitor* monitor )
|
||||
|
||||
CAF_PDM_InitField( &m_id, "ID", defId, "ID" );
|
||||
m_id.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitField( &m_useWsl, "UseWSL", false, "Use WSL to launch process" );
|
||||
m_useWsl.uiCapability()->setUiReadOnly( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -68,11 +73,6 @@ RimProcess::RimProcess( bool logStdOutErr /*true*/, RimProcessMonitor* monitor )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimProcess::~RimProcess()
|
||||
{
|
||||
if ( m_monitor != nullptr )
|
||||
{
|
||||
delete m_monitor;
|
||||
m_monitor = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmFieldHandle* RimProcess::userDescriptionField()
|
||||
@@ -124,12 +124,28 @@ void RimProcess::setDescription( QString desc )
|
||||
m_description = desc;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimProcess::description() const
|
||||
{
|
||||
return m_description();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<RimProcessMonitor> RimProcess::monitor() const
|
||||
{
|
||||
return m_monitor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimProcess::command() const
|
||||
{
|
||||
return m_command;
|
||||
return m_command();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -143,19 +159,35 @@ QStringList RimProcess::parameters() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RimProcess::stdOut() const
|
||||
const QStringList& RimProcess::stdOut() const
|
||||
{
|
||||
if ( m_monitor ) return m_monitor->stdOut();
|
||||
return QStringList();
|
||||
return m_emptyList;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RimProcess::stdErr() const
|
||||
const QStringList& RimProcess::stdErr() const
|
||||
{
|
||||
if ( m_monitor ) return m_monitor->stdErr();
|
||||
return QStringList();
|
||||
return m_emptyList;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProcess::appendStdOut( QString line )
|
||||
{
|
||||
if ( m_monitor ) m_monitor->appendStdOut( line );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProcess::appendStdErr( QString line )
|
||||
{
|
||||
if ( m_monitor ) m_monitor->appendStdErr( line );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -177,14 +209,20 @@ bool RimProcess::start( bool enableStdOut, bool enableStdErr )
|
||||
m_qProcess = new QProcess();
|
||||
QString cmd = commandLine();
|
||||
|
||||
if ( m_enableLogging ) RiaLogging::info( std::format( "Start process {}: {}", m_id(), cmd ) );
|
||||
if ( m_enableLogging )
|
||||
{
|
||||
std::string wslTxt = m_useWsl() ? " using WSL" : "";
|
||||
RiaLogging::info( std::format( "Start process {}{}: {}", m_id(), wslTxt, cmd ) );
|
||||
}
|
||||
|
||||
m_monitor->clearStdOutErr();
|
||||
|
||||
QObject::connect( m_qProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), m_monitor, SLOT( finished( int, QProcess::ExitStatus ) ) );
|
||||
if ( enableStdOut ) QObject::connect( m_qProcess, SIGNAL( readyReadStandardOutput() ), m_monitor, SLOT( readyReadStandardOutput() ) );
|
||||
if ( enableStdErr ) QObject::connect( m_qProcess, SIGNAL( readyReadStandardError() ), m_monitor, SLOT( readyReadStandardError() ) );
|
||||
QObject::connect( m_qProcess, SIGNAL( started() ), m_monitor, SLOT( started() ) );
|
||||
QObject::connect( m_qProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), m_monitor.get(), SLOT( finished( int, QProcess::ExitStatus ) ) );
|
||||
if ( enableStdOut )
|
||||
QObject::connect( m_qProcess, SIGNAL( readyReadStandardOutput() ), m_monitor.get(), SLOT( readyReadStandardOutput() ) );
|
||||
if ( enableStdErr )
|
||||
QObject::connect( m_qProcess, SIGNAL( readyReadStandardError() ), m_monitor.get(), SLOT( readyReadStandardError() ) );
|
||||
QObject::connect( m_qProcess, SIGNAL( started() ), m_monitor.get(), SLOT( started() ) );
|
||||
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
for ( auto& [key, val] : m_environmentVariables )
|
||||
@@ -197,17 +235,42 @@ bool RimProcess::start( bool enableStdOut, bool enableStdErr )
|
||||
m_qProcess->setWorkingDirectory( m_workDir().path() );
|
||||
}
|
||||
|
||||
if ( m_useWsl() )
|
||||
{
|
||||
m_arguments.prepend( m_command() );
|
||||
m_arguments = RiaPreferencesOpm::current()->wslOptions() + m_arguments;
|
||||
m_command = RiaWslTools::wslCommand();
|
||||
}
|
||||
|
||||
m_qProcess->start( m_command, m_arguments );
|
||||
if ( !m_qProcess->waitForStarted( -1 ) )
|
||||
{
|
||||
auto error = m_qProcess->errorString();
|
||||
RiaLogging::error( std::format( "Failed to start process {}. {}.", m_id(), error ) );
|
||||
if ( m_enableLogging )
|
||||
{
|
||||
auto error = m_qProcess->errorString();
|
||||
RiaLogging::error( std::format( "Failed to start process {}. {}.", m_id(), error ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProcess::writeToStdIn( QStringList text )
|
||||
{
|
||||
if ( m_qProcess == nullptr ) return;
|
||||
|
||||
for ( auto& line : text )
|
||||
{
|
||||
m_qProcess->write( line.toUtf8() + "\n" );
|
||||
m_qProcess->waitForBytesWritten();
|
||||
m_qProcess->closeWriteChannel();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -342,6 +405,14 @@ void RimProcess::addEnvironmentVariable( QString name, QString value )
|
||||
m_environmentVariables.push_back( std::make_pair( name, value ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<std::pair<QString, QString>>& RimProcess::environmentVariables() const
|
||||
{
|
||||
return m_environmentVariables;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -349,3 +420,27 @@ void RimProcess::setWorkingDirectory( QString workDir )
|
||||
{
|
||||
m_workDir = workDir;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimProcess::workingDirectory() const
|
||||
{
|
||||
return m_workDir().path();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimProcess::useWsl() const
|
||||
{
|
||||
return m_useWsl();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProcess::setUseWsl( bool useWsl )
|
||||
{
|
||||
m_useWsl = useWsl;
|
||||
}
|
||||
Reference in new issue
Block a user