예제 #1
0
 static void disposeAction(JobTreeElement jte) {
   if (jte.isJobInfo()) {
     JobInfo ji = (JobInfo) jte;
     Job job = ji.getJob();
     if (job != null) {
       Object prop = job.getProperty(IProgressConstants.ACTION_PROPERTY);
       if (prop instanceof ActionFactory.IWorkbenchAction) {
         ((ActionFactory.IWorkbenchAction) prop).dispose();
       }
     }
   }
 }
예제 #2
0
  private void checkTasks(JobInfo info) {
    if (keep(info)) {
      TaskInfo tinfo = info.getTaskInfo();
      if (tinfo != null) {
        JobTreeElement[] toBeRemoved = null;
        boolean fire = false;
        JobTreeElement element = (JobTreeElement) tinfo.getParent();
        synchronized (keptjobinfos) {
          if (element == info && !keptjobinfos.contains(tinfo)) {
            toBeRemoved = findJobsToRemove(element);
            keptjobinfos.add(tinfo);
            finishedTime.put(tinfo, new Long(System.currentTimeMillis()));
          }
        }

        if (toBeRemoved != null) {
          for (int i = 0; i < toBeRemoved.length; i++) {
            remove(toBeRemoved[i]);
          }
        }

        if (fire) {
          Object l[] = getListeners();
          for (int i = 0; i < l.length; i++) {
            KeptJobsListener jv = (KeptJobsListener) l[i];
            jv.finished(info);
          }
        }
      }
    }
  }
예제 #3
0
  /** Add given Job to list of kept jobs. */
  private void add(JobInfo info) {
    boolean fire = false;

    synchronized (keptjobinfos) {
      if (!keptjobinfos.contains(info)) {
        keptjobinfos.add(info);

        long now = System.currentTimeMillis();
        finishedTime.put(info, new Long(now));

        Object parent = info.getParent();
        if (parent != null && !keptjobinfos.contains(parent)) {
          keptjobinfos.add(parent);
          finishedTime.put(parent, new Long(now));
        }

        fire = true;
      }
    }

    if (fire) {
      Object l[] = getListeners();
      for (int i = 0; i < l.length; i++) {
        KeptJobsListener jv = (KeptJobsListener) l[i];
        jv.finished(info);
      }
    }
  }
예제 #4
0
 public void removeErrorJobs() {
   JobTreeElement[] infos = getJobInfos();
   for (int i = 0; i < infos.length; i++) {
     if (infos[i].isJobInfo()) {
       JobInfo info1 = (JobInfo) infos[i];
       Job job = info1.getJob();
       if (job != null) {
         IStatus status = job.getResult();
         if (status != null && status.getSeverity() == IStatus.ERROR) {
           JobTreeElement topElement = (JobTreeElement) info1.getParent();
           if (topElement == null) {
             topElement = info1;
           }
           FinishedJobs.getInstance().remove(topElement);
         }
       }
     }
   }
 }
예제 #5
0
  /** Returns true if JobInfo indicates that it must be kept. */
  static boolean keep(JobInfo info) {
    Job job = info.getJob();
    if (job != null) {
      Object prop = job.getProperty(ProgressManagerUtil.KEEP_PROPERTY);
      if (prop instanceof Boolean) {
        if (((Boolean) prop).booleanValue()) {
          return true;
        }
      }

      prop = job.getProperty(ProgressManagerUtil.KEEPONE_PROPERTY);
      if (prop instanceof Boolean) {
        if (((Boolean) prop).booleanValue()) {
          return true;
        }
      }

      IStatus status = job.getResult();
      if (status != null && status.getSeverity() == IStatus.ERROR) {
        return true;
      }
    }
    return false;
  }
예제 #6
0
    @Override
    public boolean toHTML(StringBuilder sb) {
      if (jobs != null) {
        DocGen.HTML.arrayHead(sb);
        sb.append("<tr class='warning'>");
        ArrayList<Argument> args = jobs[0].arguments();
        // Filter some keys to simplify UI
        args = (ArrayList<Argument>) args.clone();
        filter(
            args,
            "destination_key",
            "source",
            "cols",
            "ignored_cols_by_name",
            "response",
            "classification",
            "validation");
        for (int i = 0; i < args.size(); i++)
          sb.append("<td><b>").append(args.get(i)._name).append("</b></td>");
        sb.append("<td><b>").append("run time").append("</b></td>");
        String perf = jobs[0].speedDescription();
        if (perf != null) sb.append("<td><b>").append(perf).append("</b></td>");
        sb.append("<td><b>").append("model key").append("</b></td>");
        sb.append("<td><b>").append("prediction error").append("</b></td>");
        sb.append("<td><b>").append("F1 score").append("</b></td>");
        sb.append("</tr>");

        ArrayList<JobInfo> infos = new ArrayList<JobInfo>();
        for (Job job : jobs) {
          JobInfo info = new JobInfo();
          info._job = job;
          Object value = UKV.get(job.destination_key);
          info._model = value instanceof Model ? (Model) value : null;
          if (info._model != null) info._cm = info._model.cm();
          if (info._cm != null) info._error = info._cm.err();
          infos.add(info);
        }
        Collections.sort(
            infos,
            new Comparator<JobInfo>() {
              @Override
              public int compare(JobInfo a, JobInfo b) {
                return Double.compare(a._error, b._error);
              }
            });

        for (JobInfo info : infos) {
          sb.append("<tr>");
          for (Argument a : args) {
            try {
              Object value = a._field.get(info._job);
              String s;
              if (value instanceof int[]) s = Utils.sampleToString((int[]) value, 20);
              else s = "" + value;
              sb.append("<td>").append(s).append("</td>");
            } catch (Exception e) {
              throw new RuntimeException(e);
            }
          }
          String runTime = "Pending", speed = "";
          if (info._job.start_time != 0) {
            runTime = PrettyPrint.msecs(info._job.runTimeMs(), true);
            speed = perf != null ? PrettyPrint.msecs(info._job.speedValue(), true) : "";
          }
          sb.append("<td>").append(runTime).append("</td>");
          if (perf != null) sb.append("<td>").append(speed).append("</td>");

          String link = info._job.destination_key.toString();
          if (info._job.start_time != 0 && DKV.get(info._job.destination_key) != null) {
            if (info._model instanceof GBMModel)
              link = GBMModelView.link(link, info._job.destination_key);
            else if (info._model instanceof NeuralNetModel)
              link = NeuralNetProgress.link(info._job.self(), info._job.destination_key, link);
            if (info._model instanceof KMeans2Model)
              link = KMeans2ModelView.link(link, info._job.destination_key);
            else link = Inspect.link(link, info._job.destination_key);
          }
          sb.append("<td>").append(link).append("</td>");

          String pct = "", f1 = "";
          if (info._cm != null) {
            pct = String.format("%.2f", 100 * info._error) + "%";
            if (info._cm._arr.length == 2)
              f1 = String.format("%.2f", info._cm.precisionAndRecall());
          }
          sb.append("<td><b>").append(pct).append("</b></td>");
          sb.append("<td><b>").append(f1).append("</b></td>");
          sb.append("</tr>");
        }
        DocGen.HTML.arrayTail(sb);
      }
      return true;
    }