Given a template, a job class, construct jobs from
        the given template.
342610
def _get_jobs_from_template(self, template, job_class):
        
        jobs = []
        for command in template.eval():
            alias = command.alias
            depends_on = [job.alias
                for job in self.queue.all_jobs
                    for deps in command.depends_on
                        if deps == job.alias]
            command.update_dependent_files([job.command
                for job in self.queue.all_jobs
                    if not isinstance(job, JobTemplate)])

            job = job_class(alias, command, depends_on)
            jobs.append(job)
        return jobs
488513
def process_templates(input_dir, target_dir, context):
    
    if not target_dir.endswith('/'):
        target_dir = "{}/".format(target_dir)
    if not os.path.exists(target_dir):
        LOGGER.info('Creating: {}'.format(target_dir))
        os.makedirs(target_dir)
    replicate_directory_tree(input_dir, target_dir)
    templates = find_templates(input_dir)
    for templ in templates:
        output_file = templ.replace(input_dir, target_dir)
        output_file = output_file[:-len('.mustache')]
        render_template(templ,  output_file, context)
1230931
def build_job_scripts(root_dir, jobs):
    
    # Loop over the job list, creating each job script in turn, and then adding
    # scriptPath to the Job object
    for job in jobs:
        scriptpath = os.path.join(root_dir, "jobs", job.name)
        with open(scriptpath, "w") as scriptfile:
            scriptfile.write("#!/bin/sh\n#$ -S /bin/bash\n%s\n" % job.script)
        job.scriptpath = scriptpath
838881
def from_node(cls, task):
        """"""
        new = super().from_node(task)

        new.update(
            executable=task.executable,
            #executable_version:
            #task_events=
            pseudos=[p.as_dict() for p in task.input.pseudos],
            #input=task.input
        )

        new.register_gridfs_files(
            run_abi=(task.input_file.path, "t"),
            run_abo=(task.output_file.path, "t"),
        )

        return new
362547
def build_from_template(file)
      context = @options[:context] || {}

      template = IO.read(file)
      eruby = Erubis::Eruby.new(template)
      string = eruby.evaluate(context)
      build_from_string(string, File.dirname(file))
    end
36893
def templates_in(path):
    """"""
    ext = '.cpp'
    return (
        Template(f[0:-len(ext)], load_file(os.path.join(path, f)))
        for f in os.listdir(path) if f.endswith(ext)
    )
199015
def getnjobs(self, key, **kwargs):
        

        return self.get(key, cast_func=parse_n_jobs, **kwargs)
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']
1123902
def create_job(self,
                   builder_job,    # type: Dict[Text, Any]
                   wf_job=None,    # type: Callable[[Dict[Text, Text], Callable[[Any, Any], Any], RuntimeContext], Generator[Any, None, None]]
                   is_output=False
                  ):  # type: (...) -> Dict
        #TODO customise the file
        """"""
        copied = copy.deepcopy(builder_job)
        relativised_input_objecttemp = {}  # type: Dict[Text, Any]
        self._relativise_files(copied)
        def jdefault(o):
            return dict(o)
        if is_output:
            rel_path = posixpath.join(_posix_path(WORKFLOW), "primary-output.json")
        else:
            rel_path = posixpath.join(_posix_path(WORKFLOW), "primary-job.json")
        j = json_dumps(copied, indent=4, ensure_ascii=False, default=jdefault)
        with self.write_bag_file(rel_path) as file_path:
            file_path.write(j + u"\n")
        _logger.debug(u"[provenance] Generated customised job file: %s",
                      rel_path)
        # Generate dictionary with keys as workflow level input IDs and values
        # as
        # 1) for files the relativised location containing hash
        # 2) for other attributes, the actual value.
        relativised_input_objecttemp = {}
        for key, value in copied.items():
            if isinstance(value, MutableMapping):
                if value.get("class") in ("File", "Directory"):
                    relativised_input_objecttemp[key] = value
            else:
                relativised_input_objecttemp[key] = value
        self.relativised_input_object.update(
            {k: v for k, v in relativised_input_objecttemp.items() if v})
        return self.relativised_input_object
305753
public static <J extends Job<J,R>, R extends Run<J,R>> RunList<R> fromJobs(Iterable<? extends J> jobs) {
        List<Iterable<R>> runLists = new ArrayList<>();
        for (Job j : jobs)
            runLists.add(j.getBuilds());
        return new RunList<>(combine(runLists));
    }
1291368
def build_single_worker(queue, templates, base_output_dir):
    """"""
    while True:
        scheme_file = queue.get()
        if scheme_file is None:
            break
        build_single(scheme_file, templates, base_output_dir)
        queue.task_done()
719080
public void setJobTemplates(java.util.Collection<JobTemplate> jobTemplates) {
        if (jobTemplates == null) {
            this.jobTemplates = null;
            return;
        }

        this.jobTemplates = new java.util.ArrayList<JobTemplate>(jobTemplates);
    }
32574
def generate_jobs(queue_servers, queue_template, queue_executable)
      counter = 0
      tasks = []
      Log.debug "[#{Chimp.get_job_uuid}] Loading queue..."
      #
      # Configure group
      #
      if not ChimpQueue[@group]
        ChimpQueue.instance.create_group(@group, @group_type, @group_concurrency)
      end

      #
      # Process Server selection
      #
      Log.debug("[#{Chimp.get_job_uuid}] Processing server selection for task creation")

      queue_servers.sort! { |a,b| a['name'] <=> b['name'] }
      queue_servers.each do |server|
        #
        # Handle limiting options
        #
        counter += 1
        next if @limit_start.to_i > 0 and counter < @limit_start.to_i
        break if @limit_end.to_i > 0 and counter > @limit_end.to_i

        #
        # Construct the Server object
        #
        s = Server.new

        s.params['href']                  = server['href']

        s.params['current_instance_href'] = s.params['href']
        s.params['current-instance-href'] = s.params['href']

        s.params['name']                  = server['name']
        s.params['nickname']              = s.params['name']

        s.params['ip_address']            = server['public_ip_addresses'].first
        s.params['ip-address']            = s.params['ip_address']

        s.params['private-ip-address']    = server['private_ip_addresses'].first
        s.params['private_ip_address']    = s.params['private-ip-address']

        s.params['resource_uid']          = server['resource_uid']
        s.params['resource-uid']          = s.params['resource_uid']

        s.params['instance-type']         = server['links']['instance_type']['name']
        s.params['instance_type']         = s.params['instance-type']
        s.params['ec2_instance_type']     = s.params['instance-type']
        s.params['ec2-instance-type']     = s.params['instance-type']

        s.params['dns-name']              = server['public_dns_names'].first
        s.params['dns_name']              = s.params['dns-name']

        s.params['locked']                = server['locked']
        s.params['state']                 = server['state']
        s.params['datacenter']            = server['links']['datacenter']['name']

        # This will be useful for later on when we need to run scripts
        Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.resource (SERVER) for task creation"
        begin
          tries ||= 3
          s.object = Connection.client.resource(server['href'])
          Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.resource (SERVER) for task creation COMPLETE"
        rescue
          Log.error "[#{Chimp.get_job_uuid}] Failed to load server href via API1.5 for task creation (retrying)"
          sleep 30
          retry unless (tries -= 1).zero?
          Log.error "[#{Chimp.get_job_uuid}] Failed to load server href via API1.5 for task creation (giving up)"
        end

        e = nil

        # If @script has been passed
        if queue_executable
          e = ExecRightScript.new(
            :server => s,
            :exec => queue_executable,
            :job_uuid => @job_uuid,
            :job_notes => @job_notes,
            :inputs => @inputs,
            :timeout => @timeout,
            :delay => @delay,
            :concurrency => @concurrency,
            :verbose => @@verbose,
            :quiet => @@quiet
          )
        elsif @ssh
          e = ExecSSH.new(
            :server => s,
            :ssh_user => @ssh_user,
            :exec => @ssh,
            :verbose => @@verbose,
            :quiet => @@quiet
          )
        elsif @report
          if s.href
            e = ExecReport.new(:server => s, :verbose => @@verbose, :quiet => @@quiet)
            e.fields = @report
          end
        elsif @set_tags.size > 0
          e = ExecSetTags.new(:server => s, :verbose => @@verbose, :quiet => @@quiet)
          e.tags = set_tags
        end

        if e != nil
          e.dry_run = @dry_run
          e.quiet   = @@quiet
          e.status  = Executor::STATUS_HOLDING if @hold

          Log.debug "[#{Chimp.get_job_uuid}] Pushing task (end of control)"
          tasks.push(e)
        end
      end
      return(tasks)
    end
59483
def substitute(template, mapping=None):
    
    if mapping is None:
        mapping = {}
    templ = Template(template)
    return templ.substitute(mapping)
562066
function createCompiled(bench, decompilable, deferred, body) {
        var fn = bench.fn,
            fnArg = deferred ? getFirstArgument(fn) || 'deferred' : '';

        templateData.uid = uid + uidCounter++;

        _.assign(templateData, {
          'setup': decompilable ? getSource(bench.setup) : interpolate('m#.setup()'),
          'fn': decompilable ? getSource(fn) : interpolate('m#.fn(' + fnArg + ')'),
          'fnArg': fnArg,
          'teardown': decompilable ? getSource(bench.teardown) : interpolate('m#.teardown()')
        });

        // Use API of chosen timer.
        if (timer.unit == 'ns') {
          _.assign(templateData, {
            'begin': interpolate('s#=n#()'),
            'end': interpolate('r#=n#(s#);r#=r#[0]+(r#[1]/1e9)')
          });
        }
        else if (timer.unit == 'us') {
          if (timer.ns.stop) {
            _.assign(templateData, {
              'begin': interpolate('s#=n#.start()'),
              'end': interpolate('r#=n#.microseconds()/1e6')
            });
          } else {
            _.assign(templateData, {
              'begin': interpolate('s#=n#()'),
              'end': interpolate('r#=(n#()-s#)/1e6')
            });
          }
        }
        else if (timer.ns.now) {
          _.assign(templateData, {
            'begin': interpolate('s#=n#.now()'),
            'end': interpolate('r#=(n#.now()-s#)/1e3')
          });
        }
        else {
          _.assign(templateData, {
            'begin': interpolate('s#=new n#().getTime()'),
            'end': interpolate('r#=(new n#().getTime()-s#)/1e3')
          });
        }
        // Define `timer` methods.
        timer.start = createFunction(
          interpolate('o#'),
          interpolate('var n#=this.ns,${begin};o#.elapsed=0;o#.timeStamp=s#')
        );

        timer.stop = createFunction(
          interpolate('o#'),
          interpolate('var n#=this.ns,s#=o#.timeStamp,${end};o#.elapsed=r#')
        );

        // Create compiled test.
        return createFunction(
          interpolate('window,t#'),
          'var global = window, clearTimeout = global.clearTimeout, setTimeout = global.setTimeout;\n' +
          interpolate(body)
        );
      }
768437
def _exec_template(callable_, context, args=None, kwargs=None):
    
    template = context._with_template
    if template is not None and \
            (template.format_exceptions or template.error_handler):
        try:
            callable_(context, *args, **kwargs)
        except Exception:
            _render_error(template, context, compat.exception_as())
        except:
            e = sys.exc_info()[0]
            _render_error(template, context, e)
    else:
        callable_(context, *args, **kwargs)
211223
private JobSpec convertHopToJobSpec (ServiceNode sourceNode, ServiceNode targetNode, FlowSpec flowSpec) {
    FlowEdge flowEdge = weightedGraph.getAllEdges(sourceNode, targetNode).iterator().next();
    URI templateURI = getTemplateURI (sourceNode, targetNode, flowSpec, flowEdge);
    return buildJobSpec(sourceNode, targetNode, templateURI, flowSpec);
  }