lib/openstudio/analysis/formulation.rb in openstudio-analysis-1.3.3 vs lib/openstudio/analysis/formulation.rb in openstudio-analysis-1.3.4

- old
+ new

@@ -1,38 +1,8 @@ # ******************************************************************************* -# OpenStudio(R), Copyright (c) 2008-2023, 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, -# this list of conditions and the following disclaimer. -# -# (2) Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# (3) Neither the name of the copyright holder nor the names of any contributors -# may be used to endorse or promote products derived from this software without -# specific prior written permission from the respective party. -# -# (4) Other than as required in clauses (1) and (2), distributions in any form -# of modifications or other derivative works may not use the "OpenStudio" -# trademark, "OS", "os", or any other confusingly similar designation without -# specific prior written permission from Alliance for Sustainable Energy, LLC. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES -# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. +# See also https://openstudio.net/license # ******************************************************************************* # OpenStudio formulation class handles the generation of the OpenStudio Analysis format. module OpenStudio module Analysis @@ -57,10 +27,19 @@ attr_reader :outputs attr_accessor :display_name attr_accessor :workflow attr_accessor :algorithm attr_accessor :osw_path + attr_accessor :download_zip + attr_accessor :download_reports + attr_accessor :download_osw + attr_accessor :download_osm + attr_accessor :cli_debug + attr_accessor :cli_verbose + attr_accessor :initialize_worker_timeout + attr_accessor :run_workflow_timeout + attr_accessor :upload_results_timeout # the attributes below are used for packaging data into the analysis zip file attr_reader :weather_files attr_reader :seed_models attr_reader :worker_inits @@ -79,10 +58,19 @@ @workflow = OpenStudio::Analysis::Workflow.new # Initialize child objects (expect workflow) @weather_file = WeatherFile.new @seed_model = SeedModel.new @algorithm = OpenStudio::Analysis::AlgorithmAttributes.new + @download_zip = true + @download_reports = true + @download_osw = true + @download_osm = true + @cli_debug = "--debug" + @cli_verbose = "--verbose" + @initialize_worker_timeout = 28800 + @run_workflow_timeout = 28800 + @upload_results_timeout = 28800 # Analysis Zip attributes @weather_files = SupportFiles.new @seed_models = SupportFiles.new @worker_inits = SupportFiles.new @@ -118,10 +106,101 @@ # @param path [String] Path to the weather file or folder. def weather_file=(file) @weather_file[:file] = file end + # Set the value for 'download_zip' + # + # @param value [Boolean] The value for 'download_zip' + def download_zip=(value) + if [true, false].include?(value) + @download_zip = value + else + raise ArgumentError, "Invalid value for 'download_zip'. Only true or false allowed." + end + end + + # Set the value for 'download_reports' + # + # @param value [Boolean] The value for 'download_reports' + def download_reports=(value) + if [true, false].include?(value) + @download_reports = value + else + raise ArgumentError, "Invalid value for 'download_reports'. Only true or false allowed." + end + end + + # Set the value for 'download_osw' + # + # @param value [Boolean] The value for 'download_osw' + def download_osw=(value) + if [true, false].include?(value) + @download_osw = value + else + raise ArgumentError, "Invalid value for 'download_osw'. Only true or false allowed." + end + end + + # Set the value for 'download_osm' + # + # @param value [Boolean] The value for 'download_osm' + def download_osm=(value) + if [true, false].include?(value) + @download_osm = value + else + raise ArgumentError, "Invalid value for 'download_osm'. Only true or false allowed." + end + end + + # Set the value for 'cli_debug' + # + # @param value [Boolean] The value for 'cli_debug' + def cli_debug=(value) + @cli_debug = value + end + + # Set the value for 'cli_verbose' + # + # @param value [Boolean] The value for 'cli_verbose' + def cli_verbose=(value) + @cli_verbose = value + end + + # Set the value for 'run_workflow_timeout' + # + # @param value [Integer] The value for 'run_workflow_timeout' + def run_workflow_timeout=(value) + if value.is_a?(Integer) + @run_workflow_timeout = value + else + raise ArgumentError, "Invalid value for 'run_workflow_timeout'. Only integer values allowed." + end + end + + # Set the value for 'initialize_worker_timeout' + # + # @param value [Integer] The value for 'initialize_worker_timeout' + def initialize_worker_timeout=(value) + if value.is_a?(Integer) + @initialize_worker_timeout = value + else + raise ArgumentError, "Invalid value for 'initialize_worker_timeout'. Only integer values allowed." + end + end + + # Set the value for 'upload_results_timeout' + # + # @param value [Integer] The value for 'upload_results_timeout' + def upload_results_timeout=(value) + if value.is_a?(Integer) + @upload_results_timeout = value + else + raise ArgumentError, "Invalid value for 'upload_results_timeout'. Only integer values allowed." + end + end + # Add an output of interest to the problem formulation # # @param output_hash [Hash] Hash of the output variable in the legacy format # @option output_hash [String] :display_name Name to display # @option output_hash [String] :display_name_short A shorter display name @@ -231,14 +310,19 @@ # log: could not find weather file warn 'Could not resolve a valid weather file. Check paths to weather files' end h[:analysis][:file_format_version] = version - h[:analysis][:cli_debug] = "--debug" - h[:analysis][:cli_verbose] = "--verbose" - h[:analysis][:run_workflow_timeout] = 28800 - h[:analysis][:upload_results_timeout] = 28800 - h[:analysis][:initialize_worker_timeout] = 28800 + h[:analysis][:cli_debug] = @cli_debug + h[:analysis][:cli_verbose] = @cli_verbose + h[:analysis][:run_workflow_timeout] = @run_workflow_timeout + h[:analysis][:upload_results_timeout] = @upload_results_timeout + h[:analysis][:initialize_worker_timeout] = @initialize_worker_timeout + h[:analysis][:download_zip] = @download_zip + h[:analysis][:download_reports] = @download_reports + h[:analysis][:download_osw] = @download_osw + h[:analysis][:download_osm] = @download_osm + #-BLB I dont think this does anything. server_scripts are run if they are in #the /scripts/analysis or /scripts/data_point directories #but nothing is ever checked in the OSA. # h[:analysis][:server_scripts] = {}