Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16173


Ignore:
Timestamp:
09/21/18 16:00:50 (5 years ago)
Author:
jkarder
Message:

#2839:

  • fixed compilation errors in HiveEngine
  • minor changes
Location:
addons/HeuristicLab.MetaOptimization
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HeuristicLab.HiveEngine.Views-3.3.csproj

    r15741 r16173  
    125125      <Private>False</Private>
    126126    </Reference>
     127    <Reference Include="HeuristicLab.Common.Resources-3.3">
     128      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     129      <Private>False</Private>
     130    </Reference>
    127131    <Reference Include="HeuristicLab.Core-3.3">
    128132      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
     
    173177    </ProjectReference>
    174178  </ItemGroup>
    175   <ItemGroup>
    176     <EmbeddedResource Include="HiveEngineView.resx">
    177       <DependentUpon>HiveEngineView.cs</DependentUpon>
    178     </EmbeddedResource>
    179   </ItemGroup>
    180179  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    181180  <PropertyGroup>
  • addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.Designer.cs

    r12930 r16173  
    2525    /// </summary>
    2626    private void InitializeComponent() {
    27       this.resourceIdsLabel = new System.Windows.Forms.Label();
    28       this.resourceIdsTextBox = new System.Windows.Forms.TextBox();
     27      this.projectLabel = new System.Windows.Forms.Label();
     28      this.projectNameTextBox = new System.Windows.Forms.TextBox();
    2929      this.priorityLabel = new System.Windows.Forms.Label();
    30       this.priorityTextBox = new System.Windows.Forms.TextBox();
    3130      this.label1 = new System.Windows.Forms.Label();
    3231      this.executionTimeOnHiveTextBox = new System.Windows.Forms.TextBox();
     
    3837      this.executionTimeLabel = new System.Windows.Forms.Label();
    3938      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
     39      this.priorityComboBox = new System.Windows.Forms.ComboBox();
     40      this.searchButton = new System.Windows.Forms.Button();
    4041      this.tabControl.SuspendLayout();
    4142      this.jobsTabPage.SuspendLayout();
     
    4344      this.SuspendLayout();
    4445      //
    45       // resourceIdsLabel
    46       //
    47       this.resourceIdsLabel.AutoSize = true;
    48       this.resourceIdsLabel.Location = new System.Drawing.Point(113, 55);
    49       this.resourceIdsLabel.Name = "resourceIdsLabel";
    50       this.resourceIdsLabel.Size = new System.Drawing.Size(70, 13);
    51       this.resourceIdsLabel.TabIndex = 3;
    52       this.resourceIdsLabel.Text = "ResourceIds:";
    53       //
    54       // resourceIdsTextBox
    55       //
    56       this.resourceIdsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    57             | System.Windows.Forms.AnchorStyles.Left)
    58             | System.Windows.Forms.AnchorStyles.Right)));
    59       this.resourceIdsTextBox.Location = new System.Drawing.Point(189, 52);
    60       this.resourceIdsTextBox.Name = "resourceIdsTextBox";
    61       this.resourceIdsTextBox.Size = new System.Drawing.Size(517, 20);
    62       this.resourceIdsTextBox.TabIndex = 4;
    63       this.resourceIdsTextBox.Text = "HEAL";
    64       this.resourceIdsTextBox.Validated += new System.EventHandler(this.resourceIdsTextBox_Validated);
     46      // projectLabel
     47      //
     48      this.projectLabel.AutoSize = true;
     49      this.projectLabel.Location = new System.Drawing.Point(3, 55);
     50      this.projectLabel.Name = "projectLabel";
     51      this.projectLabel.Size = new System.Drawing.Size(43, 13);
     52      this.projectLabel.TabIndex = 3;
     53      this.projectLabel.Text = "Project:";
     54      //
     55      // projectNameTextBox
     56      //
     57      this.projectNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     58            | System.Windows.Forms.AnchorStyles.Left)
     59            | System.Windows.Forms.AnchorStyles.Right)));
     60      this.projectNameTextBox.Location = new System.Drawing.Point(162, 52);
     61      this.projectNameTextBox.Name = "projectNameTextBox";
     62      this.projectNameTextBox.ReadOnly = true;
     63      this.projectNameTextBox.Size = new System.Drawing.Size(544, 20);
     64      this.projectNameTextBox.TabIndex = 4;
    6565      //
    6666      // priorityLabel
    6767      //
    6868      this.priorityLabel.AutoSize = true;
    69       this.priorityLabel.Location = new System.Drawing.Point(3, 55);
     69      this.priorityLabel.Location = new System.Drawing.Point(3, 81);
    7070      this.priorityLabel.Name = "priorityLabel";
    7171      this.priorityLabel.Size = new System.Drawing.Size(41, 13);
    7272      this.priorityLabel.TabIndex = 5;
    7373      this.priorityLabel.Text = "Priority:";
    74       //
    75       // priorityTextBox
    76       //
    77       this.priorityTextBox.Location = new System.Drawing.Point(50, 52);
    78       this.priorityTextBox.Name = "priorityTextBox";
    79       this.priorityTextBox.Size = new System.Drawing.Size(57, 20);
    80       this.priorityTextBox.TabIndex = 6;
    81       this.priorityTextBox.Text = "0";
    82       this.priorityTextBox.Validated += new System.EventHandler(this.priorityTextBox_Validated);
    8374      //
    8475      // label1
     
    9687            | System.Windows.Forms.AnchorStyles.Left)
    9788            | System.Windows.Forms.AnchorStyles.Right)));
    98       this.executionTimeOnHiveTextBox.Location = new System.Drawing.Point(129, 26);
     89      this.executionTimeOnHiveTextBox.Location = new System.Drawing.Point(132, 26);
    9990      this.executionTimeOnHiveTextBox.Name = "executionTimeOnHiveTextBox";
    10091      this.executionTimeOnHiveTextBox.ReadOnly = true;
    101       this.executionTimeOnHiveTextBox.Size = new System.Drawing.Size(577, 20);
     92      this.executionTimeOnHiveTextBox.Size = new System.Drawing.Size(574, 20);
    10293      this.executionTimeOnHiveTextBox.TabIndex = 8;
    10394      //
     
    109100      this.tabControl.Controls.Add(this.jobsTabPage);
    110101      this.tabControl.Controls.Add(this.logTabPage);
    111       this.tabControl.Location = new System.Drawing.Point(3, 78);
     102      this.tabControl.Location = new System.Drawing.Point(3, 105);
    112103      this.tabControl.Name = "tabControl";
    113104      this.tabControl.SelectedIndex = 0;
    114       this.tabControl.Size = new System.Drawing.Size(700, 460);
     105      this.tabControl.Size = new System.Drawing.Size(700, 433);
    115106      this.tabControl.TabIndex = 9;
    116107      //
     
    121112      this.jobsTabPage.Name = "jobsTabPage";
    122113      this.jobsTabPage.Padding = new System.Windows.Forms.Padding(3);
    123       this.jobsTabPage.Size = new System.Drawing.Size(692, 434);
     114      this.jobsTabPage.Size = new System.Drawing.Size(692, 407);
    124115      this.jobsTabPage.TabIndex = 0;
    125116      this.jobsTabPage.Text = "Jobs";
     
    135126      this.hiveExperimentListView.ReadOnly = false;
    136127      this.hiveExperimentListView.ShowDetails = true;
    137       this.hiveExperimentListView.Size = new System.Drawing.Size(686, 428);
     128      this.hiveExperimentListView.Size = new System.Drawing.Size(686, 401);
    138129      this.hiveExperimentListView.TabIndex = 0;
    139130      //
     
    144135      this.logTabPage.Name = "logTabPage";
    145136      this.logTabPage.Padding = new System.Windows.Forms.Padding(3);
    146       this.logTabPage.Size = new System.Drawing.Size(692, 434);
     137      this.logTabPage.Size = new System.Drawing.Size(692, 410);
    147138      this.logTabPage.TabIndex = 1;
    148139      this.logTabPage.Text = "Log";
     
    157148      this.logView.Name = "logView";
    158149      this.logView.ReadOnly = false;
    159       this.logView.Size = new System.Drawing.Size(686, 428);
     150      this.logView.Size = new System.Drawing.Size(686, 404);
    160151      this.logView.TabIndex = 0;
    161152      //
     
    163154      //
    164155      this.executionTimeLabel.AutoSize = true;
    165       this.executionTimeLabel.Location = new System.Drawing.Point(4, 6);
     156      this.executionTimeLabel.Location = new System.Drawing.Point(3, 6);
    166157      this.executionTimeLabel.Name = "executionTimeLabel";
    167158      this.executionTimeLabel.Size = new System.Drawing.Size(83, 13);
     
    174165            | System.Windows.Forms.AnchorStyles.Left)
    175166            | System.Windows.Forms.AnchorStyles.Right)));
    176       this.executionTimeTextBox.Location = new System.Drawing.Point(129, 3);
     167      this.executionTimeTextBox.Location = new System.Drawing.Point(132, 3);
    177168      this.executionTimeTextBox.Name = "executionTimeTextBox";
    178169      this.executionTimeTextBox.ReadOnly = true;
    179       this.executionTimeTextBox.Size = new System.Drawing.Size(577, 20);
     170      this.executionTimeTextBox.Size = new System.Drawing.Size(574, 20);
    180171      this.executionTimeTextBox.TabIndex = 11;
     172      //
     173      // priorityComboBox
     174      //
     175      this.priorityComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     176            | System.Windows.Forms.AnchorStyles.Right)));
     177      this.priorityComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     178      this.priorityComboBox.FormattingEnabled = true;
     179      this.priorityComboBox.Items.AddRange(new object[] {
     180            "Low",
     181            "Normal",
     182            "Urgent",
     183            "Critical"});
     184      this.priorityComboBox.Location = new System.Drawing.Point(132, 78);
     185      this.priorityComboBox.Name = "priorityComboBox";
     186      this.priorityComboBox.Size = new System.Drawing.Size(574, 21);
     187      this.priorityComboBox.TabIndex = 44;
     188      this.priorityComboBox.SelectedIndexChanged += new System.EventHandler(this.priorityComboBox_SelectedIndexChanged);
     189      //
     190      // searchButton
     191      //
     192      this.searchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
     193      this.searchButton.Location = new System.Drawing.Point(132, 49);
     194      this.searchButton.Name = "searchButton";
     195      this.searchButton.Size = new System.Drawing.Size(24, 24);
     196      this.searchButton.TabIndex = 45;
     197      this.searchButton.UseVisualStyleBackColor = true;
     198      this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
    181199      //
    182200      // HiveEngineView
     
    184202      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    185203      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     204      this.Controls.Add(this.searchButton);
     205      this.Controls.Add(this.priorityComboBox);
    186206      this.Controls.Add(this.executionTimeTextBox);
    187207      this.Controls.Add(this.executionTimeLabel);
     
    189209      this.Controls.Add(this.label1);
    190210      this.Controls.Add(this.executionTimeOnHiveTextBox);
    191       this.Controls.Add(this.priorityTextBox);
    192211      this.Controls.Add(this.priorityLabel);
    193       this.Controls.Add(this.resourceIdsLabel);
    194       this.Controls.Add(this.resourceIdsTextBox);
     212      this.Controls.Add(this.projectLabel);
     213      this.Controls.Add(this.projectNameTextBox);
    195214      this.Name = "HiveEngineView";
    196215      this.Size = new System.Drawing.Size(706, 541);
     
    205224    #endregion
    206225
    207     private System.Windows.Forms.Label resourceIdsLabel;
    208     private System.Windows.Forms.TextBox resourceIdsTextBox;
     226    private System.Windows.Forms.Label projectLabel;
     227    private System.Windows.Forms.TextBox projectNameTextBox;
    209228    private System.Windows.Forms.Label priorityLabel;
    210     private System.Windows.Forms.TextBox priorityTextBox;
    211229    private System.Windows.Forms.Label label1;
    212230    private System.Windows.Forms.TextBox executionTimeOnHiveTextBox;
     
    218236    private HeuristicLab.Core.Views.LogView logView;
    219237    private RefreshableHiveJobListView hiveExperimentListView;
     238    protected System.Windows.Forms.ComboBox priorityComboBox;
     239    private System.Windows.Forms.Button searchButton;
    220240  }
    221241}
  • addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs

    r12930 r16173  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
     25using System.Windows.Forms;
     26using HeuristicLab.Clients.Hive;
     27using HeuristicLab.Clients.Hive.JobManager.Views;
    2328using HeuristicLab.Core.Views;
    2429using HeuristicLab.MainForm;
     
    2833  [Content(typeof(HiveEngine), IsDefaultView = true)]
    2934  public sealed partial class HiveEngineView : ItemView {
     35    private readonly HiveResourceSelectorDialog hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Guid.Empty, Guid.Empty);
     36
    3037    public new HiveEngine Content {
    3138      get { return (HiveEngine)base.Content; }
     
    7077      base.OnContentChanged();
    7178      if (Content == null) {
    72         resourceIdsTextBox.Text = string.Empty;
    73         priorityTextBox.Text = string.Empty;
     79        projectNameTextBox.Text = string.Empty;
     80        priorityComboBox.SelectedIndex = 1;
    7481        executionTimeOnHiveTextBox.Text = string.Empty;
    7582        hiveExperimentListView.Content = null;
    7683        logView.Content = null;
    7784      } else {
    78         resourceIdsTextBox.Text = Content.ResourceNames;
    79         priorityTextBox.Text = Content.Priority.ToString();
     85        if (Content.ProjectId != null && Content.ProjectId != Guid.Empty) {
     86          var project = HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(Content.ProjectId));
     87          if (project != null) projectNameTextBox.Text = project.Name;
     88        } else {
     89          projectNameTextBox.Text = string.Empty;
     90        }
     91
     92        if (Content.Priority >= 0 && Content.Priority < priorityComboBox.Items.Count) {
     93          priorityComboBox.SelectedIndex = Content.Priority;
     94        } else {
     95          priorityComboBox.SelectedIndex = 1;
     96        }
     97
    8098        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
    8199        hiveExperimentListView.Content = Content.Jobs;
     
    86104    protected override void SetEnabledStateOfControls() {
    87105      base.SetEnabledStateOfControls();
    88       // Enable or disable controls based on whether the content is null or the view is set readonly
    89       if (Content != null) {
    90         resourceIdsTextBox.ReadOnly = this.ReadOnly;
    91         priorityTextBox.ReadOnly = this.ReadOnly;
    92       } else {
    93         resourceIdsTextBox.ReadOnly = false;
    94         priorityTextBox.ReadOnly = false;
     106
     107      searchButton.Enabled = Content != null && !ReadOnly && !Locked;
     108      projectNameTextBox.Enabled = Content != null && !ReadOnly && !Locked;
     109      priorityComboBox.Enabled = Content != null && !ReadOnly && !Locked;
     110    }
     111
     112    private void searchButton_Click(object sender, EventArgs e) {
     113      hiveResourceSelectorDialog.SelectedProjectId = Content != null ? Content.ProjectId : Guid.Empty;
     114      hiveResourceSelectorDialog.SelectedResourceIds = Content != null ? Content.ResourceIds : new List<Guid>();
     115
     116      var result = hiveResourceSelectorDialog.ShowDialog(this);
     117      if (result == DialogResult.OK) {
     118        var selectedProject = hiveResourceSelectorDialog.SelectedProject;
     119        if (selectedProject != null) {
     120          projectNameTextBox.Text = selectedProject.Name;
     121          Content.ProjectId = selectedProject.Id;
     122          Content.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     123        } else {
     124          projectNameTextBox.Text = string.Empty;
     125          Content.ProjectId = Guid.Empty;
     126          Content.ResourceIds = new List<Guid>();
     127        }
    95128      }
    96129    }
    97130
    98     #region Event Handlers (child controls)
    99     private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
    100       Content.ResourceNames = resourceIdsTextBox.Text;
     131    private void priorityComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     132      if (Content != null && Content.Priority != priorityComboBox.SelectedIndex) {
     133        Content.Priority = priorityComboBox.SelectedIndex;
     134      }
    101135    }
    102 
    103     private void priorityTextBox_Validated(object sender, EventArgs e) {
    104       Content.Priority = int.Parse(priorityTextBox.Text);
    105     }
    106     #endregion
    107136  }
    108137}
  • addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine/3.3/HiveEngine.cs

    r14913 r16173  
    4545
    4646    [Storable]
    47     public string ResourceNames { get; set; }
     47    public Guid ProjectId { get; set; }
     48
     49    [Storable]
     50    public IEnumerable<Guid> ResourceIds { get; set; }
    4851
    4952    [Storable]
     
    9497    #region constructors and cloning
    9598    public HiveEngine() {
    96       this.ResourceNames = "HEAL";
     99      this.ProjectId = Guid.Empty;
     100      this.ResourceIds = new List<Guid>();
    97101      this.Priority = 0;
    98102      this.log = new ThreadSafeLog();
     
    103107    protected HiveEngine(HiveEngine original, Cloner cloner)
    104108      : base(original, cloner) {
    105       this.ResourceNames = original.ResourceNames;
     109      this.ProjectId = original.ProjectId;
     110      this.ResourceIds = original.ResourceIds.ToList();
    106111      this.currentOperator = cloner.Clone(original.currentOperator);
    107112      this.priority = original.priority;
     
    145150        firstRun = false;
    146151      }
     152
     153      if (ProjectId == Guid.Empty)
     154        throw new ArgumentException("Cannot run HiveEngine. No project has been specified.");
     155
     156      if (!ResourceIds.Any())
     157        throw new ArgumentException("Cannot run HiveEngine. No resources have been specified.");
    147158
    148159      while (executionStack.Count > 0) {
     
    175186                }
    176187              }
    177             }
    178             catch {
     188            } catch {
    179189              executionStack.Push(coll); throw;
    180190            }
     
    187197          try {
    188198            next = operation.Operator.Execute((IExecutionContext)operation, cancellationToken);
    189           }
    190           catch (Exception ex) {
     199          } catch (Exception ex) {
    191200            executionStack.Push(operation);
    192201            if (ex is OperationCanceledException) throw ex;
     
    217226        }
    218227        return FindRandomParameter(ec.Parent);
    219       }
    220       catch { return null; }
     228      } catch { return null; }
    221229    }
    222230
     
    256264            random.Reset(random.Next());
    257265        }
     266
    258267        HiveClient.StartJob((e) => { log.LogException(e); }, refreshableJob, cancellationToken);
    259268
    260269        // do polling until experiment is finished and all jobs are downloaded
    261270        while (!refreshableJob.IsFinished()) {
     271          if (!refreshableJob.RefreshAutomatically && refreshableJob.Id != Guid.Empty)
     272            refreshableJob.RefreshAutomatically = true;
     273
    262274          Thread.Sleep(2000);
     275
    263276          this.ExecutionTimeOnHive = TimeSpan.FromMilliseconds(jobs.Sum(x => x.ExecutionTime.TotalMilliseconds));
    264277          cancellationToken.ThrowIfCancellationRequested();
    265278        }
     279
    266280        log.LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableJob.ToString(), refreshableJob.ExecutionTime));
    267281
     
    277291          scopes[j++] = scope;
    278292        }
     293
    279294        return scopes;
    280       }
    281       catch (OperationCanceledException e) {
     295      } catch (OperationCanceledException e) {
    282296        throw e;
    283       }
    284       catch (Exception e) {
     297      } catch (Exception e) {
    285298        log.LogException(e);
    286299        throw e;
    287       }
    288       finally {
     300      } finally {
    289301        DisposeJob(refreshableJob);
    290302      }
     
    293305    private RefreshableJob CreateJob() {
    294306      lock (locker) {
    295         var hiveExperiment = new Job();
    296         hiveExperiment.Name = "HiveEngine Run " + jobs.Count;
    297         hiveExperiment.DateCreated = DateTime.Now;
    298         hiveExperiment.ResourceNames = this.ResourceNames;
    299         var refreshableHiveExperiment = new RefreshableJob(hiveExperiment);
    300         refreshableHiveExperiment.IsDownloadable = false; // download happens automatically so disable button
     307        var hiveExperiment = new Job {
     308          Name = "HiveEngine Run " + jobs.Count,
     309          DateCreated = DateTime.Now,
     310          ProjectId = ProjectId,
     311          ResourceIds = ResourceIds.ToList(),
     312        };
     313
     314        var refreshableHiveExperiment = new RefreshableJob(hiveExperiment) {
     315          RefreshAutomatically = false,
     316          IsDownloadable = false // download happens automatically later on so disable button
     317        };
     318
    301319        jobs.Add(refreshableHiveExperiment);
     320
    302321        return refreshableHiveExperiment;
    303322      }
     
    319338    private void DeleteHiveExperiment(Guid jobId) {
    320339      HiveClient.TryAndRepeat(() => {
    321         HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(jobId));
     340        HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(jobId, JobState.StatisticsPending));
    322341      }, 5, string.Format("Could not delete jobs"));
    323     }
    324 
    325     private List<Guid> GetResourceIds() {
    326       return HiveServiceLocator.Instance.CallHiveService(service => {
    327         var resourceNames = ResourceNames.Split(';');
    328         var resourceIds = new List<Guid>();
    329         foreach (var resourceName in resourceNames) {
    330           Guid resourceId = service.GetResourceId(resourceName);
    331           if (resourceId == Guid.Empty) {
    332             throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName));
    333           }
    334           resourceIds.Add(resourceId);
    335         }
    336         return resourceIds;
    337       });
    338342    }
    339343  }
Note: See TracChangeset for help on using the changeset viewer.