Class defining a single job
Note - in the moa system, there can be only one current job - many operations try to access the job in sysConf
>>> wd = tempfile.mkdtemp()
>>> job = Job(wd)
>>> assert(isinstance(job, Job))
>>> assert(job.template.name == 'nojob')
Check command, and rearrange if there are delegates.
>>> job = newTestJob('unittest')
>>> assert(job.template.commands.run.delegate == ['prepare', 'run2'])
>>> assert(job.checkCommands('run2') == ['run2'])
>>> assert(job.checkCommands('run') == ['prepare', 'run2'])
>>> assert(job.checkCommands('prepare') == ['prepare'])
Parameters: | commands (list of strings) – The list of commands to check |
---|---|
Returns: | The checked list of commands |
Return type: | list of strings |
Check if the configuration directory exists. If not create it.
>>> job = newTestJob('unittest')
>>> confdir = os.path.join(job.wd, '.moa')
>>> assert(os.path.exists(confdir))
>>> import shutil
>>> shutil.rmtree(confdir)
>>> assert(os.path.exists(confdir) == False)
>>> job.checkConfDir()
>>> assert(os.path.exists(confdir))
Register template commands with the argparser
Set command line options - deferred to the backend - PER COMMAND
>>> job = newTestJob('unittest')
>>> import optparse
>>> parser = optparse.OptionParser()
>>> job.defineOptions(parser)
Execute command in the context of this job. Execution is alwasy deferred to the backend
#Note: Uncertain how to test verbose & silent
Parameters: |
|
---|
Finish the run!
Return all moa files - i.e. all files crucial to this job.
Check if this job defines a certain command
Warning
THIS METHOD DOES NOT WORK PROPERLY YET
>>> job = newTestJob('unittest')
>>> assert(job.hasCommand('run'))
>>> assert(not job.hasCommand('dummy'))
Initialize a new job in the current wd
Check if this is a Moa directory - Currently, this needs to be overridden #weird; uncertain if this ever gets called
load the backend
Load the template for this job, based on what configuration can be found
Load the template meta data for this job, based on what configuration can be found
Give this job a chance to prepare for execution.
Reload the template into the local .moa/template.d directory
>>> job = newTestJob('unittest')
>>> templateFile = os.path.join(job.confDir, 'template.d', 'unittest.jinja2')
>>> assert(os.path.exists(templateFile))
>>> os.unlink(templateFile)
>>> assert(not os.path.exists(templateFile))
>>> job.refreshTemplate()
>>> assert(os.path.exists(templateFile))
Shortcut to run a job plugin hook
Set a new template for this job
>>> job = newTestJob('unittest')
>>> job.setTemplate('adhoc')
>>> afile = os.path.join(job.confDir, 'template.d', 'adhoc.mk')
>>> assert(os.path.exists(afile))
Create a new job in the wd and return the proper job object currently only makefile jobs are supported - later we’ll scan the template, and instantiate the proper job type
>>> wd = tempfile.mkdtemp()
>>> job = newJob(wd, template='blast', title='test')
>>> assert(isinstance(job, Job))
>>> assert(job.template.name == 'blast')
>>> assert(job.conf.title == 'test')
Parameters: |
|
---|---|
Return type: | instance of moa.job.Job |
for testing purposes - creates a temporary directory and uses that to instantiate a job. This function returns the job object created
>>> job = newTestJob(template = 'adhoc', title='test title')
>>> assert(isinstance(job, Job))
>>> assert(os.path.exists(job.wd))
>>> assert(job.conf.title == 'test title')
>>> assert(os.path.exists(os.path.join(job.wd, '.moa')))
>>> assert(os.path.exists(os.path.join(job.wd, '.moa', 'template')))
>>> assert(job.template.name == 'adhoc')
Returns: | the created job |
---|---|
Return type: | instance of moa.job.Job |