Create a JobNote, possibly via auto-classification.

        Create mappings from the given Job to Bugs via verified Classifications
        of this Job.

        Also creates a JobNote.
340692
def create_autoclassify_job_note(self, job, user=None):
        
        # Only insert bugs for verified failures since these are automatically
        # mirrored to ES and the mirroring can't be undone
        # TODO: Decide whether this should change now that we're no longer mirroring.
        bug_numbers = set(ClassifiedFailure.objects
                          .filter(best_for_errors__text_log_error__step__job=job,
                                  best_for_errors__best_is_verified=True)
                          .exclude(bug_number=None)
                          .exclude(bug_number=0)
                          .values_list('bug_number', flat=True))

        existing_maps = set(BugJobMap.objects.filter(bug_id__in=bug_numbers)
                                             .values_list('bug_id'))

        for bug_number in (bug_numbers - existing_maps):
            BugJobMap.objects.create(job_id=job.id, bug_id=bug_number, user=user)

        # if user is not specified, then this is an autoclassified job note and
        # we should mark it as such
        classification_name = 'intermittent' if user else 'autoclassified intermittent'
        classification = FailureClassification.objects.get(name=classification_name)

        return JobNote.objects.create(job=job,
                                      failure_classification=classification,
                                      user=user,
                                      text="")
149243
@Override
  public void addJob(final Job job) throws JobExistsException {
    log.info("adding job: {}", job);
    final JobId id = job.getId();
    final UUID operationId = UUID.randomUUID();
    final String creationPath = Paths.configJobCreation(id, operationId);
    final ZooKeeperClient client = provider.get("addJob");
    try {
      try {
        client.ensurePath(Paths.historyJob(id));
        client.transaction(create(Paths.configJob(id), job),
            create(Paths.configJobRefShort(id), id),
            create(Paths.configJobHosts(id)),
            create(creationPath),
            // Touch the jobs root node so that its version is bumped on every job
            // change down the tree. Effectively, make it that version == cVersion.
            set(Paths.configJobs(), UUID.randomUUID().toString().getBytes()));
      } catch (final NodeExistsException e) {
        if (client.exists(creationPath) != null) {
          // The job was created, we're done here
          return;
        }
        throw new JobExistsException(id.toString());
      }
    } catch (NoNodeException e) {
      throw new HeliosRuntimeException("adding job " + job + " failed due to missing ZK path: "
                                       + e.getPath(), e);
    } catch (final KeeperException e) {
      throw new HeliosRuntimeException("adding job " + job + " failed", e);
    }
  }
1152116
private ConcurrentHashMap<JobVertexID, TaskStateStats> createEmptyTaskStateStatsMap() {
		ConcurrentHashMap<JobVertexID, TaskStateStats> taskStatsMap = new ConcurrentHashMap<>(jobVertices.size());
		for (ExecutionJobVertex vertex : jobVertices) {
			TaskStateStats taskStats = new TaskStateStats(vertex.getJobVertexId(), vertex.getParallelism());
			taskStatsMap.put(vertex.getJobVertexId(), taskStats);
		}
		return taskStatsMap;
	}
385502
public static JobResult createFrom(AccessExecutionGraph accessExecutionGraph) {
		final JobID jobId = accessExecutionGraph.getJobID();
		final JobStatus jobStatus = accessExecutionGraph.getState();

		checkArgument(
			jobStatus.isGloballyTerminalState(),
			"The job " + accessExecutionGraph.getJobName() + '(' + jobId + ") is not in a globally " +
				"terminal state. It is in state " + jobStatus + '.');

		final JobResult.Builder builder = new JobResult.Builder();
		builder.jobId(jobId);

		builder.applicationStatus(ApplicationStatus.fromJobStatus(accessExecutionGraph.getState()));

		final long netRuntime = accessExecutionGraph.getStatusTimestamp(jobStatus) - accessExecutionGraph.getStatusTimestamp(JobStatus.CREATED);
		// guard against clock changes
		final long guardedNetRuntime = Math.max(netRuntime, 0L);
		builder.netRuntime(guardedNetRuntime);
		builder.accumulatorResults(accessExecutionGraph.getAccumulatorsSerialized());

		if (jobStatus != JobStatus.FINISHED) {
			final ErrorInfo errorInfo = accessExecutionGraph.getFailureInfo();

			if (errorInfo != null) {
				builder.serializedThrowable(errorInfo.getException());
			}
		}

		return builder.build();
	}
1036896
protected Job createJob() throws IOException {
    Job job = Job.getInstance(new Configuration());
    for (Map.Entry<Object, Object> entry : this.taskContext.getTaskState().getProperties().entrySet()) {
      if (entry.getKey() instanceof String && ((String) entry.getKey()).startsWith(JOB_CONFIGURATION_PREFIX)) {
        String actualKey = ((String) entry.getKey()).substring(JOB_CONFIGURATION_PREFIX.length());
        job.getConfiguration().set(actualKey, (String) entry.getValue());
      }
    }
    return job;
  }
15929
def insert_jobs(jobs, verify_jobs=True, conn=None):
    
    assert isinstance(jobs, list)
    if verify_jobs \
            and not verify({Jobs.DESCRIPTOR.name: jobs}, Jobs()):
        raise ValueError("Invalid Jobs")
    inserted = RBJ.insert(jobs).run(conn)
    return inserted
137675
def generate(self, job):
        

        options = job.get_options().copy()
        job_name = options.pop('name', None)
        job_account = options.pop('account', None)
        job_walltime = options.pop('walltime', None)
        job_mem_per_cpu = options.pop('mem_per_cpu', None)
        job_memory = options.pop('memory', None)
        job_working_directory = options.pop('working_directory', None)
        job_error_path = options.pop('error_path', None)
        job_output_path = options.pop('output_path', None)
        job_dependency = options.pop('depending', None)
        job_shell = options.pop('shell', '/bin/bash')
        job_custom_options = options.pop('__custom__', [])

        directives_lines = []

        if job_name is not None:
            directives_lines.append('--job-name=%s' % job_name)

        if job_account is not None:
            directives_lines.append('--account=%s' % job_account)

        if job_working_directory is not None:
            directives_lines.append('--workdir=%s' % job_working_directory)

        if job_error_path is not None:
            directives_lines.append('--error=%s' % job_error_path)

        if job_output_path is not None:
            directives_lines.append('--output=%s' % job_output_path)

        if job_walltime is not None:
            directives_lines.append('--time=%s' %
                                    strfdelta(job_walltime, '%H:%M:%S'))

        if job_mem_per_cpu is not None:
            directives_lines.append('--mem-per-cpu=%d' % job_mem_per_cpu)

        if job_memory is not None:
            directives_lines.append('--mem=%d' % job_memory)

        if job_dependency is not None:
            master = job_dependency['job']
            dependency_type = SlurmPrinter.get_dependency_type(
                job_dependency['dependency_type']
            )
            job_id = master.get_id() if isinstance(master, JobInterface) else master

            directives_lines.append(
                '--dependency=%s:%s' %
                (dependency_type, job_id)
            )

        for custom_option in job_custom_options:
            directives_lines.append(custom_option)

        directives = '\n'.join([
            '#SBATCH %s' % directive for directive in directives_lines
        ])

        commands = '\n'.join([
            '\n'.join(command_container.get_commands()) for command_container in job.get_commands()
        ])

        script = '#!%s\n' % job_shell
        script += SlurmPrinter.get_header()
        script += directives
        script += '\n\n'
        script += commands

        return script
433305
def create(record)
      result = self.class.post(worksheet_url,
        :body => { "fields" => record.fields }.to_json,
        :headers => { "Content-type" => "application/json" }).parsed_response

      check_and_raise_error(result)

      record.override_attributes!(result_attributes(result))
      record
    end
1117567
public IJobDetail build ()
  {

    final JobDetail job = new JobDetail ();

    job.setJobClass (m_aJobClass);
    job.setDescription (m_sDescription);
    if (m_aKey == null)
      m_aKey = new JobKey (Key.createUniqueName (null), null);
    job.setKey (m_aKey);
    job.setDurability (m_bDurability);
    job.setRequestsRecovery (m_bShouldRecover);

    if (!m_aJobDataMap.isEmpty ())
      job.setJobDataMap (m_aJobDataMap);

    return job;
  }
750040
public static DefaultJobSpecScheduleImpl createNoSchedule(JobSpec jobSpec,
                                                            Runnable jobRunnable) {
    return new DefaultJobSpecScheduleImpl(jobSpec, jobRunnable,
                                          Optional.<Long>absent());
  }
736623
def _makeJobSuccessorReadyToRun(self, jobGraph, jobNode):
        """"""
        successorJobStoreID = jobNode.jobStoreID
        #Build map from successor to predecessors.
        if successorJobStoreID not in self.toilState.successorJobStoreIDToPredecessorJobs:
            self.toilState.successorJobStoreIDToPredecessorJobs[successorJobStoreID] = []
        self.toilState.successorJobStoreIDToPredecessorJobs[successorJobStoreID].append(jobGraph)

        if jobNode.predecessorNumber > 1:
            return self._checkSuccessorReadyToRunMultiplePredecessors(jobGraph, jobNode, successorJobStoreID)
        else:
            return True
286166
def createRootJob(self, *args, **kwargs):
        
        rootJob = self.create(*args, **kwargs)
        self.setRootJob(rootJob.jobStoreID)
        return rootJob
1280767
public static ArchivedExecutionGraph createFrom(ExecutionGraph executionGraph) {
		final int numberVertices = executionGraph.getTotalNumberOfVertices();

		Map<JobVertexID, ArchivedExecutionJobVertex> archivedTasks = new HashMap<>(numberVertices);
		List<ArchivedExecutionJobVertex> archivedVerticesInCreationOrder = new ArrayList<>(numberVertices);

		for (ExecutionJobVertex task : executionGraph.getVerticesTopologically()) {
			ArchivedExecutionJobVertex archivedTask = task.archive();
			archivedVerticesInCreationOrder.add(archivedTask);
			archivedTasks.put(task.getJobVertexId(), archivedTask);
		}

		final Map<String, SerializedValue<OptionalFailure<Object>>> serializedUserAccumulators =
			executionGraph.getAccumulatorsSerialized();

		final long[] timestamps = new long[JobStatus.values().length];

		for (JobStatus jobStatus : JobStatus.values()) {
			final int ordinal = jobStatus.ordinal();
			timestamps[ordinal] = executionGraph.getStatusTimestamp(jobStatus);
		}

		return new ArchivedExecutionGraph(
			executionGraph.getJobID(),
			executionGraph.getJobName(),
			archivedTasks,
			archivedVerticesInCreationOrder,
			timestamps,
			executionGraph.getState(),
			executionGraph.getFailureInfo(),
			executionGraph.getJsonPlan(),
			executionGraph.getAccumulatorResultsStringified(),
			serializedUserAccumulators,
			executionGraph.getArchivedExecutionConfig(),
			executionGraph.isStoppable(),
			executionGraph.getCheckpointCoordinatorConfiguration(),
			executionGraph.getCheckpointStatsSnapshot());
	}
186255
public static StepExecutionItem createJobRef(
            final String jobIdentifier,
            final String[] args,
            final boolean nodeStep,
            final StepExecutionItem handler,
            final boolean keepgoingOnSuccess,
            final String label
    )
    {
        return createJobRef(
                jobIdentifier,
                args,
                nodeStep,
                handler,
                keepgoingOnSuccess,
                null,
                null,
                null,
                null,
                null,
                label,
                false,
                null,
                false,
                false,
                null,
                false
        );
    }
89649
def submit_jobs(self, link, job_dict=None, job_archive=None, stream=sys.stdout):
        
        failed = False
        if job_dict is None:
            job_dict = link.jobs

        for job_key, job_details in sorted(job_dict.items()):
            job_config = job_details.job_config
            # clean failed jobs
            if job_details.status == JobStatus.failed:
                clean_job(job_details.logfile,
                          job_details.outfiles, self._dry_run)
                # clean_job(job_details.logfile, {}, self._dry_run)
            job_config['logfile'] = job_details.logfile
            new_job_details = self.dispatch_job(
                link, job_key, job_archive, stream)
            if new_job_details.status == JobStatus.failed:
                failed = True
                clean_job(new_job_details.logfile,
                          new_job_details.outfiles, self._dry_run)
            link.jobs[job_key] = new_job_details
        if failed:
            return JobStatus.failed
        return JobStatus.done
1040245
public void addJobEntry(BackupJob job)
   {
      // jobEntries
      try
      {
         JobEntryInfo info = new JobEntryInfo();
         info.setDate(Calendar.getInstance());
         info.setType(job.getType());
         info.setState(job.getState());
         info.setURL(job.getStorageURL());

         logWriter.write(info, config);
      }
      catch (IOException e)
      {
         logger.error("Can't add job", e);
      }
      catch (XMLStreamException e)
      {
         logger.error("Can't add job", e);
      }
      catch (BackupOperationException e)
      {
         logger.error("Can't add job", e);
      }
   }
854892
def create(cls, **kwargs):
        
        linkname = kwargs.setdefault('linkname', cls.clientclass.linkname_default)
        # Don't use setdefault b/c we don't want to build a JobArchive
        # Unless it is needed
        job_archive = kwargs.get('job_archive', None)
        if job_archive is None:
            job_archive = JobArchive.build_temp_job_archive()
            kwargs.setdefault('job_archive', job_archive)
        kwargs_client = dict(linkname=linkname,
                             link_prefix=kwargs.get('link_prefix', ''),
                             file_stage=kwargs.get('file_stage', None),
                             job_archive=job_archive)
        link = cls.clientclass.create(**kwargs_client)
        sg = cls(link, **kwargs)
        return sg