mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 15:41:00 -05:00
Add preferences for HPC/Batch scheduler Add Slurm and LSF support Add batch job monitor Support launcher specific user settings Use internal timer to refresh job state Add some more options to batch monitor Improve naming Add tests for job lists Change WSL handling for processes.
111 lines
3.4 KiB
C++
111 lines
3.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2021 Equinor ASA
|
|
//
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
#pragma once
|
|
|
|
#include "RiaWslTools.h"
|
|
|
|
#include "cafFilePath.h"
|
|
#include "cafPdmField.h"
|
|
#include "cafPdmObject.h"
|
|
|
|
#include <QPointer>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
class RimProcessMonitor;
|
|
class QProcess;
|
|
|
|
class RimProcess : public caf::PdmObject
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
RimProcess( bool logStdOutErr = true, std::shared_ptr<RimProcessMonitor> monitor = nullptr );
|
|
~RimProcess() override;
|
|
|
|
void setDescription( QString desc );
|
|
void setCommand( QString cmdStr );
|
|
void addParameter( QString paramStr );
|
|
void addParameters( QStringList parameterList );
|
|
|
|
void addEnvironmentVariable( QString name, QString value );
|
|
|
|
const std::vector<std::pair<QString, QString>>& environmentVariables() const;
|
|
|
|
void setWorkingDirectory( QString directory );
|
|
QString workingDirectory() const;
|
|
|
|
QString commandLine() const;
|
|
|
|
QString command() const;
|
|
QStringList parameters() const;
|
|
size_t ID() const;
|
|
QString description() const;
|
|
std::shared_ptr<RimProcessMonitor> monitor() const;
|
|
|
|
void setWslOptions( const RiaWslTools::WslOptions& wslOpt );
|
|
const RiaWslTools::WslOptions& wslOptions() const;
|
|
|
|
// blocking run
|
|
bool execute( bool enableStdOut = true, bool enableStdErr = true );
|
|
|
|
// async run
|
|
bool start( bool enableStdOut = true, bool enableStdErr = true );
|
|
void cleanUpAfterRun();
|
|
void terminate();
|
|
void notifyErrorFinish();
|
|
void writeToStdIn( QStringList stdIn );
|
|
bool isRunning();
|
|
|
|
const QStringList& stdErr() const;
|
|
const QStringList& stdOut() const;
|
|
|
|
void appendStdOut( QString line );
|
|
void appendStdErr( QString line );
|
|
|
|
protected:
|
|
caf::PdmFieldHandle* userDescriptionField() override;
|
|
|
|
private:
|
|
QString optionalCommandInterpreter() const;
|
|
QString optionalPreParameters() const;
|
|
QString handleSpaces( QString argument ) const;
|
|
|
|
bool isWindowsBatchFile() const;
|
|
|
|
caf::PdmField<QString> m_command;
|
|
QStringList m_arguments;
|
|
caf::PdmField<QString> m_description;
|
|
caf::PdmField<size_t> m_id;
|
|
caf::PdmField<caf::FilePath> m_workDir;
|
|
|
|
std::vector<std::pair<QString, QString>> m_environmentVariables;
|
|
|
|
static std::atomic<size_t> m_nextProcessId;
|
|
std::shared_ptr<RimProcessMonitor> m_monitor;
|
|
bool m_enableLogging;
|
|
QPointer<QProcess> m_qProcess;
|
|
QStringList m_emptyList;
|
|
RiaWslTools::WslOptions m_wslOptions;
|
|
};
|