-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for an outdated reporting measure taking no model arg + re…
…organize test folder so that example_model.osm is shared
- Loading branch information
Showing
12 changed files
with
329 additions
and
86 deletions.
There are no files selected for viewing
File renamed without changes.
89 changes: 89 additions & 0 deletions
89
resources/workflow/measures/OutdatedReportingMeasure/measure.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# start the measure | ||
class OutdatedReportingMeasure < OpenStudio::Ruleset::ReportingUserScript | ||
# human readable name | ||
def name | ||
# Measure name should be the title case of the class name. | ||
return 'Outdated Reporting Measure' | ||
end | ||
|
||
# human readable description | ||
def description | ||
return 'ReportingMeasure is an old ReportingUserScript' | ||
end | ||
|
||
# human readable description of modeling approach | ||
def modeler_description | ||
return "The ReportingMeasure Measure derives the deprecated ReportingUserScript class, and arguments doesn't take model" | ||
end | ||
|
||
# define the arguments that the user will input | ||
def arguments | ||
args = OpenStudio::Measure::OSArgumentVector.new | ||
|
||
# bool argument to report report_drybulb_temp | ||
report_drybulb_temp = OpenStudio::Measure::OSArgument.makeBoolArgument('report_drybulb_temp', true) | ||
report_drybulb_temp.setDisplayName('Add output variables for Drybulb Temperature') | ||
report_drybulb_temp.setDescription('Will add drybulb temp and report min/mix value in html.') | ||
report_drybulb_temp.setValue(true) | ||
args << report_drybulb_temp | ||
|
||
return args | ||
end | ||
|
||
# define the outputs that the measure will create | ||
def outputs | ||
outs = OpenStudio::Measure::OSOutputVector.new | ||
|
||
# this measure does not produce machine readable outputs with registerValue, return an empty list | ||
|
||
return outs | ||
end | ||
|
||
# return a vector of IdfObject's to request EnergyPlus objects needed by the run method | ||
# Warning: Do not change the name of this method to be snake_case. The method must be lowerCamelCase. | ||
def energyPlusOutputRequests(runner, user_arguments) | ||
super(runner, user_arguments) # Do **NOT** remove this line | ||
|
||
result = OpenStudio::IdfObjectVector.new | ||
|
||
# use the built-in error checking | ||
unless runner.validateUserArguments(arguments, user_arguments) | ||
return result | ||
end | ||
|
||
if runner.getBoolArgumentValue('report_drybulb_temp', user_arguments) | ||
request = OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Drybulb Temperature,Hourly;').get | ||
result << request | ||
end | ||
|
||
return result | ||
end | ||
|
||
# define what happens when the measure is run | ||
def run(runner, user_arguments) | ||
super(runner, user_arguments) | ||
|
||
# get the last model and sql file | ||
model = runner.lastOpenStudioModel | ||
if model.empty? | ||
runner.registerError('Cannot find last model.') | ||
return false | ||
end | ||
model = model.get | ||
|
||
# use the built-in error checking (need model) | ||
if !runner.validateUserArguments(arguments, user_arguments) | ||
return false | ||
end | ||
|
||
# get measure arguments | ||
report_drybulb_temp = runner.getBoolArgumentValue('report_drybulb_temp', user_arguments) | ||
|
||
runner.registerValue("report_drybulb_temp", report_drybulb_temp) | ||
|
||
return true | ||
end | ||
end | ||
|
||
# register the measure to be used by the application | ||
OutdatedReportingMeasure.new.registerWithApplication |
63 changes: 63 additions & 0 deletions
63
resources/workflow/measures/OutdatedReportingMeasure/measure.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0"?> | ||
<measure> | ||
<schema_version>3.1</schema_version> | ||
<name>outdated_reporting_measure</name> | ||
<uid>681fa83e-57e1-439b-8bef-d3d234ac6f68</uid> | ||
<version_id>ed691a5a-2114-4635-b462-cde7102e0df1</version_id> | ||
<version_modified>2023-11-15T20:56:44Z</version_modified> | ||
<xml_checksum>C3203FCF</xml_checksum> | ||
<class_name>OutdatedReportingMeasure</class_name> | ||
<display_name>Outdated Reporting Measure</display_name> | ||
<description>ReportingMeasure is an old ReportingUserScript</description> | ||
<modeler_description>The ReportingMeasure Measure derives the deprecated ReportingUserScript class, and arguments doesn't take model</modeler_description> | ||
<arguments> | ||
<argument> | ||
<name>report_drybulb_temp</name> | ||
<display_name>Add output variables for Drybulb Temperature</display_name> | ||
<description>Will add drybulb temp and report min/mix value in html.</description> | ||
<type>Boolean</type> | ||
<required>true</required> | ||
<model_dependent>false</model_dependent> | ||
<choices> | ||
<choice> | ||
<value>true</value> | ||
<display_name>true</display_name> | ||
</choice> | ||
<choice> | ||
<value>false</value> | ||
<display_name>false</display_name> | ||
</choice> | ||
</choices> | ||
</argument> | ||
</arguments> | ||
<outputs /> | ||
<provenances /> | ||
<tags> | ||
<tag>Envelope.Form</tag> | ||
</tags> | ||
<attributes> | ||
<attribute> | ||
<name>Measure Type</name> | ||
<value>ReportingMeasure</value> | ||
<datatype>string</datatype> | ||
</attribute> | ||
<attribute> | ||
<name>Measure Language</name> | ||
<value>Ruby</value> | ||
<datatype>string</datatype> | ||
</attribute> | ||
</attributes> | ||
<files> | ||
<file> | ||
<version> | ||
<software_program>OpenStudio</software_program> | ||
<identifier>3.7.0</identifier> | ||
<min_compatible>3.7.0</min_compatible> | ||
</version> | ||
<filename>measure.rb</filename> | ||
<filetype>rb</filetype> | ||
<usage_type>script</usage_type> | ||
<checksum>11D2080F</checksum> | ||
</file> | ||
</files> | ||
</measure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
$os_build/Products/openstudio measure new \ | ||
--class-name ModelMeasureRegistersError \ | ||
--type ModelMeasure \ | ||
--class-name OutdatedReportingMeasure \ | ||
--type ReportingMeasure \ | ||
--language Ruby \ | ||
--name "Model Measure Registers Error" \ | ||
--description "Model Measure Registers Error" \ | ||
--modeler-description "The Model Measure, in the run method does runner.registerError" \ | ||
--taxonomy-tag "Envelope.Form" ./ModelMeasureRegistersError | ||
--name "Outdated Reporting Measure" \ | ||
--description "ReportingMeasure is an old ReportingUserScript" \ | ||
--modeler-description "The ReportingMeasure Measure derives the deprecated ReportingUserScript class, and arguments doesn't take model" \ | ||
--taxonomy-tag "Envelope.Form" ./OutdatedReportingMeasure |
11 changes: 11 additions & 0 deletions
11
resources/workflow/outdated_measures/outdatedreportingmeasure.osw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"weather_file": "../../Examples/compact_osw/files/srrl_2013_amy.epw", | ||
"seed_file": "../example_model.osm", | ||
"measure_paths": ["../measures/"], | ||
"steps": [ | ||
{ | ||
"measure_dir_name": "OutdatedReportingMeasure", | ||
"arguments": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
|
||
from workflow_helpers import run_workflow | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"is_labs", | ||
[pytest.param(True, id="labs"), pytest.param(False, id="classic")], | ||
) | ||
def test_outdated_reportingmeasure(osclipath, is_labs: bool): | ||
suffix = "labs" if is_labs else "classic" | ||
runDir, r = run_workflow( | ||
osclipath=osclipath, | ||
base_osw_name="outdatedreportingmeasure.osw", | ||
suffix=suffix, | ||
is_labs=is_labs, | ||
verbose=False, | ||
debug=True, | ||
post_process_only=True, | ||
) | ||
r.check_returncode() | ||
assert r.returncode == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.