Changeset 18045


Ignore:
Timestamp:
08/31/21 15:43:06 (3 months ago)
Author:
dpiringe
Message:

#3026

  • code cleanup
  • fixed a bug in ValueParameterConverter which prevented successful injection
  • changed error handling in method Main.HeadlessRun and Runner.Run
Location:
branches/3026_IntegrationIntoSymSpace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs

    r18041 r18045  
    1212  internal static class Runner {
    1313    internal static void Run(string template, string config, string outputFile) {
    14       try {
    15         InstantiatorResult instantiatorResult = JsonTemplateInstantiator.Instantiate(template, config);
    16         IOptimizer optimizer = instantiatorResult.Optimizer;
    17         IEnumerable<IResultJsonItem> configuredResultItem = instantiatorResult.ConfiguredResultItems;
     14      InstantiatorResult instantiatorResult = JsonTemplateInstantiator.Instantiate(template, config);
     15      IOptimizer optimizer = instantiatorResult.Optimizer;
     16      IEnumerable<IResultJsonItem> configuredResultItem = instantiatorResult.ConfiguredResultItems;
    1817
    19         optimizer.Runs.Clear();
    20         if (optimizer is EngineAlgorithm e)
    21           e.Engine = new ParallelEngine.ParallelEngine();
     18      optimizer.Runs.Clear();
     19      if (optimizer is EngineAlgorithm e)
     20        e.Engine = new ParallelEngine.ParallelEngine();
    2221
    23         Task task = optimizer.StartAsync();
    24         while (!task.IsCompleted) {
    25           WriteResultsToFile(outputFile, optimizer, configuredResultItem);
    26           Thread.Sleep(100);
    27         }
     22      Task task = optimizer.StartAsync();
     23      while (!task.IsCompleted) {
     24        WriteResultsToFile(outputFile, optimizer, configuredResultItem);
     25        Thread.Sleep(100);
     26      }
    2827
    29         WriteResultsToFile(outputFile, optimizer, configuredResultItem);
    30       } catch (Exception e) {
    31         Console.Error.WriteLine($"{e.Message} \n\n\n\n {e.StackTrace}");
    32         File.WriteAllText(outputFile, e.Message + "\n\n\n\n" + e.StackTrace);
    33         Environment.Exit(-1);
    34       }
     28      WriteResultsToFile(outputFile, optimizer, configuredResultItem);
    3529    }
    3630
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs

    r18043 r18045  
    1111
    1212    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    13       IParameterizedItem pItem = item as IParameterizedItem;
     13      var pItem = item as IParameterizedItem;
    1414
    1515      if(data.Children != null) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs

    r18044 r18045  
    4343      StringArrayJsonItem allowedInputVariables = null;
    4444
    45 
    4645      // search first for the items (cache them, because the
    4746      // order is important for injection)
    4847      foreach (var child in data.Children) {
    49 
    5048        if (child.Path.EndsWith(Dataset))
    5149          dataset = child as DoubleMatrixJsonItem;
     
    5856        else if (child.Path.EndsWith(AllowedInputVariables))
    5957          allowedInputVariables = child as StringArrayJsonItem;
    60 
    6158      }
    6259
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs

    r18043 r18045  
    2020    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
    2121      IValueLookupParameter param = value as IValueLookupParameter;
    22 
    2322      IValueLookupJsonItem item = new ValueLookupJsonItem();
    2423
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs

    r18043 r18045  
    1313      IParameter parameter = value as IParameter;
    1414
    15       if (!(data is EmptyJsonItem)) {
    16         if (parameter.ActualValue == null)
    17           parameter.ActualValue = Instantiate(parameter.DataType);
    18         root.Inject(parameter.ActualValue, data, root);
    19       }
     15      if (parameter.ActualValue == null)
     16        parameter.ActualValue = Instantiate(parameter.DataType);
     17      root.Inject(parameter.ActualValue, data, root);
    2018    }
    2119
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.PluginInfrastructure/3.3/Main.cs

    r18040 r18045  
    5656
    5757    public static void HeadlessRun(string[] args) {
    58       string pluginPath = Path.GetFullPath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
    59       var pluginManager = new PluginManager(pluginPath);
    60       pluginManager.DiscoverAndCheckPlugins();
     58      try {
     59        string pluginPath = Path.GetFullPath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
     60        var pluginManager = new PluginManager(pluginPath);
     61        pluginManager.DiscoverAndCheckPlugins();
    6162
    62       var arguments = CommandLineArgumentHandling.GetArguments(args);
    63       foreach (var argument in arguments) {
    64         if (argument is StartArgument) {
    65           var arg = (StartArgument)argument;
    66           var appDesc = (from desc in pluginManager.Applications
    67                          where desc.Name.Equals(arg.Value)
    68                          select desc).SingleOrDefault();
    69           if (appDesc != null) {
    70             try {
     63        var arguments = CommandLineArgumentHandling.GetArguments(args);
     64        foreach (var argument in arguments) {
     65          if (argument is StartArgument) {
     66            var arg = (StartArgument)argument;
     67            var appDesc = (from desc in pluginManager.Applications
     68                           where desc.Name.Equals(arg.Value)
     69                           select desc).SingleOrDefault();
     70            if (appDesc != null) {
    7171              pluginManager.Run(appDesc, arguments);
    72             } catch (Exception e) {
    73               Console.WriteLine(e.Message);
    7472            }
    7573          }
    7674        }
     75      } catch (Exception e) {
     76        Console.Error.WriteLine($"{e.Message} \n\n {e.StackTrace}");
     77        Environment.Exit(-1);
    7778      }
    7879    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab/3.3/HeuristicLab-3.3.csproj

    r16565 r18045  
    2323    <OldToolsVersion>3.5</OldToolsVersion>
    2424    <UpgradeBackupLocation />
     25    <IsWebBootstrapper>false</IsWebBootstrapper>
     26    <TargetFrameworkProfile>
     27    </TargetFrameworkProfile>
    2528    <PublishUrl>publish\</PublishUrl>
    2629    <Install>true</Install>
     
    3538    <ApplicationRevision>0</ApplicationRevision>
    3639    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    37     <IsWebBootstrapper>false</IsWebBootstrapper>
    3840    <UseApplicationTrust>false</UseApplicationTrust>
    3941    <BootstrapperEnabled>true</BootstrapperEnabled>
    40     <TargetFrameworkProfile>
    41     </TargetFrameworkProfile>
    4242  </PropertyGroup>
    4343  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Note: See TracChangeset for help on using the changeset viewer.