Project jobs statuses
763989
def k8s_events_handle_job_statuses(self: 'celery_app.task', payload: Dict) -> None:
    """"""
    details = payload['details']
    job_uuid = details['labels']['job_uuid']
    job_name = details['labels']['job_name']
    project_name = details['labels'].get('project_name')
    logger.debug('handling events status for job %s', job_name)

    try:
        job = Job.objects.get(uuid=job_uuid)
    except Job.DoesNotExist:
        logger.debug('Job `%s` does not exist', job_name)
        return

    try:
        job.project
    except Project.DoesNotExist:
        logger.debug('Project for job `%s` does not exist', project_name)
        return

    # Set the new status
    try:
        set_node_scheduling(job, details['node_name'])
        job.set_status(status=payload['status'],
                       message=payload['message'],
                       traceback=payload.get('traceback'),
                       details=details)
    except IntegrityError:
        # Due to concurrency this could happen, we just retry it
        self.retry(countdown=Intervals.EXPERIMENTS_SCHEDULER)
619841
private <Q, R> void recordFinalStatus(JobIdentifier<Q, R> jobId, JobStatus<Q, R> jobStatus) {
        try {
            _jobStatusDAO.updateJobStatus(jobId, jobStatus);
        } catch (Exception e) {
            _log.error("Failed to record final status for job: [id={}, status={}]", jobId, jobStatus.getStatus(), e);
        }
    }
701233
@Get("/projects")
    public CompletableFuture<List<ProjectDto>> listProjects(@Param("status") Optional<String> status) {
        if (status.isPresent()) {
            checkStatusArgument(status.get());
            return CompletableFuture.supplyAsync(() -> projectManager().listRemoved().stream()
                                                                       .map(ProjectDto::new)
                                                                       .collect(toImmutableList()));
        }

        return CompletableFuture.supplyAsync(() -> projectManager().list().values().stream()
                                                                   .map(DtoConverter::convert)
                                                                   .collect(toImmutableList()));
    }
160235
protected function projectsStatus()
    {
        $status_report = [];
        $status = locale_translation_get_status();
        foreach ($status as $project_id => $project) {
            foreach ($project as $langcode => $project_info) {
                $info = '';
                if ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
                    $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : null;
                    $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : null;
                    $local_age = $local->timestamp? format_date($local->timestamp, 'html_date'): '';
                    $remote_age = $remote->timestamp? format_date($remote->timestamp, 'html_date'): '';

                    if ($local_age >= $remote_age) {
                        $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
                    } else {
                        $info = $this->trans('commands.locale.translation.status.messages.translation-project-available');
                    }
                } elseif ($project_info->type == LOCALE_TRANSLATION_CURRENT) {
                    $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
                } else {
                    $local_age = '';
                    $remote_age = '';
                    $info = $this->createInfoString($project_info);
                }

                $status_report[$langcode][] = [$project_info->name, $project_info->version, $local_age, $remote_age ,$info ];
            }
        }

        return $status_report;
    }
1179660
def get_job(project_id, job_id, opts = {})
      data, _status_code, _headers = get_job_with_http_info(project_id, job_id, opts)
      return data
    end
1372731
def set_project_status(project_id, status, **kwargs):
    
    user_id = kwargs.get('user_id')
    #check_perm(user_id, 'delete_project')
    project = _get_project(project_id)
    project.check_write_permission(user_id)
    project.status = status
    db.DBSession.flush()
506245
def list(self, request, project):
        
        job_ids = request.query_params.getlist('job_id')
        if not job_ids:
            raise ParseError(
                detail="The job_id parameter is mandatory for this endpoint")
        try:
            job_ids = [int(job_id) for job_id in job_ids]
        except ValueError:
            raise ParseError(detail="The job_id parameter(s) must be integers")

        logs = JobLog.objects.filter(job__repository__name=project,
                                     job_id__in=job_ids)

        return Response([self._log_as_dict(log) for log in logs])
910997
def get_status(self):
        
        if self.n_total == 0:
            return JobStatus.no_job
        elif self.n_done == self.n_total:
            return JobStatus.done
        elif self.n_failed > 0:
            # If more that a quater of the jobs fail, fail the whole thing
            if self.n_failed > self.n_total / 4.:
                return JobStatus.failed
            return JobStatus.partial_failed
        elif self.n_running > 0:
            return JobStatus.running
        elif self.n_pending > 0:
            return JobStatus.pending
        return JobStatus.ready
234454
def get_task_statuses(self):
        

        params = {'taskstatus': ''}

        resp = self._client.get(self.resource(), params=params)
        self.parse(self._client, resp, obj=self)

        return dict([(task.name, task) for task in self._tasks])
1274533
public void updateStatus(JobStatus newStatus) {
    JobMonitor monitor = getJobMonitor(newStatus);
    monitor.updateStatus(newStatus);
  }
882041
private void updateTaskStatuses(TaskTrackerStatus status) {
    TaskTrackerInfo trackerInfo = TaskTrackerInfo.fromStatus(status);
    String trackerName = status.getTrackerName();
    for (TaskStatus report : status.getTaskReports()) {
      // Ensure that every report has information about task tracker
      report.setTaskTracker(trackerName);
      LOG.debug("Task status report: " + report);
      updateTaskStatus(trackerInfo, report);
      // Take any actions outside updateTaskStatus()
      setupReduceRequests(job);
      processFetchFailures(report);
    }
  }
1033413
def project(project_id, opts = {})
      data, _status_code, _headers = project_with_http_info(project_id, opts)
      return data
    end
1249898
def _status(self):
        ''' 
        '''

        job_id_list = ' '.join(self.resources.keys())

        jobs_missing = list(self.resources.keys())

        retcode, stdout, stderr = self.channel.execute_wait("qstat {0}".format(job_id_list), 3)
        for line in stdout.split('\n'):
            parts = line.split()
            if not parts or parts[0].upper().startswith('JOB') or parts[0].startswith('---'):
                continue
            job_id = parts[0]
            status = translate_table.get(parts[4], 'UNKNOWN')
            self.resources[job_id]['status'] = status
            jobs_missing.remove(job_id)

        # squeue does not report on jobs that are not running. So we are filling in the
        # blanks for missing jobs, we might lose some information about why the jobs failed.
        for missing_job in jobs_missing:
            if self.resources[missing_job]['status'] in ['PENDING', 'RUNNING']:
                self.resources[missing_job]['status'] = translate_table['E']
1246342
def post(self, result_id, project_id):
        """"""

        result = db.session.query(Result).filter_by(id=result_id).first()

        if result is None:
            return jsonify({
                'result': None,
                'message': 'No interface defined for URL.'
            }), 404

        job_status = CommandsState.job_status(result.path_name)
        if job_status != JobStatus.RUNNING:
            if job_status == JobStatus.NO_EXTENSION_ERROR:
                return jsonify({
                    'message': '\'CommandsExtension\' is not set or disabled.'
                }), 400
            elif job_status == JobStatus.INITIALIZED:
                return jsonify({
                    'message': 'The target training job has not run, yet'
                }), 400
            elif job_status == JobStatus.STOPPED:
                return jsonify({
                    'message': 'The target training job has already stopped'
                }), 400
            else:
                return jsonify({
                    'message': 'Cannot get the target training job status'
                }), 400

        request_json = request.get_json()
        if request_json is None:
            return jsonify({
                'message': 'Empty request.'
            }), 400

        command_name = request_json.get('name', None)
        if command_name is None:
            return jsonify({
                'message': 'Name is required.'
            }), 400

        schedule = request_json.get('schedule', None)
        if not CommandItem.is_valid_schedule(schedule):
            return jsonify({
                'message': 'Schedule is invalid.'
            }), 400

        command = CommandItem(
            name=command_name,
        )

        command.set_request(
            CommandItem.REQUEST_OPEN,
            request_json.get('body', None),
            request_json.get('schedule', None)
        )

        commands = CommandItem.load_commands(result.path_name)
        commands.append(command)

        CommandItem.dump_commands(commands, result.path_name)

        new_result = crawl_result(result, force=True)
        new_result_dict = new_result.serialize

        return jsonify({'commands': new_result_dict['commands']})
401543
def status(self):
        """"""
        # If there is no script it is either ready or a lost duplicate #
        if not self.script_path.exists:
            if self.name in     jobs.names: return "DUPLICATE"
            if self.name not in jobs.names: return "READY"
        # It is submitted already #
        if self.name in jobs.names:
            if jobs[self.name]['type'] == 'queued':  return "QUEUED"
            if jobs[self.name]['type'] == 'running': return "RUNNING"
        # So the script exists for sure but it is not in the queue #
        if not self.kwargs['out_file'].exists: return "ABORTED"
        # Let's look in log file #
        if 'CANCELED'          in self.log_tail: return "CANCELLED"
        if 'slurmstepd: error' in self.log_tail: return "CANCELLED"
        # It all looks good #
        if 'SLURM: end at'     in self.log_tail: return "FINISHED"
        # At this point we have no idea #
        return "INTERUPTED"
631823
def status(self, job_id):
        
        check_jobid(job_id)

        queue = self._get_queue()
        if queue is None:
            raise QueueDoesntExist

        ret, output = self._call('%s %s' % (
                                 shell_escape(queue / 'commands/status'),
                                 job_id),
                                 True)
        if ret == 0:
            directory, result = output.splitlines()
            result = result.decode('utf-8')
            return RemoteQueue.JOB_DONE, PosixPath(directory), result
        elif ret == 2:
            directory = output.splitlines()[0]
            return RemoteQueue.JOB_RUNNING, PosixPath(directory), None
        elif ret == 3:
            raise JobNotFound
        else:
            raise RemoteCommandFailure(command="commands/status",
                                       ret=ret)
855901
def set_status(db, job_id, status):
    
    assert status in (
        'created', 'submitted', 'executing', 'complete', 'aborted', 'failed'
    ), status
    if status in ('created', 'complete', 'failed', 'aborted'):
        is_running = 0
    else:  # 'executing'
        is_running = 1
    if job_id < 0:
        rows = db('SELECT id FROM job ORDER BY id DESC LIMIT ?x', -job_id)
        if not rows:
            return 0
        job_id = rows[-1].id
    cursor = db('UPDATE job SET status=?x, is_running=?x WHERE id=?x',
                status, is_running, job_id)
    return cursor.rowcount