-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5295 from NREL/5233_ValidateOSW
Fix #5233 - Validate OSW measures before running
- Loading branch information
Showing
13 changed files
with
329 additions
and
4 deletions.
There are no files selected for viewing
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,19 @@ | ||
{ | ||
"weather_file": "../../Examples/compact_osw/files/srrl_2013_amy.epw", | ||
"seed_file": "../example_model.osm", | ||
"measure_paths": ["../measures/"], | ||
"steps": [ | ||
{ | ||
"measure_dir_name": "FakeModelMeasure", | ||
"arguments": {} | ||
}, | ||
{ | ||
"measure_dir_name": "NON_EXISTING_MEASURE_THIS_SHOULD_BE_CAUGHT", | ||
"arguments": {} | ||
}, | ||
{ | ||
"measure_dir_name": "FakeReport", | ||
"arguments": {} | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
resources/workflow/invalid_measures/unloadable_measure.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,19 @@ | ||
{ | ||
"weather_file": "../../Examples/compact_osw/files/srrl_2013_amy.epw", | ||
"seed_file": "../example_model.osm", | ||
"measure_paths": ["../measures/"], | ||
"steps": [ | ||
{ | ||
"measure_dir_name": "FakeModelMeasure", | ||
"arguments": {} | ||
}, | ||
{ | ||
"measure_dir_name": "UnloadableMeasure", | ||
"arguments": {} | ||
}, | ||
{ | ||
"measure_dir_name": "FakeReport", | ||
"arguments": {} | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
resources/workflow/invalid_measures/wrong_measure_type_order.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,15 @@ | ||
{ | ||
"weather_file": "../../Examples/compact_osw/files/srrl_2013_amy.epw", | ||
"seed_file": "../example_model.osm", | ||
"measure_paths": ["../measures/"], | ||
"steps": [ | ||
{ | ||
"measure_dir_name": "FakeReport", | ||
"arguments": {} | ||
}, | ||
{ | ||
"measure_dir_name": "FakeModelMeasure", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class FakeModelMeasure < OpenStudio::Measure::ModelMeasure | ||
# human readable name | ||
def name | ||
# Measure name should be the title case of the class name. | ||
return 'A dumb ModelMeasure' | ||
end | ||
|
||
# human readable description | ||
def description | ||
return 'Does nothing' | ||
end | ||
|
||
# human readable description of modeling approach | ||
def modeler_description | ||
return 'Just for testing' | ||
end | ||
|
||
# define the arguments that the user will input | ||
def arguments(model) | ||
args = OpenStudio::Measure::OSArgumentVector.new | ||
|
||
return args | ||
end | ||
|
||
# define what happens when the measure is run | ||
def run(model, runner, user_arguments) | ||
super(model, runner, user_arguments) # Do **NOT** remove this line | ||
|
||
# use the built-in error checking | ||
if !runner.validateUserArguments(arguments(model), user_arguments) | ||
return false | ||
end | ||
|
||
# report final condition of model | ||
runner.registerFinalCondition("The FakeModelMeasure run.") | ||
|
||
return true | ||
end | ||
end | ||
|
||
# register the measure to be used by the application | ||
FakeModelMeasure.new.registerWithApplication |
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,44 @@ | ||
<?xml version="1.0"?> | ||
<measure> | ||
<schema_version>3.1</schema_version> | ||
<name>fake_model_measure</name> | ||
<uid>677b8fd3-2627-4516-b090-f6e47dc99fea</uid> | ||
<version_id>162465e5-b6f6-419f-ab5f-c2fc4bd549e0</version_id> | ||
<version_modified>2024-11-07T11:55:10Z</version_modified> | ||
<xml_checksum>82D8F881</xml_checksum> | ||
<class_name>FakeModelMeasure</class_name> | ||
<display_name>A dumb ModelMeasure</display_name> | ||
<description>Does nothing</description> | ||
<modeler_description>Just for testing</modeler_description> | ||
<arguments /> | ||
<outputs /> | ||
<provenances /> | ||
<tags> | ||
<tag>Envelope.Form</tag> | ||
</tags> | ||
<attributes> | ||
<attribute> | ||
<name>Measure Type</name> | ||
<value>ModelMeasure</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.9.0</identifier> | ||
<min_compatible>3.9.0</min_compatible> | ||
</version> | ||
<filename>measure.rb</filename> | ||
<filetype>rb</filetype> | ||
<usage_type>script</usage_type> | ||
<checksum>DDA977B0</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 |
---|---|---|
@@ -0,0 +1 @@ | ||
This doesnt have a xml |
Empty file.
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
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.