OpenStudioCore:runmanager/lib
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
openstudio::runmanager::RunManager Class Reference

#include <RunManager.hpp>

Public Member Functions

void clearJobs ()
 safely clears all jobs from the runmanager More...
 
bool connect (const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type=Qt::QueuedConnection) const
 Connect a Qt SLOT to a signal in the underlying RunManager_Impl object available signals: More...
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type=Qt::QueuedConnection) const
 Connect a Qt SIGNAL to a slot in the underlying RunManager_Impl object available slots: More...
 
openstudio::path dbPath () const
 Return the file location this RunManager DB was created from. More...
 
void deleteWorkflowByName (const std::string &t_name)
 
void deleteWorkflows ()
 deletes the workflows from the database More...
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *method=nullptr)
 Disconnects signal or signals from the underlying RunManager_Impl object. More...
 
bool enqueue (const Job &job, bool force, const openstudio::path &basePath=openstudio::path())
 Queue up a job (and all children) for processing. More...
 
bool enqueue (const std::vector< openstudio::runmanager::Job > &jobs, bool force, const openstudio::path &t_basePath=openstudio::path())
 Queue up a job (and all children) for processing. More...
 
boost::optional< JobenqueueOrReturnExisting (const Job &job, bool force, const openstudio::path &basePath=openstudio::path())
 
openstudio::runmanager::ConfigOptions getConfigOptions () const
 Return a copy of the current openstudio::runmanager::ConfigOptions object. More...
 
QModelIndex getIndex (const Job &t_job) const
 
openstudio::runmanager::Job getJob (const openstudio::UUID &t_uuid) const
 Return the job that is represented by the given openstudio::UUID throw an std::out_of_range if a job with the UUID does not exist. More...
 
openstudio::runmanager::Job getJob (const QModelIndex &t_index) const
 Return the job at the current QModelIndex throw an std::out_of_range if the job could not be found. More...
 
std::vector
< openstudio::runmanager::Job
getJobs () const
 Return a vector of all Jobs the RunManager knows about. More...
 
std::vector
< openstudio::runmanager::Job
getJobs (const QModelIndexList &t_indexes) const
 
QAbstractItemModel * getQItemModel ()
 Return a QAbstractItemModel which represents the RunManager work queue. More...
 
void hideStatusDialog ()
 Hide the status dialog. More...
 
std::vector< JobjobsForExport () const
 
std::string jobsToJson () const
 
void loadJobs (const openstudio::path &t_db)
 Load all of the jobs from the given database file into the current RunManager, enqueuing them. More...
 
Workflow loadWorkflow (const std::string &key) const
 
Workflow loadWorkflowByName (const std::string &t_name) const
 
std::vector< WorkflowloadWorkflows () const
 
void lowerPriority (const Job &t_job)
 Lower the priority of the given job. More...
 
void lowerPriority (const std::vector< Job > &t_jobs)
 Lower the priority of the given jobs. More...
 
bool outOfDate (const openstudio::runmanager::Job &job) const
 Return true if the given job is out of date. More...
 
bool paused () const
 
std::string persistWorkflow (const Workflow &_wf)
 Persist a workflow to the database. More...
 
void raisePriority (const Job &t_job)
 Raise the priority of the given job. More...
 
void raisePriority (const std::vector< Job > &t_jobs)
 Raise the priority of the given jobs. More...
 
void remove (const openstudio::runmanager::Job &job)
 Remove the given job and all child jobs from the queue. More...
 
 RunManager (bool t_paused=false, bool t_initializeui=true, bool t_useStatusGUI=true)
 Construct a RunManager using a new temporary database file for this one use only. More...
 
 RunManager (const openstudio::path &DB, bool t_new=false, bool t_paused=false, bool t_initializeui=true, bool t_useStatusGUI=true)
 Construct a RunManager from a given database file path. More...
 
openstudio::runmanager::Job runWorkflow (const std::string &t_json, const openstudio::path &t_basePath, const openstudio::path &t_runPath, const openstudio::runmanager::Tools &t_tools, const openstudio::runmanager::JSONWorkflowOptions &t_options)
 Executes a workflow which is defined by a JSON string from Nick. More...
 
openstudio::runmanager::Job runWorkflow (const openstudio::path &t_jsonPath, const openstudio::path &t_basePath, const openstudio::path &t_runPath, const openstudio::runmanager::Tools &t_tools, const openstudio::runmanager::JSONWorkflowOptions &t_options)
 Executes a workflow which is defined by a JSON string from Nick. More...
 
void setConfigOptions (const openstudio::runmanager::ConfigOptions &co)
 Update the configuration options in one atomic step. More...
 
void setOutOfDateRunnable ()
 Update all out of date jobs to be runnable again Jobs do not automatically restart as soon as they are out of date. More...
 
void setPaused (bool t_paused=true)
 set paused state More...
 
void showConfigGui ()
 Launch the openstudio::runmanager::Configuration UI. More...
 
RunManagerStatusHandle showStatusDialog ()
 Show a status dialog of the processes taking place if one is not already open. More...
 
std::map< std::string, double > statistics () const
 
void updateJob (const Job &t_job)
 update job tree More...
 
void updateJob (const openstudio::UUID &t_uuid, const Job &t_job)
 update job tree, and be willing to change the UUID in the process More...
 
void updateJob (const Job &t_job, const openstudio::path &t_dir)
 update job tree More...
 
void updateJobs (const std::string &t_json, bool t_externallyManaged)
 Load all of the jobs from the given JSON string, updating job trees. More...
 
void updateJobs (const QVariant &t_variant, const VersionString &t_version, bool t_externallyManaged)
 Load all of the jobs from the given JSON structure represented by a QVariant, updating job trees. More...
 
void updateJobs (const std::vector< Job > &t_jobs)
 update job trees More...
 
void waitForFinished (int m_secs=-1)
 Block until the RunManager has finished processing all work. More...
 
bool workPending () const
 
 ~RunManager ()
 

Static Public Member Functions

static openstudio::path defaultDBLocation ()
 Return default path to use for the RunManager settings/queue database something such as $HOME/.runmanager_default_db. More...
 
static void simplifyModelForPerformance (openstudio::model::Model &t_model)
 perform some model simplifications that reduce the simulation time with accuracy being an acceptable loss More...
 

Public Attributes

void showConfigGuit_parent
 Launch the openstudio::runmanager::Configuration UI for choosing configuration options. More...
 

Detailed Description

A handle to an underlying RunManager_Impl object, can be copied and passed around freely.

If two RunManager objects are created using the same DB path, the same RunManager is loaded and shared between the two objects. This prevents any issues between file sharing for the DB's and ensures that each instantiation receives the same signals

Constructor & Destructor Documentation

openstudio::runmanager::RunManager::RunManager ( bool  t_paused = false,
bool  t_initializeui = true,
bool  t_useStatusGUI = true 
)

Construct a RunManager using a new temporary database file for this one use only.

Parameters
[in]t_pausedIf true the processor is started in paused mode.
[in]t_initializeuiIf true the application's UI subsystem is initialized. Used in a standalone application that utilized RunManager
[in]t_useStatusGUIEnable the use of Job status GUI elements
openstudio::runmanager::RunManager::RunManager ( const openstudio::path &  DB,
bool  t_new = false,
bool  t_paused = false,
bool  t_initializeui = true,
bool  t_useStatusGUI = true 
)

Construct a RunManager from a given database file path.

Parameters
[in]DBThe file location for the database storing prefs and job queue
[in]t_newIf true, the database file is truncated and started from scratch
[in]t_pausedIf true the processor is started in paused mode.
[in]t_initializeuiIf true the application's UI subsystem is initialized. Used in a standalone application that utilized RunManager
[in]t_useStatusGUIEnable the use of Job status GUI elements
openstudio::runmanager::RunManager::~RunManager ( )

Member Function Documentation

void openstudio::runmanager::RunManager::clearJobs ( )

safely clears all jobs from the runmanager

bool openstudio::runmanager::RunManager::connect ( const char *  signal,
const QObject receiver,
const char *  method,
Qt::ConnectionType  type = Qt::QueuedConnection 
) const

Connect a Qt SLOT to a signal in the underlying RunManager_Impl object available signals:

  • pausedChanged(bool)
    Parameters
    signalsignal on RunManager_Impl to connect to
    receiverobject receiving signal
    methodslot on receiver to connect to
    typetype of Qt connection
bool openstudio::runmanager::RunManager::connect ( const QObject sender,
const char *  signal,
const char *  method,
Qt::ConnectionType  type = Qt::QueuedConnection 
) const

Connect a Qt SIGNAL to a slot in the underlying RunManager_Impl object available slots:

  • setPaused(bool t_state);
    Parameters
    senderobject that SIGNAL is coming from
    signalsignal on object to connect
    methodslot on RunManager_Impl to connect to
    typetype of Qt connection to make
openstudio::path openstudio::runmanager::RunManager::dbPath ( ) const

Return the file location this RunManager DB was created from.

static openstudio::path openstudio::runmanager::RunManager::defaultDBLocation ( )
static

Return default path to use for the RunManager settings/queue database something such as $HOME/.runmanager_default_db.

void openstudio::runmanager::RunManager::deleteWorkflowByName ( const std::string &  t_name)
void openstudio::runmanager::RunManager::deleteWorkflows ( )

deletes the workflows from the database

bool openstudio::runmanager::RunManager::disconnect ( const char *  signal = nullptr,
const QObject receiver = nullptr,
const char *  method = nullptr 
)

Disconnects signal or signals from the underlying RunManager_Impl object.

bool openstudio::runmanager::RunManager::enqueue ( const Job job,
bool  force,
const openstudio::path &  basePath = openstudio::path() 
)

Queue up a job (and all children) for processing.

Parameters
[in]jobJob to enqueue
[in]forceProcess job even if it is out of date
[in]basePathPath by which relative paths in this job should be evaluated. If not provided, the path of the runmanager db is used.
bool openstudio::runmanager::RunManager::enqueue ( const std::vector< openstudio::runmanager::Job > &  jobs,
bool  force,
const openstudio::path &  t_basePath = openstudio::path() 
)

Queue up a job (and all children) for processing.

Parameters
[in]jobsVector of Jobs to enqueue
[in]forceProcess job even if it is out of date
[in]t_basePathPath by which relative paths in this job should be evaluated. If not provided, the path of the runmanager db is used.
boost::optional<Job> openstudio::runmanager::RunManager::enqueueOrReturnExisting ( const Job job,
bool  force,
const openstudio::path &  basePath = openstudio::path() 
)
openstudio::runmanager::ConfigOptions openstudio::runmanager::RunManager::getConfigOptions ( ) const

Return a copy of the current openstudio::runmanager::ConfigOptions object.

QModelIndex openstudio::runmanager::RunManager::getIndex ( const Job t_job) const
Returns
the QModelIndex for the given job in the QAbstractItemModel
openstudio::runmanager::Job openstudio::runmanager::RunManager::getJob ( const openstudio::UUID &  t_uuid) const

Return the job that is represented by the given openstudio::UUID throw an std::out_of_range if a job with the UUID does not exist.

Parameters
[in]t_uuidUUID to look up
openstudio::runmanager::Job openstudio::runmanager::RunManager::getJob ( const QModelIndex &  t_index) const

Return the job at the current QModelIndex throw an std::out_of_range if the job could not be found.

Parameters
[in]t_indexQModelIndex to look up
std::vector<openstudio::runmanager::Job> openstudio::runmanager::RunManager::getJobs ( ) const

Return a vector of all Jobs the RunManager knows about.

std::vector<openstudio::runmanager::Job> openstudio::runmanager::RunManager::getJobs ( const QModelIndexList &  t_indexes) const
Returns
a vector of all jobs contained in the QModelIndexList provided
QAbstractItemModel* openstudio::runmanager::RunManager::getQItemModel ( )

Return a QAbstractItemModel which represents the RunManager work queue.

The model is appropriate for using with a QTreeView widget

void openstudio::runmanager::RunManager::hideStatusDialog ( )

Hide the status dialog.

std::vector<Job> openstudio::runmanager::RunManager::jobsForExport ( ) const
std::string openstudio::runmanager::RunManager::jobsToJson ( ) const
void openstudio::runmanager::RunManager::loadJobs ( const openstudio::path &  t_db)

Load all of the jobs from the given database file into the current RunManager, enqueuing them.

Workflow openstudio::runmanager::RunManager::loadWorkflow ( const std::string &  key) const
Returns
a specific workflow
Workflow openstudio::runmanager::RunManager::loadWorkflowByName ( const std::string &  t_name) const
std::vector<Workflow> openstudio::runmanager::RunManager::loadWorkflows ( ) const
Returns
a vector of all workflows in the database
void openstudio::runmanager::RunManager::lowerPriority ( const Job t_job)

Lower the priority of the given job.

void openstudio::runmanager::RunManager::lowerPriority ( const std::vector< Job > &  t_jobs)

Lower the priority of the given jobs.

bool openstudio::runmanager::RunManager::outOfDate ( const openstudio::runmanager::Job job) const

Return true if the given job is out of date.

Todo:
This should probably be removed in favor of openstudio::runmanager::Job::isOutOfDate
bool openstudio::runmanager::RunManager::paused ( ) const
Returns
true if the queue is paused
std::string openstudio::runmanager::RunManager::persistWorkflow ( const Workflow _wf)

Persist a workflow to the database.

Returns
the key the workflow is stored under
void openstudio::runmanager::RunManager::raisePriority ( const Job t_job)

Raise the priority of the given job.

void openstudio::runmanager::RunManager::raisePriority ( const std::vector< Job > &  t_jobs)

Raise the priority of the given jobs.

void openstudio::runmanager::RunManager::remove ( const openstudio::runmanager::Job job)

Remove the given job and all child jobs from the queue.

openstudio::runmanager::Job openstudio::runmanager::RunManager::runWorkflow ( const std::string &  t_json,
const openstudio::path &  t_basePath,
const openstudio::path &  t_runPath,
const openstudio::runmanager::Tools t_tools,
const openstudio::runmanager::JSONWorkflowOptions t_options 
)

Executes a workflow which is defined by a JSON string from Nick.

To monitor the progress of the workflow use the RunManagerWatcher object

See also
openstudio::runmanager::RunManagerWatcher
Parameters
[in]t_jsonthe JSON string to execute. See various input files from Nick for definition.
[in]t_basePaththe path of the directory containing the input files necessary
[in]t_runPathdirectory to execute the simulations in
[in]t_toolstools to use for executing job
[in]t_optionsset of options for job creation
openstudio::runmanager::Job openstudio::runmanager::RunManager::runWorkflow ( const openstudio::path &  t_jsonPath,
const openstudio::path &  t_basePath,
const openstudio::path &  t_runPath,
const openstudio::runmanager::Tools t_tools,
const openstudio::runmanager::JSONWorkflowOptions t_options 
)

Executes a workflow which is defined by a JSON string from Nick.

Parameters
[in]t_jsonPaththe path to a json file to load and parse
[in]t_basePaththe path of the directory containing the input files necessary
[in]t_runPathdirectory to execute the simulations in
[in]t_toolstools to use for executing job
[in]t_optionsset of options for job creation
void openstudio::runmanager::RunManager::setConfigOptions ( const openstudio::runmanager::ConfigOptions co)

Update the configuration options in one atomic step.

void openstudio::runmanager::RunManager::setOutOfDateRunnable ( )

Update all out of date jobs to be runnable again Jobs do not automatically restart as soon as they are out of date.

void openstudio::runmanager::RunManager::setPaused ( bool  t_paused = true)

set paused state

void openstudio::runmanager::RunManager::showConfigGui ( )

Launch the openstudio::runmanager::Configuration UI.

This method creates one that is parentless

RunManagerStatusHandle openstudio::runmanager::RunManager::showStatusDialog ( )

Show a status dialog of the processes taking place if one is not already open.

A handle to the dialog is returned. When the last copy of the handle goes out of scope the dialog is destroyed.

static void openstudio::runmanager::RunManager::simplifyModelForPerformance ( openstudio::model::Model &  t_model)
static

perform some model simplifications that reduce the simulation time with accuracy being an acceptable loss

Todo:
move this into a more formalized location at some point
std::map<std::string, double> openstudio::runmanager::RunManager::statistics ( ) const
Returns
a set of named statistics regarding the job queue
void openstudio::runmanager::RunManager::updateJob ( const Job t_job)

update job tree

void openstudio::runmanager::RunManager::updateJob ( const openstudio::UUID &  t_uuid,
const Job t_job 
)

update job tree, and be willing to change the UUID in the process

void openstudio::runmanager::RunManager::updateJob ( const Job t_job,
const openstudio::path &  t_dir 
)

update job tree

void openstudio::runmanager::RunManager::updateJobs ( const std::string &  t_json,
bool  t_externallyManaged 
)

Load all of the jobs from the given JSON string, updating job trees.

void openstudio::runmanager::RunManager::updateJobs ( const QVariant &  t_variant,
const VersionString &  t_version,
bool  t_externallyManaged 
)

Load all of the jobs from the given JSON structure represented by a QVariant, updating job trees.

void openstudio::runmanager::RunManager::updateJobs ( const std::vector< Job > &  t_jobs)

update job trees

void openstudio::runmanager::RunManager::waitForFinished ( int  m_secs = -1)

Block until the RunManager has finished processing all work.

This method is generally only recommended for a non-gui scenario.

bool openstudio::runmanager::RunManager::workPending ( ) const
Returns
true if there is still work pending

Member Data Documentation

void showConfigGui * openstudio::runmanager::RunManager::t_parent

Launch the openstudio::runmanager::Configuration UI for choosing configuration options.

Parameters
t_parentThe parent widget for the created Configuration UI