lib/openstudio/extension/runner.rb in openstudio-extension-0.3.2 vs lib/openstudio/extension/runner.rb in openstudio-extension-0.4.0
- old
+ new
@@ -1,7 +1,7 @@
# *******************************************************************************
-# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
+# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
@@ -71,19 +71,22 @@
# if the dirname contains a runner.conf file, then use the config file to specify the parameters
@options = OpenStudio::Extension::RunnerConfig.default_config
# ORDER of PRECEDENCE: default config < runner.conf file < options passed in directly
- if File.exist?(File.join(dirname, OpenStudio::Extension::RunnerConfig::FILENAME)) && options.empty?
+ if File.exist?(File.join(dirname, OpenStudio::Extension::RunnerConfig::FILENAME))
puts 'Using runner options from runner.conf file'
runner_config = OpenStudio::Extension::RunnerConfig.new(dirname)
# use the default values overriden with runner.conf values
@options = @options.merge(runner_config.options)
end
- # use the passed values or defaults overriden by passed options
- @options = @options.merge(options)
+ if !options.empty?
+ puts 'Merging in passed-in options'
+ # use the passed values or defaults overriden by passed options
+ @options = @options.merge(options)
+ end
puts "Initializing runner with dirname: '#{dirname}' and options: #{@options}"
@dirname = File.absolute_path(dirname)
# use passed options, otherwise assume @dirname
@@ -658,10 +661,19 @@
STDOUT.flush
else
puts 'simulations are not performed, since to the @options[:run_simulations] is set to false'
end
- # DLM: this does not always return false for failed CLI runs, consider checking for failed.job file as backup test
+ if @options[:run_simulations]
+ # Additional checks for failed CLI
+ if File.exist?(File.join(run_dir, 'failed.job'))
+ result = false
+ end
+
+ if !File.exist?(File.join(run_dir, 'finished.job'))
+ result = false
+ end
+ end
return result
end
# run osws, return any failure messages