Changeset 12621


Ignore:
Timestamp:
07/07/15 00:06:42 (4 years ago)
Author:
ascheibe
Message:

#2409 added support for IProgrammableItem in Hive

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveTasks/EngineHiveTask.cs

    r12012 r12621  
    4747
    4848    public override TaskData GetAsTaskData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) {
    49       plugins = new List<IPluginDescription>();
    50       if (this.itemTask == null)
     49      if (ItemTask == null) {
     50        plugins = new List<IPluginDescription>();
    5151        return null;
     52      }
    5253
    5354      TaskData jobData = new TaskData();
     
    6061      jobData.Data = PersistenceUtil.Serialize(ItemTask, out usedTypes);
    6162
    62       PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);
     63      plugins = PluginUtil.GetPluginsForTask(usedTypes, ItemTask);
    6364      return jobData;
    6465    }
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveTasks/HiveTask.cs

    r12012 r12621  
    295295    /// </param>
    296296    public virtual TaskData GetAsTaskData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) {
    297       plugins = new List<IPluginDescription>();
    298       if (this.itemTask == null)
     297      if (ItemTask == null) {
     298        plugins = new List<IPluginDescription>();
    299299        return null;
     300      }
    300301
    301302      IEnumerable<Type> usedTypes;
    302       byte[] taskByteArray = PersistenceUtil.Serialize(this.ItemTask, out usedTypes);
     303      byte[] taskByteArray = PersistenceUtil.Serialize(ItemTask, out usedTypes);
    303304      TaskData taskData = new TaskData() { TaskId = task.Id, Data = taskByteArray };
    304       PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);
     305      plugins = PluginUtil.GetPluginsForTask(usedTypes, ItemTask);
    305306      return taskData;
    306307    }
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveTasks/OptimizerHiveTask.cs

    r12041 r12621  
    347347    /// </param>
    348348    public override TaskData GetAsTaskData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) {
    349       plugins = new List<IPluginDescription>();
    350       if (this.itemTask == null) // || this.jobItem.Optimizer == null
     349      if (ItemTask == null) {
     350        plugins = new List<IPluginDescription>();
    351351        return null;
     352      }
    352353
    353354      IEnumerable<Type> usedTypes;
    354355      byte[] jobByteArray;
    355       if (withoutChildOptimizers && this.ItemTask.Item is Optimization.Experiment) {
    356         OptimizerTask clonedJob = (OptimizerTask)this.ItemTask.Clone(); // use a cloned task, so that the childHiveJob don't get confused
     356      if (withoutChildOptimizers && ItemTask.Item is Optimization.Experiment) {
     357        OptimizerTask clonedJob = (OptimizerTask)ItemTask.Clone(); // use a cloned task, so that the childHiveJob don't get confused
    357358        clonedJob.OptimizerAsExperiment.Optimizers.Clear();
    358359        jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes);
    359       } else if (withoutChildOptimizers && this.ItemTask.Item is Optimization.BatchRun) {
    360         OptimizerTask clonedJob = (OptimizerTask)this.ItemTask.Clone();
     360      } else if (withoutChildOptimizers && ItemTask.Item is Optimization.BatchRun) {
     361        OptimizerTask clonedJob = (OptimizerTask)ItemTask.Clone();
    361362        clonedJob.OptimizerAsBatchRun.Optimizer = null;
    362363        jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes);
    363       } else if (this.ItemTask.Item is IAlgorithm) {
    364         ((IAlgorithm)this.ItemTask.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size
    365         jobByteArray = PersistenceUtil.Serialize(this.ItemTask, out usedTypes);
     364      } else if (ItemTask.Item is IAlgorithm) {
     365        ((IAlgorithm)ItemTask.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size
     366        jobByteArray = PersistenceUtil.Serialize(ItemTask, out usedTypes);
    366367      } else {
    367         jobByteArray = PersistenceUtil.Serialize(this.ItemTask, out usedTypes);
     368        jobByteArray = PersistenceUtil.Serialize(ItemTask, out usedTypes);
    368369      }
    369370
    370371      TaskData jobData = new TaskData() { TaskId = task.Id, Data = jobByteArray };
    371       PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);
     372      plugins = PluginUtil.GetPluginsForTask(usedTypes, ItemTask);
    372373      return jobData;
    373374    }
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/Util/PluginUtil.cs

    r12012 r12621  
    2626using System.Security.Cryptography;
    2727using System.ServiceModel;
     28using HeuristicLab.Common;
     29using HeuristicLab.Core;
    2830using HeuristicLab.PluginInfrastructure;
    2931
     
    7981    }
    8082
    81     public static Plugin CreatePlugin(IPluginDescription plugin) {
    82       return new Plugin() { Name = plugin.Name, Version = plugin.Version };
    83     }
    84 
    8583    public static List<PluginData> CreatePluginDatas(IPluginDescription plugin) {
    8684      List<PluginData> pluginDatas = new List<PluginData>();
     
    9694    }
    9795
    98     public static void CollectDeclaringPlugins(List<IPluginDescription> plugins, IEnumerable<Type> usedTypes) {
     96    public static List<IPluginDescription> GetPluginsForTask(IEnumerable<Type> usedTypes, object task) {
     97      if (task.GetObjectGraphObjects().Any(x => typeof(IProgrammableItem).IsInstanceOfType(x))) {
     98        //when a programmable item is used all plugins that are currently loaded need to be sent to Hive
     99        return ApplicationManager.Manager.Plugins.ToList();
     100      } else {
     101        return CollectDeclaringPlugins(usedTypes);
     102      }
     103    }
     104
     105    private static List<IPluginDescription> CollectDeclaringPlugins(IEnumerable<Type> usedTypes) {
     106      List<IPluginDescription> plugins = new List<IPluginDescription>();
    99107      foreach (Type type in usedTypes) {
    100108        var plugin = ApplicationManager.Manager.GetDeclaringPlugin(type);
     
    104112        }
    105113      }
     114      return plugins;
    106115    }
    107116
    108     public static void CollectPluginDependencies(List<IPluginDescription> plugins, IPluginDescription plugin) {
     117    private static void CollectPluginDependencies(List<IPluginDescription> plugins, IPluginDescription plugin) {
    109118      if (plugin == null) return;
    110119      foreach (var dependency in plugin.Dependencies) {
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.MathJax/1.1/HeuristicLab.MathJax-1.1/Plugin.cs.frame

    r12472 r12621  
    3636      base.OnLoad();
    3737      if (!Directory.EnumerateFiles(AppDomain.CurrentDomain.BaseDirectory, "MathJax.js", SearchOption.TopDirectoryOnly).Any()) {
    38         ZipFile.ExtractToDirectory("mathjax.zip", AppDomain.CurrentDomain.BaseDirectory);
     38        ZipFile.ExtractToDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mathjax.zip"), AppDomain.CurrentDomain.BaseDirectory);
    3939      }
    4040    }
Note: See TracChangeset for help on using the changeset viewer.