Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native support for measure argument methods in OsLib_HelperMethods #5142

Merged
merged 12 commits into from
Apr 12, 2024

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Apr 11, 2024

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

…S >= 10.14 supports it, and E+ is 10.15 minimum anyways
* Try to align getPastStepValuesForName on check_upstream_measure_for_arg in what it picks for measure name
* getPastStepValuesForMeasure: allow matching on either the WorkflowStep's measureDirName or name, or the WorkflowStepResult's measureName
* Scope the test blocks for readability and avoiding side effects (less chances of making a mistake)
@jmarrec jmarrec added the Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. label Apr 11, 2024
@jmarrec jmarrec self-assigned this Apr 11, 2024
Comment on lines +789 to +794
// This function aims to replace OsLib_HelperMethods.createRunVariables
// TODO: should this call validateUserArguments like the ruby counterpart? At least it validates that the defaults are supposed to match etc
if (!validateUserArguments(script_arguments, user_arguments)) {
registerError("Invalid argument values.");
LOG_AND_THROW("Invalid argument values.");
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: do we want this? I think we do.

Comment on lines +802 to +806
if (arg.hasValue()) {
argument_values[name] = arg.valueAsJSON();
} else if (arg.hasDefaultValue()) {
// TODO: is this wanted?
argument_values[name] = arg.defaultValueAsJSON();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: do we include defaultValue if not value?

Comment on lines +820 to +830
// TODO: should we match on any of these three?
if (istringEqual(measureName, step.measureDirName())) { // The directory name, eg `IncreaseWallRValue`
LOG(Trace, "Step matches on measureDirName");
} else if (auto s_ = step.name(); istringEqual(measureName, *s_)) { // An optional, abritrary one
LOG(Trace, "Step matches on name");
} else if (auto s_ = stepResult_->measureName();
istringEqual(measureName, *s_)) { // The xml one, eg `increase_insulation_r_value_for_exterior_walls_by_percentage`
LOG(Trace, "Step matches on Step Result's measureName");
} else {
continue;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it matches on any. Maybe we shouldn't, maybe we should have three functions.

Maybe we return an array of hashes instead, so user can pick.

}
}
break;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking at first one found right now. Maybe that's bad.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think this method was in the OSLibHelpers @joseph-robertson . It could be useful nonetheless

Comment on lines +852 to +858
std::string measure_name = step.measureDirName(); // The directory name, eg `IncreaseWallRValue`
if (auto s_ = step.name()) { // An optional, abritrary one
measure_name = std::move(*s_);
}
// if (auto s_ = stepResult_->measureName()) { // The xml one, eg `increase_insulation_r_value_for_exterior_walls_by_percentage`
// measure_name = std::move(*s_);
// }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to do it like check_upstream_measure_for_arg

Comment on lines +863 to +865
if (auto value = root["value"]) {
step_values[measure_name] = value;
// TODO: check_upstream_measure_for_arg was breaking early, and returning a {:value => value, :measure_name => measure_name} format
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Copy link
Collaborator

@joseph-robertson joseph-robertson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve, but I defer to @DavidGoldwasser for whether all expected functionality is here.

@joseph-robertson joseph-robertson added this to the OpenStudio SDK 3.8.0 milestone Apr 11, 2024
…true

* Move logic to Variant::isTruish to determine if a variant is trueish (whether that's bool true, str = "true", int != 0, double != 0.0
* Add  a OSRunner::prepareForMeasureRun() that takes no arg, protected, and friend OSWorkflow so we can use it without the penatly of instantiating an OSMeasure
* In Apply Measure, when __SKIP__, correctly call prepareForMEasureRun before incrementing the step. And do load the BCLMeasure to write the resultInfo like the workflow-gem was doing
@ci-commercialbuildings
Copy link
Collaborator

ci-commercialbuildings commented Apr 12, 2024

@jmarrec jmarrec merged commit 7a59317 into lib-helper-methods2 Apr 12, 2024
1 of 4 checks passed
@jmarrec jmarrec deleted the lib-helper-methods3 branch April 12, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants