Write info about a job run by this `Link` to the job archive
420207
def _archive_self(self, logfile, key=JobDetails.topkey, status=JobStatus.unknown):
        """"""
        self._register_self(logfile, key, status)
        if self._job_archive is None:
            return
        self._job_archive.register_jobs(self.get_jobs())
560788
def writeWorkerDebug(debugStats, queueLength, path_suffix=""):
    """"""
    createDirectory(path_suffix)
    origin_prefix = "origin-" if scoop.IS_ORIGIN else ""
    statsFilename = os.path.join(
        getDebugDirectory(),
        path_suffix,
        "{1}worker-{0}-STATS".format(getDebugIdentifier(), origin_prefix)
    )
    lengthFilename = os.path.join(
        getDebugDirectory(),
        path_suffix,
        "{1}worker-{0}-QUEUE".format(getDebugIdentifier(), origin_prefix)
    )
    with open(statsFilename, 'wb') as f:
        pickle.dump(debugStats, f)
    with open(lengthFilename, 'wb') as f:
        pickle.dump(queueLength, f)
664315
def submit_job(job_ini, username, hazard_job_id=None):
    
    job_id = logs.init('job')
    oq = engine.job_from_file(
        job_ini, job_id, username, hazard_calculation_id=hazard_job_id)
    pik = pickle.dumps(oq, protocol=0)  # human readable protocol
    code = RUNCALC % dict(job_id=job_id, hazard_job_id=hazard_job_id, pik=pik,
                          username=username)
    tmp_py = gettemp(code, suffix='.py')
    # print(code, tmp_py)  # useful when debugging
    devnull = subprocess.DEVNULL
    popen = subprocess.Popen([sys.executable, tmp_py],
                             stdin=devnull, stdout=devnull, stderr=devnull)
    threading.Thread(target=popen.wait).start()
    logs.dbcmd('update_job', job_id, {'pid': popen.pid})
    return job_id, popen.pid
865847
def process_job(job, options = {}, report_email = nil, postback_url = nil, binary_key = nil)
      data = options
      data['job'] = job
      if !report_email.nil?
        data['report_email'] = report_email
      end

      if !postback_url.nil?
        data['postback_url'] = postback_url
      end
      api_post(:job, data, binary_key)
    end
401438
def rq_link(self):
        """"""
        if self.rq_job:
            url = reverse('rq_job_detail',
                          kwargs={'job_id': self.rq_id, 'queue_index': queue_index_by_name(self.rq_origin)})
            return '<a href="{}">{}</a>'.format(url, self.rq_id)
694571
def insert_source_info(result):
    """"""
    comment = result.get("comment")
    # don't change comment if it already exists
    if comment:
        return

    source = result.get("source")
    job_name = result.get("job_name")
    run = result.get("run")
    source_list = [source, job_name, run]
    if not all(source_list):
        return

    source_note = "/".join(source_list)
    source_note = "Source: {}".format(source_note)
    result["comment"] = source_note
113761
def WriteCronJobRun(self, run_object):
    """"""
    if run_object.cron_job_id not in self.cronjobs:
      raise db.UnknownCronJobError("Job with id %s not found." %
                                   run_object.cron_job_id)

    clone = run_object.Copy()
    clone.timestamp = rdfvalue.RDFDatetime.Now()
    self.cronjob_runs[(clone.cron_job_id, clone.run_id)] = clone
76569
def _link(self, next_worker, next_is_first=False):
        """"""

        lock = multiprocessing.Lock()
        next_worker._lock_prev_input = lock
        self._lock_next_input = lock
        lock.acquire()

        lock = multiprocessing.Lock()
        next_worker._lock_prev_output = lock
        self._lock_next_output = lock
        lock.acquire()

        # If the next worker is the first one, trigger it now.
        if next_is_first:
            self._lock_next_input.release()
            self._lock_next_output.release()
579348
def write_job(self,fh):
    
    if isinstance(self.job(),CondorDAGManJob):
      # create an external subdag from this dag
      fh.write( ' '.join(
        ['SUBDAG EXTERNAL', self.__name, self.__job.get_sub_file()]) )
      if self.job().get_dag_directory():
        fh.write( ' DIR ' + self.job().get_dag_directory() )
    else:
      # write a regular condor job
      fh.write( 'JOB ' + self.__name + ' ' + self.__job.get_sub_file() )
    fh.write( '\n')

    fh.write( 'RETRY ' + self.__name + ' ' + str(self.__retry) + '\n' )
331127
def write_output(job_id, content, conn=None):
    
    output_job = get_job_by_id(job_id, conn)
    results = {}
    if output_job is not None:
        entry = {
            OUTPUTJOB_FIELD: output_job,
            CONTENT_FIELD: content
        }
        results = RBO.insert(entry, conflict=RDB_REPLACE).run(conn)
    return results
100556
def get_details(cls, node, as_model=False):
        
        rest_job = RestJob(
            process_name=node.process_name,
            timeperiod=node.timeperiod,
            time_qualifier=node.time_qualifier,
            number_of_children=len(node.children),
            number_of_failures='NA' if not node.job_record else node.job_record.number_of_failures,
            state='NA' if not node.job_record else node.job_record.state,
            event_log=[] if not node.job_record else node.job_record.event_log)

        if as_model:
            return rest_job
        else:
            return rest_job.document
1041760
def WriteCronJobRun(self, run_object, cursor=None):
    """"""
    query = ("INSERT INTO cron_job_runs "
             "(job_id, run_id, write_time, run) "
             "VALUES (%s, %s, FROM_UNIXTIME(%s), %s) "
             "ON DUPLICATE KEY UPDATE "
             "run=VALUES(run), write_time=VALUES(write_time)")

    write_time_str = mysql_utils.RDFDatetimeToTimestamp(
        rdfvalue.RDFDatetime.Now())
    try:
      cursor.execute(query, [
          run_object.cron_job_id,
          db_utils.CronJobRunIDToInt(run_object.run_id),
          write_time_str,
          run_object.SerializeToString(),
      ])
    except MySQLdb.IntegrityError as e:
      raise db.UnknownCronJobError(
          "CronJob with id %s not found." % run_object.cron_job_id, cause=e)
1117250
private void insertJobMetadata() {
    final String baseURL = this.azkabanProps.get(AZKABAN_WEBSERVER_URL);
    if (baseURL != null) {
      final String flowName = this.node.getParentFlow().getFlowId();
      final String projectName = this.node.getParentFlow().getProjectName();

      this.props.put(CommonJobProperties.AZKABAN_URL, baseURL);
      this.props.put(CommonJobProperties.EXECUTION_LINK,
          String.format("%s/executor?execid=%d", baseURL, this.executionId));
      this.props.put(CommonJobProperties.JOBEXEC_LINK, String.format(
          "%s/executor?execid=%d&job=%s", baseURL, this.executionId, this.node.getNestedId()));
      this.props.put(CommonJobProperties.ATTEMPT_LINK, String.format(
          "%s/executor?execid=%d&job=%s&attempt=%d", baseURL, this.executionId,
          this.node.getNestedId(), this.node.getAttempt()));
      this.props.put(CommonJobProperties.WORKFLOW_LINK, String.format(
          "%s/manager?project=%s&flow=%s", baseURL, projectName, flowName));
      this.props.put(CommonJobProperties.JOB_LINK, String.format(
          "%s/manager?project=%s&flow=%s&job=%s", baseURL, projectName,
          flowName, this.jobId));
    } else {
      if (this.logger != null) {
        this.logger.info(AZKABAN_WEBSERVER_URL + " property was not set");
      }
    }
    // out nodes
    this.props.put(CommonJobProperties.OUT_NODES,
        StringUtils.join2(this.node.getOutNodes(), ","));

    // in nodes
    this.props.put(CommonJobProperties.IN_NODES,
        StringUtils.join2(this.node.getInNodes(), ","));
  }
769474
def archive(self):
        
        ids = self.rpc_model.search(self.domain, context=self.context)
        if ids:
            self.rpc_model.write(ids, {'active': False})
466474
def check_job(cls, job_details):
        
        return check_log(job_details.logfile, cls.string_exited, cls.string_successful)
1022589
def job(self, job_id):
        
        path = '/ws/v1/history/mapreduce/jobs/{jobid}'.format(jobid=job_id)

        return self.request(path)
272784
def get_details(self, jobname, jobkey):
        """"""
        fullkey = JobDetails.make_fullkey(jobname, jobkey)
        return self._cache[fullkey]