Creates a job template
346498
def create_job_template(self, template):
        
        endpoint = self._build_url('jobTemplates')
        data = self._query_api('POST',
                               endpoint,
                               None,
                               {'Content-Type': 'application/json'},
                               json.dumps(template))
        return data['results']
920584
def _make_qheader(self, job_name, qout_path, qerr_path):
        """"""
        # get substitution dict for replacements into the template
        subs_dict = self.get_subs_dict()

        # Set job_name and the names for the stderr and stdout of the
        # queue manager (note the use of the extensions .qout and .qerr
        # so that we can easily locate this file.
        subs_dict['job_name'] = job_name.replace('/', '_')
        subs_dict['_qout_path'] = qout_path
        subs_dict['_qerr_path'] = qerr_path

        qtemplate = QScriptTemplate(self.QTEMPLATE)
        # might contain unused parameters as leftover $$.
        unclean_template = qtemplate.safe_substitute(subs_dict)

        # Remove lines with leftover $$.
        clean_template = []
        for line in unclean_template.split('\n'):
            if '$$' not in line:
                clean_template.append(line)

        return '\n'.join(clean_template)
1071142
protected String formatTemplate(String template,FaxJob faxJob)
    {
        return SpiUtil.formatTemplate(template,faxJob,null,false,true);
    }
307467
def build_task_template
      b = binding
      ERB.new(Woro::TaskHelper.read_template_file).result(b)
    end
1065217
function (jobName, customParams, callback) {
      [jobName, customParams, callback] = doArgs(arguments, ['string', ['object', {}], 'function']);

      doRequest({
        urlPattern: [JOB_INFO, jobName]
      }, customParams, callback);
    }
992365
def create_job(self, process_name, timeperiod):
        
        job_record = Job()
        job_record.state = job.STATE_EMBRYO
        job_record.timeperiod = timeperiod
        job_record.process_name = process_name
        self.job_dao.update(job_record)

        self.logger.info('Created Job {0} for {1}@{2}'
                         .format(job_record.db_id, job_record.process_name, job_record.timeperiod))
        return job_record
1253540
def _createJobStateFile(self):
        
        jobStateFile = os.path.join(self.localTempDir, '.jobState')
        jobState = {'jobPID': os.getpid(),
                    'jobName': self.jobName,
                    'jobDir': self.localTempDir,
                    'deferredFunctions': []}
        with open(jobStateFile + '.tmp', 'wb') as fH:
            dill.dump(jobState, fH)
        os.rename(jobStateFile + '.tmp', jobStateFile)
        return jobStateFile
71854
def job(name, **kwargs):
    ''''''
    return task(name=name, schedulable=True, base=JobTask,
                bind=True, **kwargs)
473629
def _create_job(self, func, args=None, kwargs=None, commit=True,
                    result_ttl=None, ttl=None, id=None, description=None,
                    queue_name=None, timeout=None, meta=None):
        
        if args is None:
            args = ()
        if kwargs is None:
            kwargs = {}
        job = self.job_class.create(
                func, args=args, connection=self.connection,
                kwargs=kwargs, result_ttl=result_ttl, ttl=ttl, id=id,
                description=description, timeout=timeout, meta=meta)
        if self._queue is not None:
            job.origin = self._queue.name
        else:
            job.origin = queue_name or self.queue_name
        if commit:
            job.save()
        return job
693158
protected function _prepareForm()
    {
        $job = $this->getJob();
        $form = new Varien_Data_Form(
            array(
                'id'     => 'edit_form',
                'action' => $this->getData('action'),
                'method' => 'post'
            )
        );

        $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('General')));
        $this->_addElementTypes($fieldset);

        $fieldset->addField(
            'job_code',
            'text',
            array(
                'name'     => 'job_code',
                'label'    => $this->__('Job code'),
                'title'    => $this->__('Job code'),
                'class'    => '',
                'required' => true,
                'disabled' => $job->getJobCode() ? true : false,
            )
        );

        $fieldset->addField(
            'name',
            'text',
            array(
                'name'               => 'name',
                'label'              => $this->__('Name'),
                'title'              => $this->__('Name'),
                'class'              => '',
                'required'           => false,
                'after_element_html' => $this->getOriginalValueSnippet($job, 'name'),
            )
        );

        $fieldset->addField(
            'short_description',
            'textarea',
            array(
                'name'               => 'short_description',
                'label'              => $this->__('Short description'),
                'title'              => $this->__('Short description'),
                'class'              => '',
                'required'           => false,
                'after_element_html' => $this->getOriginalValueSnippet($job, 'short_description'),
            )
        );

        $fieldset->addField(
            'description',
            'textarea',
            array(
                'name'               => 'description',
                'label'              => $this->__('Description'),
                'title'              => $this->__('Description'),
                'class'              => '',
                'required'           => false,
                'after_element_html' => $this->getOriginalValueSnippet($job, 'description'),
            )
        );

        $fieldset->addField(
            'run_model',
            'text',
            array(
                'name'               => 'run_model',
                'label'              => $this->__('Run model'),
                'title'              => $this->__('Run model'),
                'class'              => '',
                'required'           => true,
                'note'               => $this->__('e.g. "aoe_scheduler/task_heartbeat::run"'),
                'after_element_html' => $this->getOriginalValueSnippet($job, 'run/model'),
            )
        );

        $fieldset->addField(
            'is_active',
            'select',
            array(
                'name'               => 'is_active',
                'label'              => $this->__('Status'),
                'title'              => $this->__('Status'),
                'required'           => true,
                'options'            => array(
                    0 => $this->__('Disabled'),
                    1 => $this->__('Enabled')
                ),
                'after_element_html' => $this->getOriginalValueSnippetFlag($job, 'is_active', 'Enabled', 'Disabled'),
            )
        );

        $fieldset = $form->addFieldset('cron_fieldset', array('legend' => $this->__('Scheduling')));
        $this->_addElementTypes($fieldset);

        $fieldset->addField(
            'schedule_config_path',
            'text',
            array(
                'name'               => 'schedule_config_path',
                'label'              => $this->__('Cron configuration path'),
                'title'              => $this->__('Cron configuration path'),
                'class'              => '',
                'required'           => false,
                'note'               => $this->__(
                    'Path to system configuration containing the cron configuration for this job. (e.g. system/cron/scheduler_cron_expr_heartbeat) This configuration - if set - has a higher priority over the cron expression configured with the job directly.'
                ),
                'after_element_html' => $this->getOriginalValueSnippet($job, 'schedule/config_path'),
            )
        );

        $fieldset->addField(
            'schedule_cron_expr',
            'text',
            array(
                'name'               => 'schedule_cron_expr',
                'label'              => $this->__('Cron expression'),
                'title'              => $this->__('Cron expression'),
                'required'           => false,
                'note'               => $this->__('e.g "*/5 * * * *" or "always"'),
                'after_element_html' => $this->getOriginalValueSnippet($job, 'schedule/cron_expr'),
            )
        );

        $fieldset = $form->addFieldset('parameter_fieldset', array('legend' => $this->__('Extras')));
        $this->_addElementTypes($fieldset);

        $fieldset->addField(
            'parameters',
            'textarea',
            array(
                'name'               => 'parameters',
                'label'              => $this->__('Parameters'),
                'title'              => $this->__('Parameters'),
                'class'              => 'textarea',
                'required'           => false,
                'note'               => $this->__('These parameters will be passed to the model. It is up to the model to specify the format of these parameters (e.g. json/xml/...'),
                'after_element_html' => $this->getOriginalValueSnippet($job, 'parameters'),
            )
        );

        $fieldset->addField(
            'groups',
            'textarea',
            array(
                'name'               => 'groups',
                'label'              => $this->__('Groups'),
                'title'              => $this->__('Groups'),
                'class'              => 'textarea',
                'required'           => false,
                'note'               => $this->__('Comma-separated list of groups (tags) that can be used with the include/exclude command line options of scheduler.php'),
                'after_element_html' => $this->getOriginalValueSnippet($job, 'groups'),
            )
        );

        $fieldset = $form->addFieldset('dependency_fieldset', array('legend' => $this->__('Dependencies')));
        $this->_addElementTypes($fieldset);

        $fieldset->addField(
            'on_success',
            'textarea',
            array(
                'name'               => 'on_success',
                'label'              => $this->__('Run jobs on success'),
                'title'              => $this->__('Run jobs on success'),
                'class'              => 'textarea',
                'required'           => false,
                'note'               => $this->__('Comma-separated list of job codes that will be scheduled after the current cron job has completed successfully.')
            )
        );

        $this->setForm($form);

        return parent::_prepareForm();
    }
380356
def create_template(self):
        """"""
        template = self.template
        # variables = self.get_variables()
        template.add_version('2010-09-09')
        template.add_description('Static Website - Dependencies')

        # Resources
        awslogbucket = template.add_resource(
            s3.Bucket(
                'AWSLogBucket',
                AccessControl=s3.Private,
                VersioningConfiguration=s3.VersioningConfiguration(
                    Status='Enabled'
                )
            )
        )
        template.add_output(Output(
            'AWSLogBucketName',
            Description='Name of bucket storing AWS logs',
            Value=awslogbucket.ref()
        ))

        template.add_resource(
            s3.BucketPolicy(
                'AllowAWSLogWriting',
                Bucket=awslogbucket.ref(),
                PolicyDocument=Policy(
                    Version='2012-10-17',
                    Statement=[
                        Statement(
                            Action=[awacs.s3.PutObject],
                            Effect=Allow,
                            Principal=AWSPrincipal(Join(':',
                                                        ['arn:aws:iam:',
                                                         AccountId,
                                                         'root'])),
                            Resource=[
                                Join('', ['arn:aws:s3:::',
                                          awslogbucket.ref(),
                                          '/*'])
                            ]
                        )
                    ]
                )
            )
        )
        artifacts = template.add_resource(
            s3.Bucket(
                'Artifacts',
                AccessControl=s3.Private,
                LifecycleConfiguration=s3.LifecycleConfiguration(
                    Rules=[
                        s3.LifecycleRule(
                            NoncurrentVersionExpirationInDays=90,
                            Status='Enabled'
                        )
                    ]
                ),
                VersioningConfiguration=s3.VersioningConfiguration(
                    Status='Enabled'
                )
            )
        )
        template.add_output(Output(
            'ArtifactsBucketName',
            Description='Name of bucket storing artifacts',
            Value=artifacts.ref()
        ))
1186306
def create_or_update_job(job, opts = {})
      data, _status_code, _headers = create_or_update_job_with_http_info(job, opts)
      return data
    end
1300429
def _format_job_instance(job):
    '''
    
    '''
    if not job:
        ret = {'Error': 'Cannot contact returner or no job with this jid'}
        return ret

    ret = {'Function': job.get('fun', 'unknown-function'),
           'Arguments': list(job.get('arg', [])),
           # unlikely but safeguard from invalid returns
           'Target': job.get('tgt', 'unknown-target'),
           'Target-type': job.get('tgt_type', 'list'),
           'User': job.get('user', 'root')}

    if 'metadata' in job:
        ret['Metadata'] = job.get('metadata', {})
    else:
        if 'kwargs' in job:
            if 'metadata' in job['kwargs']:
                ret['Metadata'] = job['kwargs'].get('metadata', {})

    if 'Minions' in job:
        ret['Minions'] = job['Minions']
    return ret
306756
def get_template_file(args):
    """"""
    if args.template is None:
        template_filename  = os.getenv("HOME") + "/.mvmany.template"
        try:
            template_filename = open(template_filename, "r")
        except:
            with open(template_filename, "w") as file:
                print >> file, """#SBATCH --job-name=$jobname
#SBATCH --nodes=1
#SBATCH --tasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=$memory
#SBATCH --time=$walltime
#SBATCH --error $logpath/$jobname.e
#SBATCH --output $respath/$jobname.txt

cd $pwd

$body
    """
            print >> sys.stderr, """PLEASE NOTE: \n
A default template file, %s, has been created. You are encouraged to configure it according to work with your cluster
management software or personalize it with email notifications, etc.\n"""
            template_filename = open(template_filename, "r")

    return template_filename
87452
def generate_template(template_name, **context):
    """"""
    context.update(href=href, format_datetime=format_datetime)
    return template_loader.load(template_name).generate(**context)
561204
def create_project_file
      template = TemplatePage.new(RDoc::Page::HPP_FILE)
      values = { "title" => @options.title, "opname" => @op_name }
      files = []
      @files.each do |f|
	files << { "html_file_name" => f.path }
      end

      values['all_html_files'] = files
      
      File.open(@project_name, "w") do |f|
        template.write_html_on(f, values)
      end
    end
717718
def _create_job(self, mapping):
        """"""
        job_id = self.bulk.create_insert_job(mapping["sf_object"], contentType="CSV")
        self.logger.info("  Created bulk job {}".format(job_id))

        # Upload batches
        local_ids_for_batch = {}
        for batch_file, local_ids in self._get_batches(mapping):
            batch_id = self.bulk.post_batch(job_id, batch_file)
            local_ids_for_batch[batch_id] = local_ids
            self.logger.info("    Uploaded batch {}".format(batch_id))

        self.bulk.close_job(job_id)
        return job_id, local_ids_for_batch