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

#include <RubyJobUtils.hpp>

Public Member Functions

void addInputFile (const FileSelection &t_fileselection, const FileSource &t_filesource, const std::string &t_inputregex, const std::string &t_outputname)
 Adds an input file from the Job defined list of input FileInfo objects that should be added as a requirement to this. More...
 
bool addRequiredFile (const openstudio::path &currentPath, const openstudio::path &copyPath, const openstudio::path &relativeTo=openstudio::path(), bool verifyExistence=true)
 
void addScriptArgument (const std::string &name)
 Adds an argument with no "--" prefix to the ruby script that is executed. More...
 
void addScriptParameter (const std::string &name, const std::string &value)
 Adds a parameter to be passed to the ruby script that is executed. More...
 
void addScriptParameter (const std::string &name)
 Adds a valueless parameter to be passed to the ruby script that is executed. More...
 
void addToolArgument (const std::string &name)
 Sets a parameter to pass to the ruby interpreter itself. More...
 
void addToWorkflow (Workflow &t_wf, const std::vector< openstudio::path > &t_requiredFiles=std::vector< openstudio::path >()) const
 Adds the Ruby job as it is currently defined to the given workflow. More...
 
boost::optional< openstudio::UUID > bclMeasureUUID () const
 
void clearIncludeDir ()
 Clears any -I parameters currently set to be sent to the ruby script interpreter. More...
 
void copyRequiredFiles (const std::string &t_infileextension, const std::string &t_outextension, const std::string &t_requiredFilename)
 Specifies that the "requiredFiles" from an input file with given extension (t_infileextension) to all generated output files with the matching extension (t_outextension) if the requiredFile matches the given filename (t_requiredFilename) More...
 
std::vector< std::tuple
< std::string, std::string,
std::string > > 
copyRequiredFiles () const
 Returns the collection of required files to copy for this job. More...
 
std::vector< std::string > getScriptParameters () const
 Returns the script parameters defined. More...
 
std::vector< std::string > getToolParameters () const
 Returns the tool parameters defined. More...
 
std::vector< std::tuple
< FileSelection, FileSource,
std::string, std::string > > 
inputFiles () const
 Returns the collection of input files specified for this job. More...
 
const std::vector
< RubyJobBuilder > & 
mergedJobs () const
 
boost::optional< openstudio::UUID > originalUUID () const
 
std::vector< std::pair
< openstudio::path,
openstudio::path > > 
requiredFiles () const
 
 RubyJobBuilder (bool t_userScriptJob=false)
 
 RubyJobBuilder (const openstudio::path &t_json)
 Construct a RubyJobBuilder from a json file. More...
 
 RubyJobBuilder (const JobParams &t_params)
 Construct a RubyJobBuilder from an existing set of JobParams (useful when loading from the database). More...
 
 RubyJobBuilder (const WorkItem &t_workItem)
 Create from the workflow WorkItem. More...
 
 RubyJobBuilder (const WorkItem &t_workItem, const openstudio::path &t_originalBasePath, const openstudio::path &t_newBasePath)
 Create from the workflow WorkItem. More...
 
 RubyJobBuilder (const openstudio::BCLMeasure &t_measure, const std::vector< ruleset::OSArgument > &t_args=std::vector< ruleset::OSArgument >(), const openstudio::path &t_relativeTo=openstudio::path(), bool t_copyFileTrue=false)
 Create from a BCLMeasure by: Setting scriptFile to t_measure.primaryRubyScriptPath() Calling addRequiredFile for each t_measure.files() Calling addInputFile for appropriate t_measure.inputFileType() Calling copyRequiredFiles for t_measure.inputFileType to t_measure.outputFileType() More...
 
 RubyJobBuilder (const openstudio::BCLMeasure &t_measure, const std::map< std::string, ruleset::OSArgument > &t_args, const openstudio::path &t_relativeTo=openstudio::path(), bool t_copyFileTrue=false)
 
openstudio::path script () const
 
void setIncludeDir (const openstudio::path &value)
 Sets the -I include dir that is passed to the ruby script interpreter during execution. More...
 
void setScriptFile (const openstudio::path &t_script)
 Sets the name of the ruby script file to execute. More...
 
JobParams toParams () const
 Returns the set of JobParams defined by this object currently. More...
 
WorkItem toWorkItem (const std::vector< openstudio::path > &t_requiredFiles=std::vector< openstudio::path >()) const
 Create a WorkItem representing this RubyScriptJob. More...
 
bool userScriptJob () const
 

Static Public Member Functions

static void addJobsToWorkflow (Workflow &t_workflow, const std::vector< RubyJobBuilder > &t_jobs, const openstudio::path &t_includePath, const std::vector< openstudio::path > &t_requiredFiles)
 
static std::vector
< RubyJobBuilder
createRubyJobsFromFolder (const openstudio::path &t_path, const std::vector< std::pair< openstudio::path, std::vector< ruleset::OSArgument > > > &t_userScripts, const std::string &t_inputExtension, const openstudio::path &t_relativeTo=openstudio::path(), bool t_copyFileTrue=false)
 
static RubyJobBuilder createUserScriptRubyJob (const openstudio::path &t_userScriptPath, const std::vector< ruleset::OSArgument > &t_args, const openstudio::path &t_relativeTo=openstudio::path(), bool t_copyFileTrue=false)
 
static ScriptInfo refreshArgumentsFromScript (runmanager::RunManager &t_rm, runmanager::ScriptInfo t_scriptInfo)
 
static ScriptInfo saveArgumentsToDb (runmanager::ScriptInfo t_scriptInfo)
 
static JobParams toJobParams (const std::vector< ruleset::OSArgument > &t_args, const openstudio::path &t_basePath=openstudio::path())
 
static std::vector
< ruleset::OSArgument > 
toOSArguments (const JobParams &t_params, const openstudio::path &t_basePath=openstudio::path())
 
static ScriptInfo updateArgumentsFromDb (runmanager::ScriptInfo t_scriptInfo)
 

Detailed Description

Utilities class for encoding and decoding the JobParams object needed for executing a RubyJob.

Example:

// make a new ruby job
rubyJobBuilder.setScriptFile(perturbScript);
rubyJobBuilder.addScriptParameter("inputPath", "5ZoneWarmest.idf");
rubyJobBuilder.addScriptParameter("outputPath", "out.idf");
rubyJobBuilder.addScriptParameter("objectType", "Building");
rubyJobBuilder.addScriptParameter("nameRegex", ".*");
rubyJobBuilder.addScriptParameter("field", "0");
rubyJobBuilder.addScriptParameter("value", "My Building");
".*\\.idf",
"5ZoneWarmest.idf");
rubyJobBuilder.addToolArgument("-I" + rubyOpenStudioDir()) ;
// create a dummy workflow and add ruby job
rubyJobBuilder.addToWorkflow(wf);

Constructor & Destructor Documentation

openstudio::runmanager::RubyJobBuilder::RubyJobBuilder ( bool  t_userScriptJob = false)
openstudio::runmanager::RubyJobBuilder::RubyJobBuilder ( const openstudio::path &  t_json)

Construct a RubyJobBuilder from a json file.

openstudio::runmanager::RubyJobBuilder::RubyJobBuilder ( const JobParams t_params)

Construct a RubyJobBuilder from an existing set of JobParams (useful when loading from the database).

openstudio::runmanager::RubyJobBuilder::RubyJobBuilder ( const WorkItem t_workItem)

Create from the workflow WorkItem.

openstudio::runmanager::RubyJobBuilder::RubyJobBuilder ( const WorkItem t_workItem,
const openstudio::path &  t_originalBasePath,
const openstudio::path &  t_newBasePath 
)

Create from the workflow WorkItem.

openstudio::runmanager::RubyJobBuilder::RubyJobBuilder ( const openstudio::BCLMeasure &  t_measure,
const std::vector< ruleset::OSArgument > &  t_args = std::vector< ruleset::OSArgument >(),
const openstudio::path &  t_relativeTo = openstudio::path(),
bool  t_copyFileTrue = false 
)

Create from a BCLMeasure by: Setting scriptFile to t_measure.primaryRubyScriptPath() Calling addRequiredFile for each t_measure.files() Calling addInputFile for appropriate t_measure.inputFileType() Calling copyRequiredFiles for t_measure.inputFileType to t_measure.outputFileType()

openstudio::runmanager::RubyJobBuilder::RubyJobBuilder ( const openstudio::BCLMeasure &  t_measure,
const std::map< std::string, ruleset::OSArgument > &  t_args,
const openstudio::path &  t_relativeTo = openstudio::path(),
bool  t_copyFileTrue = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Function Documentation

void openstudio::runmanager::RubyJobBuilder::addInputFile ( const FileSelection t_fileselection,
const FileSource t_filesource,
const std::string &  t_inputregex,
const std::string &  t_outputname 
)

Adds an input file from the Job defined list of input FileInfo objects that should be added as a requirement to this.

static void openstudio::runmanager::RubyJobBuilder::addJobsToWorkflow ( Workflow t_workflow,
const std::vector< RubyJobBuilder > &  t_jobs,
const openstudio::path &  t_includePath,
const std::vector< openstudio::path > &  t_requiredFiles 
)
static
bool openstudio::runmanager::RubyJobBuilder::addRequiredFile ( const openstudio::path &  currentPath,
const openstudio::path &  copyPath,
const openstudio::path &  relativeTo = openstudio::path(),
bool  verifyExistence = true 
)
void openstudio::runmanager::RubyJobBuilder::addScriptArgument ( const std::string &  name)

Adds an argument with no "--" prefix to the ruby script that is executed.

void openstudio::runmanager::RubyJobBuilder::addScriptParameter ( const std::string &  name,
const std::string &  value 
)

Adds a parameter to be passed to the ruby script that is executed.

void openstudio::runmanager::RubyJobBuilder::addScriptParameter ( const std::string &  name)

Adds a valueless parameter to be passed to the ruby script that is executed.

void openstudio::runmanager::RubyJobBuilder::addToolArgument ( const std::string &  name)

Sets a parameter to pass to the ruby interpreter itself.

void openstudio::runmanager::RubyJobBuilder::addToWorkflow ( Workflow t_wf,
const std::vector< openstudio::path > &  t_requiredFiles = std::vector< openstudio::path >() 
) const

Adds the Ruby job as it is currently defined to the given workflow.

Parameters
[in]t_wfWorkflow
[in]t_requiredFilesSet of files to add as required files to the script file
Deprecated:
See also
toWorkItem
boost::optional<openstudio::UUID> openstudio::runmanager::RubyJobBuilder::bclMeasureUUID ( ) const
void openstudio::runmanager::RubyJobBuilder::clearIncludeDir ( )

Clears any -I parameters currently set to be sent to the ruby script interpreter.

void openstudio::runmanager::RubyJobBuilder::copyRequiredFiles ( const std::string &  t_infileextension,
const std::string &  t_outextension,
const std::string &  t_requiredFilename 
)

Specifies that the "requiredFiles" from an input file with given extension (t_infileextension) to all generated output files with the matching extension (t_outextension) if the requiredFile matches the given filename (t_requiredFilename)

std::vector<std::tuple<std::string, std::string, std::string> > openstudio::runmanager::RubyJobBuilder::copyRequiredFiles ( ) const

Returns the collection of required files to copy for this job.

static std::vector<RubyJobBuilder> openstudio::runmanager::RubyJobBuilder::createRubyJobsFromFolder ( const openstudio::path &  t_path,
const std::vector< std::pair< openstudio::path, std::vector< ruleset::OSArgument > > > &  t_userScripts,
const std::string &  t_inputExtension,
const openstudio::path &  t_relativeTo = openstudio::path(),
bool  t_copyFileTrue = false 
)
static
static RubyJobBuilder openstudio::runmanager::RubyJobBuilder::createUserScriptRubyJob ( const openstudio::path &  t_userScriptPath,
const std::vector< ruleset::OSArgument > &  t_args,
const openstudio::path &  t_relativeTo = openstudio::path(),
bool  t_copyFileTrue = false 
)
static
std::vector<std::string> openstudio::runmanager::RubyJobBuilder::getScriptParameters ( ) const

Returns the script parameters defined.

See also
addScriptParameter
addscriptArgument
std::vector<std::string> openstudio::runmanager::RubyJobBuilder::getToolParameters ( ) const

Returns the tool parameters defined.

See also
addToolArguement
std::vector<std::tuple<FileSelection, FileSource, std::string, std::string> > openstudio::runmanager::RubyJobBuilder::inputFiles ( ) const

Returns the collection of input files specified for this job.

const std::vector<RubyJobBuilder>& openstudio::runmanager::RubyJobBuilder::mergedJobs ( ) const
boost::optional<openstudio::UUID> openstudio::runmanager::RubyJobBuilder::originalUUID ( ) const
static ScriptInfo openstudio::runmanager::RubyJobBuilder::refreshArgumentsFromScript ( runmanager::RunManager t_rm,
runmanager::ScriptInfo  t_scriptInfo 
)
static
std::vector< std::pair<openstudio::path, openstudio::path> > openstudio::runmanager::RubyJobBuilder::requiredFiles ( ) const
static ScriptInfo openstudio::runmanager::RubyJobBuilder::saveArgumentsToDb ( runmanager::ScriptInfo  t_scriptInfo)
static
openstudio::path openstudio::runmanager::RubyJobBuilder::script ( ) const
void openstudio::runmanager::RubyJobBuilder::setIncludeDir ( const openstudio::path &  value)

Sets the -I include dir that is passed to the ruby script interpreter during execution.

void openstudio::runmanager::RubyJobBuilder::setScriptFile ( const openstudio::path &  t_script)

Sets the name of the ruby script file to execute.

static JobParams openstudio::runmanager::RubyJobBuilder::toJobParams ( const std::vector< ruleset::OSArgument > &  t_args,
const openstudio::path &  t_basePath = openstudio::path() 
)
static
static std::vector<ruleset::OSArgument> openstudio::runmanager::RubyJobBuilder::toOSArguments ( const JobParams t_params,
const openstudio::path &  t_basePath = openstudio::path() 
)
static
JobParams openstudio::runmanager::RubyJobBuilder::toParams ( ) const

Returns the set of JobParams defined by this object currently.

WorkItem openstudio::runmanager::RubyJobBuilder::toWorkItem ( const std::vector< openstudio::path > &  t_requiredFiles = std::vector< openstudio::path >()) const

Create a WorkItem representing this RubyScriptJob.

static ScriptInfo openstudio::runmanager::RubyJobBuilder::updateArgumentsFromDb ( runmanager::ScriptInfo  t_scriptInfo)
static
bool openstudio::runmanager::RubyJobBuilder::userScriptJob ( ) const