Example #1
0
  refreshJobSummaryList(forceRefresh = false) {
    if (forceRefresh === true || this.blockRefresh === false) {
      const expandedJobsIds = Object.keys(this.state.itemIdToExpandedRowMap);
      ml.jobs.jobsSummary(expandedJobsIds)
        .then((jobs) => {
          const fullJobsList = {};
          const jobsSummaryList = jobs.map((job) => {
            if (job.fullJob !== undefined) {
              fullJobsList[job.id] = job.fullJob;
              delete job.fullJob;
            }
            job.latestTimeStampSortValue = (job.latestTimeStampMs || 0);
            return job;
          });
          const filteredJobsSummaryList = filterJobs(jobsSummaryList, this.state.filterClauses);
          this.setState({ jobsSummaryList, filteredJobsSummaryList, fullJobsList }, () => {
            this.refreshSelectedJobs();
          });

          Object.keys(this.updateFunctions).forEach((j) => {
            this.updateFunctions[j].setState({ job: fullJobsList[j] });
          });

          this.isDoneRefreshing();
        })
        .catch((error) => {
          console.error(error);
        });
    }
  }
Example #2
0
 componentDidMount() {
   // load groups to populate the select options
   ml.jobs.groups()
     .then((resp) => {
       const groups = resp.map(g => ({ label: g.id }));
       this.setState({ groups });
     })
     .catch((error) => {
       console.error('Could not load groups', error);
     });
 }
Example #3
0
 return new Promise((resolve, reject) => {
   ml.jobs.jobs(jobId)
     .then((jobs) => {
       if (jobs.length) {
         resolve(jobs[0]);
       } else {
         reject(`Could not find job ${jobId}`);
       }
     })
     .catch(() => {
       reject(`Could not find job ${jobId}`);
     });
 });
Example #4
0
  async refreshJobSummaryList(forceRefresh = false) {
    if (forceRefresh === true || this.blockRefresh === false) {

      // Set loading to true for jobs_list table for initial job loading
      if (this.state.loading === null) {
        this.setState({ loading: true });
      }

      const expandedJobsIds = Object.keys(this.state.itemIdToExpandedRowMap);
      try {
        const jobs = await ml.jobs.jobsSummary(expandedJobsIds);
        const fullJobsList = {};
        const jobsSummaryList = jobs.map((job) => {
          if (job.fullJob !== undefined) {
            fullJobsList[job.id] = job.fullJob;
            delete job.fullJob;
          }
          job.latestTimestampSortValue = (job.latestTimestampMs || 0);
          return job;
        });
        const filteredJobsSummaryList = filterJobs(jobsSummaryList, this.state.filterClauses);
        this.setState({ jobsSummaryList, filteredJobsSummaryList, fullJobsList, loading: false }, () => {
          this.refreshSelectedJobs();
        });

        Object.keys(this.updateFunctions).forEach((j) => {
          this.updateFunctions[j].setState({ job: fullJobsList[j] });
        });

        jobs.forEach((job) => {
          if (job.deleting && this.state.itemIdToExpandedRowMap[job.id]) {
            this.toggleRow(job.id);
          }
        });

        this.isDoneRefreshing();
        if (jobsSummaryList.some(j => j.deleting === true)) {
          // if there are some jobs in a deleting state, start polling for
          // deleting jobs so we can update the jobs list once the
          // deleting tasks are over
          this.checkDeletingJobTasks();
        }
      } catch (error) {
        console.error(error);
        this.setState({ loading: false });
      }
    }
  }
Example #5
0
  async checkDeletingJobTasks() {
    const { jobIds } = await ml.jobs.deletingJobTasks();

    if (jobIds.length === 0 || isEqual(jobIds.sort(), this.state.deletingJobIds.sort())) {
      this.setState({
        deletingJobIds: jobIds,
      });
      this.refreshJobSummaryList(true);
    }

    if (jobIds.length > 0 && deletingJobsRefreshTimeout === null) {
      deletingJobsRefreshTimeout = setTimeout(() => {
        deletingJobsRefreshTimeout = null;
        this.checkDeletingJobTasks();
      }, DELETING_JOBS_REFRESH_INTERVAL_MS);
    }
  }