Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/22/11 15:54:58 (13 years ago)
Author:
cneumuel
Message:

#1233

  • implemented correct downloading of paused jobs. its now also possible to change parameters and resume a algorithm
  • removed Prepare() calls in ExperimentManager and in slave, as it prevents corrent resuming of paused jobs
  • made events in ItemTreeView be invoked in the correct thread
  • reduced log output in ExperimentManager
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveExperimentClient.cs

    r5786 r5793  
    495495      jobResultPoller.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobResultPoller_ExceptionOccured);
    496496      jobResultPoller.JobResultsReceived += new EventHandler<EventArgs<IEnumerable<LightweightJob>>>(jobResultPoller_JobResultReceived);
    497       jobResultPoller.PollingStarted += new EventHandler(jobResultPoller_PollingStarted);
    498       jobResultPoller.PollingFinished += new EventHandler(jobResultPoller_PollingFinished);
    499497      jobResultPoller.IsPollingChanged += new EventHandler(jobResultPoller_IsPollingChanged);
    500498    }
     
    502500      jobResultPoller.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(jobResultPoller_ExceptionOccured);
    503501      jobResultPoller.JobResultsReceived -= new EventHandler<EventArgs<IEnumerable<LightweightJob>>>(jobResultPoller_JobResultReceived);
    504       jobResultPoller.PollingStarted -= new EventHandler(jobResultPoller_PollingStarted);
    505       jobResultPoller.PollingFinished -= new EventHandler(jobResultPoller_PollingFinished);
    506502      jobResultPoller.IsPollingChanged -= new EventHandler(jobResultPoller_IsPollingChanged);
    507503    }
    508504    private void jobResultPoller_IsPollingChanged(object sender, EventArgs e) {
    509505      this.IsPollingResults = jobResultPoller.IsPolling;
    510     }
    511     private void jobResultPoller_PollingFinished(object sender, EventArgs e) {
    512       LogMessage("Polling results finished");
    513     }
    514     private void jobResultPoller_PollingStarted(object sender, EventArgs e) {
    515       LogMessage("Polling results started");
    516506    }
    517507    private void jobResultPoller_JobResultReceived(object sender, EventArgs<IEnumerable<LightweightJob>> e) {
     
    527517            OptimizerJob optimizerJob = LoadOptimizerJob(hj.Job.Id);
    528518            if (optimizerJob == null) {
    529               // something bad happened to this job. set to finished to allow the rest beeing downloaded
    530               //hj.IsFinishedOptimizerDownloaded = true;
     519              // something bad happened to this job. bad job, BAAAD job!
    531520            } else {
    532521              // if the job is paused, download but don't integrate into parent optimizer (to avoid Prepare)
    533522              if (hj.Job.State == JobState.Paused) {
    534                
     523                hj.OptimizerJob = optimizerJob;
    535524              } else {
    536525                if (lightweightJob.ParentJobId.HasValue) {
    537526                  HiveJob parentHiveJob = HiveJob.GetHiveJobByJobId(lightweightJob.ParentJobId.Value);
    538527                  parentHiveJob.UpdateChildOptimizer(optimizerJob, hj.Job.Id);
    539                 } else {
    540                   //this.HiveJob.IsFinishedOptimizerDownloaded = true;
    541528                }
    542529              }
     
    554541
    555542    private bool AllJobsFinished() {
    556       //return HiveJob.GetAllHiveJobs().All(hj => hj.IsFinishedOptimizerDownloaded);
    557543      return HiveJob.GetAllHiveJobs().All(j => j.Job.State == JobState.Finished
    558544                                            || j.Job.State == JobState.Aborted
     
    623609        this.HiveJob = allHiveJobs[this.rootJobId];
    624610
    625 
    626         //// download them first
    627         //IDictionary<Guid, Job> allJobs = new Dictionary<Guid, Job>();
    628         //IDictionary<Guid, JobData> allJobDatas = new Dictionary<Guid, JobData>();
    629         //foreach (LightweightJob lightweightJob in allResults) {
    630         //  jobCount++;
    631         //  progress.Status = string.Format("Downloading {0} of {1} jobs...", jobCount, totalJobCount);
    632         //  allJobs.Add(lightweightJob.Id, service.GetJob(lightweightJob.Id));
    633         //  allJobDatas.Add(lightweightJob.Id, service.GetJobData(lightweightJob.Id));
    634         //  progress.ProgressValue = (double)jobCount / totalJobCount;
    635         //}
    636 
    637         //jobCount = 1;
    638         //progress.Status = string.Format("Deserializing {0} of {1} jobs... ({2} kb)", jobCount, totalJobCount, allJobDatas[this.rootJobId].Data.Count() / 1024);
    639         //this.HiveJob = new HiveJob(allJobs[this.rootJobId], allJobDatas[this.rootJobId], false);
    640         //allJobDatas.Remove(this.rootJobId); // reduce memory footprint
    641         //allJobs.Remove(this.rootJobId);
    642         //progress.ProgressValue = (double)jobCount / totalJobCount;
    643 
    644 
    645611        if (this.HiveJob.Job.DateFinished.HasValue && this.HiveJob.Job.DateCreated.HasValue) {
    646612          this.ExecutionTime = this.HiveJob.Job.DateFinished.Value - this.HiveJob.Job.DateCreated.Value;
     
    656622
    657623        // build child-job tree
    658         //LoadChildResults(service, this.HiveJob, allResults, allJobs, allJobDatas, progress, totalJobCount, ref jobCount);
    659624        BuildHiveJobTree(this.HiveJob, allJobs, allHiveJobs);
    660625        StartResultPolling();
     
    739704      return pluginDatas;
    740705    }
    741 
    742     /// <summary>
    743     /// Gets the Ids of all plugins needed for executing the job.
    744     /// All loaded plugins are assumed to be necessary.
    745     /// If a plugin with the same name and version is already online, it is used. Otherwise the local plugin is uploaded.
    746     /// If useLocalPlugins is true, all local plugins are uploaded regardless of the existence of the same plugin online.
    747     /// </summary>
    748     //public static List<Guid> GetPluginsNeededIds(bool useLocalPlugins) {
    749     //  IEnumerable<IPluginDescription> localPlugins = ApplicationManager.Manager.Plugins;
    750     //  List<Guid> pluginsNeededIds = new List<Guid>();
    751 
    752     //  using (var service = ServiceLocator.Instance.GetService()) {
    753     //    IEnumerable<Plugin> onlinePlugins = service.Obj.GetPlugins();
    754 
    755     //    foreach (IPluginDescription localPlugin in localPlugins) {
    756     //      Plugin found = onlinePlugins.Where(onlinePlugin => onlinePlugin.Name == localPlugin.Name && onlinePlugin.Version == localPlugin.Version).SingleOrDefault();
    757     //      if (!useLocalPlugins && found != null) {
    758     //        // plugin is available online; reuse
    759     //        pluginsNeededIds.Add(found.Id);
    760     //      } else {
    761     //        // upload the plugin
    762     //        Plugin p = new Plugin() { Name = localPlugin.Name, Version = localPlugin.Version, IsLocal = useLocalPlugins };
    763     //        List<PluginData> pluginDatas = new List<PluginData>();
    764 
    765     //        foreach (IPluginFile pf in localPlugin.Files) {
    766     //          PluginData pluginData = new PluginData();
    767 
    768     //          pluginData.Data = File.ReadAllBytes(pf.Name);
    769     //          pluginDatas.Add(pluginData);
    770     //        }
    771     //        pluginsNeededIds.Add(service.Obj.AddPlugin(p, pluginDatas));
    772     //      }
    773     //    }
    774     //  }
    775     //  return pluginsNeededIds;
    776     //}
    777706    #endregion
    778707
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJobClient.cs

    r5786 r5793  
    7070    public OptimizerJob OptimizerJob {
    7171      get { return optimizerJob; }
    72       private set {
     72      internal set {
    7373        if (optimizerJob != null && syncJobsWithOptimizers) {
    7474          this.childHiveJobs.Clear();
     
    289289      syncJobsWithOptimizers = false;
    290290      if (this.OptimizerJob != null && hiveJob.OptimizerJob != null) {
     291        // if job is in state Paused, it has to preserve its ResultCollection, which is cleared when a optimizer is added to an experiment
     292        OptimizerJob optimizerJobClone = null;
     293        if (hiveJob.Job.State == JobState.Paused) {
     294          optimizerJobClone = (OptimizerJob)hiveJob.OptimizerJob.Clone();
     295        }
     296
    291297        if (this.OptimizerJob.Optimizer is Optimization.Experiment) {
    292298          if (!this.OptimizerJob.OptimizerAsExperiment.Optimizers.Contains(hiveJob.OptimizerJob.Optimizer)) {
     
    295301        } else if (this.OptimizerJob.Optimizer is Optimization.BatchRun) {
    296302          UpdateOptimizerInBatchRun(this.OptimizerJob.OptimizerAsBatchRun, hiveJob.OptimizerJob);
     303        }
     304
     305        if (hiveJob.Job.State == JobState.Paused) {
     306          hiveJob.OptimizerJob = optimizerJobClone;
    297307        }
    298308      }
     
    524534    private void OnOptimizerJobChanged() {
    525535      OptimizerJob_ComputeInParallelChanged(this, EventArgs.Empty);
    526       var handler = JobChanged;
     536      var handler = OptimizerJobChanged;
    527537      if (handler != null) handler(this, EventArgs.Empty);
    528538    }
     
    649659
    650660    public void Restart() {
    651       ServiceLocator.Instance.CallHiveService(s => s.RestartJob(this.job.Id));
     661      ServiceLocator.Instance.CallHiveService(service => {
     662        JobData jobData = new JobData();
     663        jobData.JobId = this.job.Id;
     664        jobData.Data = PersistenceUtil.Serialize(this.optimizerJob);
     665        service.UpdateJobData(this.Job, jobData);
     666        service.RestartJob(this.job.Id);
     667        Job job = service.GetJob(this.job.Id);
     668        this.job.LastJobDataUpdate = job.LastJobDataUpdate;
     669      });
    652670    }
    653671  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJobDownloader.cs

    r5599 r5793  
    8888        HiveJob hiveJob = new HiveJob(job, jobData, false);
    8989        jobData.Data = null; // reduce memory consumption.
    90         hiveJob.OptimizerJob.Prepare(); // reduce memory consumption.
    9190        hiveJob.Job = job;
    9291        return hiveJob;
Note: See TracChangeset for help on using the changeset viewer.