Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16998


Ignore:
Timestamp:
05/29/19 12:31:59 (5 years ago)
Author:
dpiringe
Message:

#2924:

  • in project HeuristicLab.CommandLineInterface changed output for options -> hidden options are not shown in the help box anymore
  • in project HeuristicLab.DynamicAssemblyTestApp:
    • added ApplicationAttributes
    • added full cancel/pause/resume support for class AppTest to test the same behaviour between main and child process
  • in project HeuristicLab:
    • changed auto generated Dockerfile -> only copies necessary projects -> speeds up the build process
    • in file HeuristicLab-3.3.csproj:
      • changed DockerDefaultTargetOS to Linux
      • removed reference HeuristicLab.DefinitionLanguage
      • added icon and manifest
    • deleted folder Properties with file launchSettings.json
    • changed the direct access to ApplicationTypes for OptimizeCommand and InspectCommand to new method IApplicationManager.GetInstances<T>(params object[] args)
  • added build script for docker image dockerImageBuild.ps1
Location:
branches/2924_DotNetCoreMigration
Files:
1 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2924_DotNetCoreMigration/HeuristicLab.CommandLineInterface/CLIConsole.cs

    r16985 r16998  
    2828      WriteHeader(cmdData);
    2929
    30       if(exception != null) WriteErrors(exception);
    31      
     30      if (exception != null) WriteErrors(exception);
     31
    3232      WriteSyntax(cmdData);
    3333
     
    6262      Console.WriteLine($"ERROR(S):");
    6363      AggregateException ae = exception as AggregateException;
    64       if(ae != null) {
    65         foreach(var e in ae.InnerExceptions) {
     64      if (ae != null) {
     65        foreach (var e in ae.InnerExceptions) {
    6666          Console.WriteLine($"  -> {e} ");
    6767        }
    6868      } else {
    6969        Console.WriteLine($"  -> {exception}");
    70       }     
     70      }
    7171      Console.WriteLine();
    7272    }
     
    9494      WriteBoxSeparatorLine();
    9595      foreach (OptionData opt in cmdData.Options)
    96         WriteBoxLine(
    97           ((opt.Shortcut != null) ?
    98             $"{(OptionData.ShortcutPrefix + opt.Shortcut).ToLower() + ",",-ShortcutWidth}" :
    99             $""
    100           ) +
    101           $"{(OptionData.LongformPrefix + opt.Identifier).ToLower()}",
    102           opt.Property?.PropertyType.GetPrettyName(),
    103           opt.Description
    104         );
     96        if (!opt.Hidden)
     97          WriteBoxLine(
     98            ((opt.Shortcut != null) ?
     99              $"{(OptionData.ShortcutPrefix + opt.Shortcut).ToLower() + ",",-ShortcutWidth}" :
     100              $""
     101            ) +
     102            $"{(OptionData.LongformPrefix + opt.Identifier).ToLower()}",
     103            opt.Property?.PropertyType.GetPrettyName(),
     104            opt.Description
     105          );
    105106      WriteBoxSeparatorLine();
    106107    }
  • branches/2924_DotNetCoreMigration/HeuristicLab.DynamicAssemblyTestApp/AppTest.cs

    r16985 r16998  
    11using System;
    22using System.IO;
     3using System.Threading;
    34using HeuristicLab.Common;
    45using HeuristicLab.Core;
     
    89namespace HeuristicLab.DynamicAssemblyTestApp {
    910  [Serializable]
     11  [Application("CLIOptimize", "")]
    1012  public class AppTest : ApplicationBase {
    1113
     14    #region Vars
     15    [NonSerialized]
     16    private IExecutable executable;
     17    [NonSerialized]
     18    private static AutoResetEvent autoResetEvent = new AutoResetEvent(false);
     19    [NonSerialized]
     20    private static object locker = new object();
     21    #endregion
     22
     23    #region Properties
    1224    public UniPath InputFilePath { get; set; } = null;
    1325    public UniPath OutputPath { get; set; } = null;
     26    #endregion
     27
     28    #region Constructors
     29    public AppTest() { }
     30    public AppTest(UniPath inputFilePath, UniPath outputPath) {
     31      InputFilePath = inputFilePath;
     32      OutputPath = outputPath;
     33    }
     34    #endregion
     35
    1436    public override void Run(ICommandLineArgument[] args) {
    15       ContentManager.Initialize(new PersistenceContentManager());
    16       IStorableContent content = ContentManager.Load(InputFilePath.ToString());
    17       IExecutable exec = content as IExecutable;
    18       if (exec != null) {
    19         exec.Start();
    20         IOptimizer optimizer = exec as IOptimizer;
    21         if (optimizer != null) {
    22           Console.WriteLine("\nRESULT(S):");
    23           int i = 1;
    24           foreach (var run in optimizer.Runs) {
    25             Console.WriteLine($"{"-------------------------------- RUN",35} {$"{i++:D3}" + " --------------------------------",-35}");
    26             foreach (var res in run.Results) {
    27               Console.WriteLine($"{res.Key,35} : {res.Value,-35}");
    28             }
     37      Init();
     38      lock (locker) {
     39        executable.Stopped += Executable_Stopped;
     40        executable.StartAsync();
     41      }
     42      autoResetEvent.WaitOne();
     43    }
     44
     45    public override void OnCancel() {
     46      lock (locker) {
     47        base.OnCancel();
     48        if (executable != null)
     49          executable.Stop();
     50      }
     51    }
     52
     53    public override void OnPause() {
     54      base.OnPause();
     55      lock (locker) {
     56        if (executable != null) executable.Pause();
     57      }
     58    }
     59
     60    public override void OnResume() {
     61      base.OnResume();
     62      lock (locker) {
     63        if (executable != null)
     64          executable.StartAsync();
     65      }
     66    }
     67
     68    #region Helper
     69    private void Init() {
     70      lock (locker) {
     71        ContentManager.Initialize(new PersistenceContentManager());
     72        IStorableContent content = ContentManager.Load(InputFilePath.ToString());
     73        executable = content as IExecutable;
     74        if (executable == null)
     75          throw new NotSupportedException("The given file does not contain any algorithm to start.");
     76      }
     77    }
     78
     79    private void Executable_Stopped(object sender, EventArgs e) {
     80      lock (locker) {
     81        IOptimizer optimizer = executable as IOptimizer;
     82        if (optimizer != null) PrintResults(optimizer);
     83        ContentManager.Save((IStorableContent)executable, OutputPath.ToString() + Path.DirectorySeparatorChar + "result.hl", true);
     84      }
     85      autoResetEvent.Set();
     86    }
     87
     88    private void PrintResults(IOptimizer optimizer) {
     89      lock (locker) {
     90        Console.WriteLine("\nRESULT(S):");
     91        int i = 1;
     92        foreach (var run in optimizer.Runs) {
     93          Console.WriteLine($"{"-------------------------------- RUN",35} {$"{i++:D3}" + " --------------------------------",-35}");
     94          foreach (var res in run.Results) {
     95            Console.WriteLine($"{res.Key,35} : {res.Value,-35}");
    2996          }
    3097        }
    31        
    32         ContentManager.Save((IStorableContent)exec, OutputPath.ToString() + Path.DirectorySeparatorChar + "result.hl", true);
    33       } else throw new NotSupportedException("The given file does not contain any algorithm to start.");
     98      }
    3499    }
     100    #endregion
    35101  }
    36102}
  • branches/2924_DotNetCoreMigration/HeuristicLab.DynamicAssemblyTestApp/InspectApplication.cs

    r16985 r16998  
    77namespace HeuristicLab.DynamicAssemblyTestApp {
    88  [Serializable]
     9  [Application("CLIInspect", "")]
    910  public class InspectApplication : ApplicationBase {
    1011    public UniPath InputFilePath { get; set; }
     12
     13    public InspectApplication() { }
     14
     15    public InspectApplication(UniPath inputFilePath) {
     16      InputFilePath = inputFilePath;
     17    }
     18
    1119    public override void Run(ICommandLineArgument[] args) {
    1220      ContentManager.Initialize(new PersistenceContentManager());
  • branches/2924_DotNetCoreMigration/HeuristicLab/3.3/ApplicationCommand.cs

    r16985 r16998  
    11using System;
    2 using System.Collections.Generic;
    32using System.IO;
    43using HeuristicLab.CommandLineInterface;
     
    1211  }
    1312
    14   [HeuristicLab.CommandLineInterface.Application(
     13  [CommandLineInterface.Application(
    1514    "HL", "1.0.0.0",
    1615    SubCommands = new Type[] {
     
    3231
    3332    public void Execute() {
    34       if(StartAsRunnerHost) {
     33      if (StartAsRunnerHost) {
    3534        StartupRunnerHost();
    3635      } else {
    3736        SetupIsolation();
    3837      }
    39      
    4038    }
    4139
     
    4846      else
    4947        Console.Error.WriteLine("Cannot deserialize data from stdin to a type of RunnerConfig!");
    50 
    5148    }
    5249
  • branches/2924_DotNetCoreMigration/HeuristicLab/3.3/Dockerfile

    r16985 r16998  
    1 #Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
    2 #For more information, please see https://aka.ms/containercompat
    3 
    4 FROM mcr.microsoft.com/dotnet/core/runtime:3.0-nanoserver-1809 AS base
     1FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim AS base
    52WORKDIR /app
    63
    7 FROM mcr.microsoft.com/dotnet/core/sdk:3.0-nanoserver-1809 AS build
     4FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
    85WORKDIR /src
    9 COPY ["HeuristicLab/3.3/HeuristicLab-3.3.csproj", "HeuristicLab/3.3/"]
    10 COPY ["HeuristicLab.CommandLineInterface/HeuristicLab.CommandLineInterface.csproj", "HeuristicLab.CommandLineInterface/"]
    11 COPY ["HeuristicLab.Common/3.3/HeuristicLab.Common-3.3.csproj", "HeuristicLab.Common/3.3/"]
    12 COPY ["HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj", "HeuristicLab.PluginInfrastructure/3.3/"]
    13 COPY ["HeuristicLab.DefinitionLanguage/HeuristicLab.DefinitionLanguage.csproj", "HeuristicLab.DefinitionLanguage/"]
    14 COPY ["HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj", "HeuristicLab.Core/3.3/"]
    15 COPY ["HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj", "HeuristicLab.Persistence/3.3/"]
    16 COPY ["HeuristicLab.Tracing/3.3/HeuristicLab.Tracing-3.3.csproj", "HeuristicLab.Tracing/3.3/"]
    17 COPY ["HeuristicLab.Common.Resources/3.3/HeuristicLab.Common.Resources-3.3.csproj", "HeuristicLab.Common.Resources/3.3/"]
    18 COPY ["HeuristicLab.Collections/3.3/HeuristicLab.Collections-3.3.csproj", "HeuristicLab.Collections/3.3/"]
    19 COPY ["HeuristicLab.DynamicAssemblyTestApp/HeuristicLab.DynamicAssemblyTestApp.csproj", "HeuristicLab.DynamicAssemblyTestApp/"]
    20 COPY ["HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj", "HeuristicLab.Optimization/3.3/"]
    21 COPY ["HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj", "HeuristicLab.Data/3.3/"]
    22 COPY ["HeuristicLab.Parameters/3.3/HeuristicLab.Parameters-3.3.csproj", "HeuristicLab.Parameters/3.3/"]
    23 COPY ["HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj", "HeuristicLab.Operators/3.3/"]
     6COPY ["HeuristicLab/3.3/", "HeuristicLab/3.3/"]
     7COPY ["HeuristicLab.CommandLineInterface/", "HeuristicLab.CommandLineInterface/"]
     8COPY ["HeuristicLab.Common/3.3/", "HeuristicLab.Common/3.3/"]
     9COPY ["HeuristicLab.PluginInfrastructure/3.3/", "HeuristicLab.PluginInfrastructure/3.3/"]
     10COPY ["HeuristicLab.DynamicAssemblyTestApp/", "HeuristicLab.DynamicAssemblyTestApp/"]
     11COPY ["HeuristicLab.Core/3.3/", "HeuristicLab.Core/3.3/"]
     12COPY ["HeuristicLab.Persistence/3.3/", "HeuristicLab.Persistence/3.3/"]
     13COPY ["HeuristicLab.Tracing/3.3/", "HeuristicLab.Tracing/3.3/"]
     14COPY ["HeuristicLab.Common.Resources/3.3/", "HeuristicLab.Common.Resources/3.3/"]
     15COPY ["HeuristicLab.Collections/3.3/", "HeuristicLab.Collections/3.3/"]
     16COPY ["HeuristicLab.Optimization/3.3/", "HeuristicLab.Optimization/3.3/"]
     17COPY ["HeuristicLab.Data/3.3/", "HeuristicLab.Data/3.3/"]
     18COPY ["HeuristicLab.Parameters/3.3/", "HeuristicLab.Parameters/3.3/"]
     19COPY ["HeuristicLab.Operators/3.3/", "HeuristicLab.Operators/3.3/"]
    2420RUN dotnet restore "HeuristicLab/3.3/HeuristicLab-3.3.csproj"
    25 COPY . .
    2621WORKDIR "/src/HeuristicLab/3.3"
    2722RUN dotnet build "HeuristicLab-3.3.csproj" -c Release -o /app
  • branches/2924_DotNetCoreMigration/HeuristicLab/3.3/HeuristicLab-3.3.csproj

    r16985 r16998  
    44    <OutputType>Exe</OutputType>
    55    <TargetFramework>netcoreapp3.0</TargetFramework>
    6     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    7     <DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
     6    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
     7    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    88    <Copyright>(c) 2002-2018 HEAL</Copyright>
    99    <Product>HeuristicLab</Product>
     
    1313    <AssemblyFileVersion>3.3.15.0</AssemblyFileVersion>
    1414    <RootNamespace>HeuristicLab</RootNamespace>
     15    <ApplicationIcon>HeuristicLab.ico</ApplicationIcon>
     16    <ApplicationManifest>app.manifest</ApplicationManifest>
    1517  </PropertyGroup>
    1618
     
    2325  </ItemGroup>
    2426
    25 
    2627  <ItemGroup>
    2728    <ProjectReference Include="..\..\HeuristicLab.CommandLineInterface\HeuristicLab.CommandLineInterface.csproj" />
    2829    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj" />
    29     <ProjectReference Include="..\..\HeuristicLab.DefinitionLanguage\HeuristicLab.DefinitionLanguage.csproj" />
    3030    <ProjectReference Include="..\..\HeuristicLab.DynamicAssemblyTestApp\HeuristicLab.DynamicAssemblyTestApp.csproj" />
    3131    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj" />
  • branches/2924_DotNetCoreMigration/HeuristicLab/3.3/InspectCommand.cs

    r16985 r16998  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.IO;
     1using System.IO;
     2using System.Linq;
    43using HeuristicLab.CommandLineInterface;
    5 using HeuristicLab.DynamicAssemblyTestApp;
    64using HeuristicLab.PluginInfrastructure;
    75
     
    2119          QuietMode = false,
    2220          AssembliesToLoad = Settings.assemblyInfos,
    23           StartApplication = new InspectApplication() {
    24             InputFilePath = new UniPath(Input)
    25           }
     21          StartApplication =
     22            ApplicationManager.Manager.GetInstances<IApplication>(new UniPath(Input))
     23            .Where(x => x.Name.Equals("CLIInspect"))
     24            .First()
     25
    2626        });
    2727      }
    28      
    2928    }
    3029  }
  • branches/2924_DotNetCoreMigration/HeuristicLab/3.3/OptimizeCommand.cs

    r16985 r16998  
    1 using System.Collections.Generic;
    2 using System.IO;
     1using System.IO;
     2using System.Linq;
    33using HeuristicLab.CommandLineInterface;
    4 using HeuristicLab.DynamicAssemblyTestApp;
    54using HeuristicLab.PluginInfrastructure;
    65
     
    2726          QuietMode = Quiet,
    2827          AssembliesToLoad = Settings.assemblyInfos,
    29           StartApplication = new AppTest() {
    30             InputFilePath = new UniPath(Input),
    31             OutputPath = new UniPath(Output ?? Input.Replace(Path.GetFileName(Input), ""))
    32           }
     28          StartApplication =
     29            ApplicationManager.Manager.GetInstances<IApplication>(
     30              new UniPath(Input),
     31              new UniPath(Output ?? Input.Replace(Path.GetFileName(Input), ""))
     32            ).Where(x => x.Name.Equals("CLIOptimize"))
     33             .First()
    3334        });
    3435      }
Note: See TracChangeset for help on using the changeset viewer.