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

#include <Job.hpp>

Public Member Functions

void addChild (const Job &t_job)
 Adds a new child job to this job. More...
 
Files allFiles () const
 Return the set of all files (input and output) from this job and its dependencies. More...
 
Files allInputFiles () const
 Return the set of all input files available to this job. More...
 
JobParams allParams () const
 return all the specific params this job has appended onto the list of params acquired from all dependencies More...
 
bool canceled () const
 Returns the canceled state of the job. More...
 
std::vector< Jobchildren () const
 Returns a vector of all children that this job has. More...
 
boost::optional
< openstudio::DateTime > 
childrenLastRun () const
 Returns the most recent DateTime that any child was run. More...
 
bool childrenOutOfDate () const
 Returns true if any child process is out of date. More...
 
bool childrenRunning () const
 Returns true if any child is currently running. More...
 
bool childrenTreesOutOfDate () const
 Returns true if any child process's tree is out of date. More...
 
bool childrenTreesRunning () const
 Returns true if any child's tree is currently running. More...
 
void cleanup ()
 Cleanup the output generated by this job removing any output files that have been created. More...
 
bool connect (const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type=Qt::QueuedConnection) const
 Connect a Qt signal/slot pair through to the underlying Job_Impl object that this object is a handle to. More...
 
std::string description () const
 Return a user friendly description of the job. More...
 
std::string detailedDescription () const
 Return a detailed description of the job. More...
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *method=nullptr)
 Pass a disconnect call through to the underlying Job_Impl object. More...
 
boost::optional
< openstudio::DateTime > 
endTime () const
 
JobErrors errors () const
 Return an object representing the errors and warnings that this job has generated. More...
 
bool externallyManaged () const
 
boost::optional< JobfinishedJob () const
 
openstudio::path getBasePath () const
 
std::string getOutput () const
 Get all stdout output generated by the Job so far. More...
 
bool hasMergedJobs () const
 
std::vector< std::pair
< boost::posix_time::ptime,
AdvancedStatus > > 
history () const
 Returns the history of the status changes of the job. More...
 
int index () const
 
std::vector< FileInfoinputFiles () const
 Return a vector of all input files the job was created with. More...
 
 Job (const Job &temp)
 
JobParams jobParams () const
 Return a JobParams object for the params in this job. More...
 
JobType jobType () const
 Return the JobType of the Job. More...
 
boost::optional
< openstudio::DateTime > 
lastRun () const
 Return last time that the Job was run (set at the "start" time) More...
 
void makeExternallyManaged ()
 sets this job (and children) as being externally managed More...
 
std::vector< MergedJobResultsmergedJobResults () const
 
void mergeJob (const openstudio::runmanager::Job &t_job)
 Merge the t_job into the current job, if possible. More...
 
void moveToThread (QThread *targetThread)
 
bool operator< (const Job &rhs) const
 
Joboperator= (Job rhs)
 
bool operator== (const Job &rhs) const
 
openstudio::path outdir () const
 
bool outOfDate () const
 Return true if the job is out of date. More...
 
std::vector< FileInfooutputFiles () const
 Return a vector of all output files generated by the Job. More...
 
std::vector< JobParamparams () const
 Return a vector of all params this job was created with. More...
 
boost::optional< Jobparent () const
 
bool ranBefore (const openstudio::runmanager::Job &t_rhs) const
 Return true if this job was run before t_rhs This function provides a higher resolution comparison than lhs.lastRun() < rhs.lastRun() More...
 
std::vector< FileInforawInputFiles () const
 Return a vector of all input files the job was created with, with no base path application. More...
 
Files relativeOutputFiles () const
 
bool removeChild (const Job &t_job)
 Deparents the provided Job from this Job. More...
 
void requestStop ()
 Requests that a job stops. More...
 
bool runnable () const
 
bool running () const
 Return true if the job is currently running. More...
 
void sendSignals ()
 
void setBasePath (const openstudio::path &t_basePath)
 Sets the base path by which relative paths will be evaluated from this job. More...
 
void setBasePathRecursive (const openstudio::path &t_basePath)
 Sets the base path for this job and all child jobs. More...
 
void setCanceled (bool t_canceled=true)
 Set the canceled state of the job The job will continue processing if it has already begun, but will refuse to restart processing if the job becomes out of date later. More...
 
void setFinishedJob (const Job &t_job)
 Sets the "finishedJob" This is a job that executes after the parent and all parallel children have finished executing. More...
 
void setIndex (int index)
 
void setRunnable (bool force=false)
 Set the runnable state of the job. More...
 
void setStatus (const AdvancedStatus &t_status)
 Sets the advancedstatus of the current job. Only allowed on externally managed jobs. More...
 
void setTreeCanceled (bool t_canceled=true)
 Set the canceled state of this job and all child jobs. More...
 
void setTreeRunnable (bool force=false)
 Sets the runnable state for this job and all child jobs. More...
 
void showErrors () const
 Present the warnings and errors generated by this job to the user. More...
 
void showTreeErrors () const
 Present the warnings and errors generated by this job and all children jobs to the user. More...
 
void start (const std::shared_ptr< ProcessCreator > &t_pc)
 Begin execution of the job. More...
 
boost::optional
< openstudio::DateTime > 
startTime () const
 
AdvancedStatus status () const
 
void swap (Job &rhs)
 Swap the internals of this job with rhs. More...
 
std::string toJSON () const
 
std::vector< ToolInfotools () const
 Return a vector of all tools this job was created with. More...
 
Files treeAllFiles () const
 
std::string treeDescription () const
 
std::vector< std::string > treeDetailedDescription () const
 
JobErrors treeErrors () const
 
boost::optional
< openstudio::DateTime > 
treeLastRun () const
 
bool treeOutOfDate () const
 
Files treeOutputFiles () const
 
bool treeRunning () const
 
openstudio::runmanager::TreeStatusEnum treeStatus () const
 
void updateJob (const Job &t_other, bool t_allowUUIDUpdate)
 Update this job tree with the details from the other job tree. More...
 
UUID uuid () const
 Return the UUID of the Job. More...
 
void waitForFinished (int t_msecs=-1)
 Synchronously block until the Job has been finished. More...
 

Static Public Member Functions

static Job fromJSON (const std::string &t_json)
 

Protected Member Functions

 Job (const std::shared_ptr< detail::Job_Impl > &t_impl)
 

Related Functions

(Note that these are not member functions.)

typedef boost::optional< JobOptionalJob
 

Detailed Description

A handle to a job that must be created with the JobFactory class.

Jobs are reference counted objects can may be safely copied

Constructor & Destructor Documentation

openstudio::runmanager::Job::Job ( const Job temp)
openstudio::runmanager::Job::Job ( const std::shared_ptr< detail::Job_Impl > &  t_impl)
protected

Member Function Documentation

void openstudio::runmanager::Job::addChild ( const Job t_job)

Adds a new child job to this job.

All child jobs will be executed in parallel after the parent finishes Any child added will be reparented to this Job

Files openstudio::runmanager::Job::allFiles ( ) const

Return the set of all files (input and output) from this job and its dependencies.

Files openstudio::runmanager::Job::allInputFiles ( ) const

Return the set of all input files available to this job.

JobParams openstudio::runmanager::Job::allParams ( ) const

return all the specific params this job has appended onto the list of params acquired from all dependencies

bool openstudio::runmanager::Job::canceled ( ) const

Returns the canceled state of the job.

std::vector<Job> openstudio::runmanager::Job::children ( ) const

Returns a vector of all children that this job has.

boost::optional<openstudio::DateTime> openstudio::runmanager::Job::childrenLastRun ( ) const

Returns the most recent DateTime that any child was run.

bool openstudio::runmanager::Job::childrenOutOfDate ( ) const

Returns true if any child process is out of date.

bool openstudio::runmanager::Job::childrenRunning ( ) const

Returns true if any child is currently running.

bool openstudio::runmanager::Job::childrenTreesOutOfDate ( ) const

Returns true if any child process's tree is out of date.

bool openstudio::runmanager::Job::childrenTreesRunning ( ) const

Returns true if any child's tree is currently running.

void openstudio::runmanager::Job::cleanup ( )

Cleanup the output generated by this job removing any output files that have been created.

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

Connect a Qt signal/slot pair through to the underlying Job_Impl object that this object is a handle to.

Available slots:

  • started(const openstudio::UUID &id) - emitted when job is started
  • finished(const openstudio::UUID &id, const openstudio::runmanager::JobErrors &errors) - emitted when job has finished
  • outputFileChanged(const openstudio::UUID &id, const openstudio::runmanager::FileInfo& file) - emitted when any output file created by job has been modified
  • outputDataAdded(const openstudio::UUID &id, const std::string &data) - emitted when raw data is send to stdout, does not wait for whole lines
  • stateChanged(const openstudio::UUID &id) - emitted when the state (running) or description of the job has changed
  • statusChanged(const openstudio::runmanager::AdvancedStatus &) - emitted when detailed status information is available
  • childrenChanged(const openstudio::UUID &id) - emitted after the list of children has changed
  • parentChanged(const openstudio::UUID &id) - emitted after the parent has changed
  • treeChanged() - emitted if any of the jobs in the job tree (this one or any children) have changed in any way
  • uuidChanged(const openstudio::UUID &oldId, const openstudio::UUID &newId) - emitted if the UUID of this job changed
    Parameters
    [in]signalsignal to connect to
    [in]receiversignal receiver
    [in]methodreceiving slot
    [in]typeType of connection to make
std::string openstudio::runmanager::Job::description ( ) const

Return a user friendly description of the job.

std::string openstudio::runmanager::Job::detailedDescription ( ) const

Return a detailed description of the job.

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

Pass a disconnect call through to the underlying Job_Impl object.

Parameters
[in]signalsignal to disconnect from
[in]receiversignal receiver to disconnect
[in]methodreceiving slot to disconnect
See also
Job::connect
boost::optional<openstudio::DateTime> openstudio::runmanager::Job::endTime ( ) const
Returns
the time the job completed
JobErrors openstudio::runmanager::Job::errors ( ) const

Return an object representing the errors and warnings that this job has generated.

bool openstudio::runmanager::Job::externallyManaged ( ) const
Returns
true if the job is flagged as externally managed
boost::optional<Job> openstudio::runmanager::Job::finishedJob ( ) const
Returns
the job finished job.
See also
setFinishedJob
static Job openstudio::runmanager::Job::fromJSON ( const std::string &  t_json)
static
Returns
a re-created Job tree from the given JSON string.
Exceptions
std::exceptionif any part of the parsing fails, with description of where and why.
See also
Job::toJSON for more information
openstudio::path openstudio::runmanager::Job::getBasePath ( ) const
Returns
the base path for this process execution
std::string openstudio::runmanager::Job::getOutput ( ) const

Get all stdout output generated by the Job so far.

bool openstudio::runmanager::Job::hasMergedJobs ( ) const
Returns
true if the job has merged jobs
std::vector<std::pair<boost::posix_time::ptime, AdvancedStatus> > openstudio::runmanager::Job::history ( ) const

Returns the history of the status changes of the job.

int openstudio::runmanager::Job::index ( ) const
Returns
the Job's index in the work queue. Or -1 if unset
std::vector<FileInfo> openstudio::runmanager::Job::inputFiles ( ) const

Return a vector of all input files the job was created with.

JobParams openstudio::runmanager::Job::jobParams ( ) const

Return a JobParams object for the params in this job.

JobType openstudio::runmanager::Job::jobType ( ) const

Return the JobType of the Job.

boost::optional<openstudio::DateTime> openstudio::runmanager::Job::lastRun ( ) const

Return last time that the Job was run (set at the "start" time)

Returns
empty value if the Job has never been run.
void openstudio::runmanager::Job::makeExternallyManaged ( )

sets this job (and children) as being externally managed

std::vector<MergedJobResults> openstudio::runmanager::Job::mergedJobResults ( ) const
Returns
the breakout of completed merged jobs
void openstudio::runmanager::Job::mergeJob ( const openstudio::runmanager::Job t_job)

Merge the t_job into the current job, if possible.

If not possible, throw MergeJobError with description as to why. accepts NullJobs automatically, passes off to mergeJobImpl if otherwise.

void openstudio::runmanager::Job::moveToThread ( QThread targetThread)
bool openstudio::runmanager::Job::operator< ( const Job rhs) const
Returns
true if this Job's UUID is < rhs.uuid()
Job& openstudio::runmanager::Job::operator= ( Job  rhs)
bool openstudio::runmanager::Job::operator== ( const Job rhs) const
Returns
true if the Jobs' uuids are equal
openstudio::path openstudio::runmanager::Job::outdir ( ) const
Returns
the output directory that the Job is using
bool openstudio::runmanager::Job::outOfDate ( ) const

Return true if the job is out of date.

std::vector<FileInfo> openstudio::runmanager::Job::outputFiles ( ) const

Return a vector of all output files generated by the Job.

The list may change as the job generates more output files.

std::vector<JobParam> openstudio::runmanager::Job::params ( ) const

Return a vector of all params this job was created with.

boost::optional<Job> openstudio::runmanager::Job::parent ( ) const
Returns
the job's parent, if it exists
bool openstudio::runmanager::Job::ranBefore ( const openstudio::runmanager::Job t_rhs) const

Return true if this job was run before t_rhs This function provides a higher resolution comparison than lhs.lastRun() < rhs.lastRun()

Parameters
[in]t_rhsthe job to compare to.
std::vector<FileInfo> openstudio::runmanager::Job::rawInputFiles ( ) const

Return a vector of all input files the job was created with, with no base path application.

Files openstudio::runmanager::Job::relativeOutputFiles ( ) const
Returns
all output files relative to the rundir
bool openstudio::runmanager::Job::removeChild ( const Job t_job)

Deparents the provided Job from this Job.

Returns
false if t_job is not a child of this Job
void openstudio::runmanager::Job::requestStop ( )

Requests that a job stops.

bool openstudio::runmanager::Job::runnable ( ) const
Returns
true if the job is runnable.
bool openstudio::runmanager::Job::running ( ) const

Return true if the job is currently running.

void openstudio::runmanager::Job::sendSignals ( )
void openstudio::runmanager::Job::setBasePath ( const openstudio::path &  t_basePath)

Sets the base path by which relative paths will be evaluated from this job.

void openstudio::runmanager::Job::setBasePathRecursive ( const openstudio::path &  t_basePath)

Sets the base path for this job and all child jobs.

void openstudio::runmanager::Job::setCanceled ( bool  t_canceled = true)

Set the canceled state of the job The job will continue processing if it has already begun, but will refuse to restart processing if the job becomes out of date later.

void openstudio::runmanager::Job::setFinishedJob ( const Job t_job)

Sets the "finishedJob" This is a job that executes after the parent and all parallel children have finished executing.

void openstudio::runmanager::Job::setIndex ( int  index)
Parameters
[in]indexSet the job's index in the work queue
void openstudio::runmanager::Job::setRunnable ( bool  force = false)

Set the runnable state of the job.

Parameters
[in]forceForces the job to be runnable even if it is not out of date or has been marked as canceled
void openstudio::runmanager::Job::setStatus ( const AdvancedStatus t_status)

Sets the advancedstatus of the current job. Only allowed on externally managed jobs.

void openstudio::runmanager::Job::setTreeCanceled ( bool  t_canceled = true)

Set the canceled state of this job and all child jobs.

void openstudio::runmanager::Job::setTreeRunnable ( bool  force = false)

Sets the runnable state for this job and all child jobs.

void openstudio::runmanager::Job::showErrors ( ) const

Present the warnings and errors generated by this job to the user.

void openstudio::runmanager::Job::showTreeErrors ( ) const

Present the warnings and errors generated by this job and all children jobs to the user.

void openstudio::runmanager::Job::start ( const std::shared_ptr< ProcessCreator > &  t_pc)

Begin execution of the job.

Note that execution does not necessarily begin immediately. Check isRunning or handle the started() signal to know when the job state has changed

Parameters
[in]t_pcProcessCreator to use if any process needs to be executed by the job
boost::optional<openstudio::DateTime> openstudio::runmanager::Job::startTime ( ) const
Returns
the time the job was started
AdvancedStatus openstudio::runmanager::Job::status ( ) const
Returns
details status information about the Job
void openstudio::runmanager::Job::swap ( Job rhs)

Swap the internals of this job with rhs.

std::string openstudio::runmanager::Job::toJSON ( ) const
Returns
a snapshot of the complete status of this job and all children

All paths and tools are left as-is, as if the job were being persisted in the runmanager database.

Main uses for this function are transporting the status of a job tree across a network and for display locally and for persisting of complex workflows.

With care to use relative paths, or care to re-create the job file structure on two computers it could be used to begin a job tree on one computer and continue it on another.

See also
openstudio::runmanager::Workflow::create for information on creating a Job tree from a Workflow
openstudio::runmanager::Workflow::Workflow for information on creating a Workflow from a Job tree
std::vector<ToolInfo> openstudio::runmanager::Job::tools ( ) const

Return a vector of all tools this job was created with.

Files openstudio::runmanager::Job::treeAllFiles ( ) const
Returns
all input and output files for all jobs in this job tree.
std::string openstudio::runmanager::Job::treeDescription ( ) const
Returns
a string describing the job tree from this point down
std::vector<std::string> openstudio::runmanager::Job::treeDetailedDescription ( ) const
Returns
the concatenation of the job tree's detailed description fields
JobErrors openstudio::runmanager::Job::treeErrors ( ) const
Returns
the amalgamation of all warnings / errors reported by this job and all child jobs
boost::optional<openstudio::DateTime> openstudio::runmanager::Job::treeLastRun ( ) const
Returns
the time the tree was completed running. Only returns a value if all jobs in the tree have a last run time and returns the latest of the returned values
bool openstudio::runmanager::Job::treeOutOfDate ( ) const
Returns
true if this job or any job under it is out of date
Files openstudio::runmanager::Job::treeOutputFiles ( ) const
Returns
all output files generated by this job and all of its (grand)children jobs
bool openstudio::runmanager::Job::treeRunning ( ) const
Returns
true if this job or any job under it is running
openstudio::runmanager::TreeStatusEnum openstudio::runmanager::Job::treeStatus ( ) const
Returns
the overall status of the job tree
void openstudio::runmanager::Job::updateJob ( const Job t_other,
bool  t_allowUUIDUpdate 
)

Update this job tree with the details from the other job tree.

Throws an error if the UUID's do not match

Specifically, the static content: input files, params and tools remain static but the state, output files, last runtime are updated.

UUID openstudio::runmanager::Job::uuid ( ) const

Return the UUID of the Job.

void openstudio::runmanager::Job::waitForFinished ( int  t_msecs = -1)

Synchronously block until the Job has been finished.

Parameters
[in]t_msecsNumber of milliseconds to wait for if -1, wait indefinitely

Friends And Related Function Documentation

typedef boost::optional<Job> OptionalJob
related