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

Integrate breaking changes in btwxt interface, including error logging via interface injection. #10160

Merged
merged 37 commits into from
Nov 14, 2023

Conversation

tanaya-mankad
Copy link
Collaborator

@tanaya-mankad tanaya-mankad commented Aug 21, 2023

Pull request overview

The btwxt interpolation library underwent a major restructuring, and changes needed to be propagated to client code. Changes include new constructors, removal of internal intermediate objects from the public interface, and most importantly, a per-instance error handling policy that uses a custom error-handling class injected into the btwxt constructors (rather than the previous global error handling callback mechanism.) The libtk205 dependency was also updated, as it depends on btwxt.

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts

@nealkruis nealkruis added the NotIDDChange Code does not impact IDD (can be merged after IO freeze) label Aug 21, 2023
@nealkruis nealkruis added the Defect Includes code to repair a defect in EnergyPlus label Aug 22, 2023
Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

I had a few comments, but nothing major. The most major is probably the question about the severe error and whether it leads to a fatal. But this PR is still marked as draft, so I'll just leave this for now.

@@ -253,7 +253,7 @@ add_subdirectory(third_party)
target_include_directories(project_options INTERFACE ${PROJECT_SOURCE_DIR}/src)
target_include_directories(project_options INTERFACE ${PROJECT_SOURCE_DIR}/third_party)
target_include_directories(project_options INTERFACE ${PROJECT_SOURCE_DIR}/third_party/fmt-8.0.1/include)
target_include_directories(project_options INTERFACE ${PROJECT_SOURCE_DIR}/third_party/btwxt/src)
target_include_directories(project_options INTERFACE ${PROJECT_SOURCE_DIR}/third_party/btwxt/include)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -6941,9 +6941,9 @@ namespace AirflowNetwork {

std::vector<Real64> dirs30 = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360};
std::vector<Btwxt::GridAxis> dirs30Axes;
dirs30Axes.emplace_back(dirs30, Btwxt::Method::LINEAR, Btwxt::Method::LINEAR, std::pair<double, double>{0.0, 360.0});
dirs30Axes.emplace_back(dirs30, "", Btwxt::Method::linear, Btwxt::Method::linear, std::pair<double, double>{0.0, 360.0});
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but I do wonder what the new empty string constructor argument will be as I read along...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These have now been populated. I'm not sure if the string literal should be pulled out into its own variable; if it moved beyond the two local uses I'd do that.

@@ -757,6 +757,7 @@ target_link_libraries(
DElight
libkiva
btwxt
courierr
Copy link
Member

Choose a reason for hiding this comment

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

What is courierr?

Copy link
Collaborator Author

@tanaya-mankad tanaya-mankad Sep 11, 2023

Choose a reason for hiding this comment

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

The target link didn't need to be here, so it's been removed. But, courierr is Big Ladder's current lightweight error-logging interface. The idea is that a client user would provide a concrete implementation of the courierr interface as an injected dependency, rather than an old C-style callback, to handle logging.
At the moment, there is a bit of a proliferation of those concrete implementations (in this and an upcoming PR). Neal and I intend to merge those into a single central class that anything in E+ can use.

thisCurve->TableIndex = gridIndex;
thisCurve->GridValueIndex = state.dataCurveManager->btwxtManager.addOutputValues(gridIndex, lookupValues);
} catch (Btwxt::BtwxtException &e) {
ShowSevereError(state, "GridAxis construction error.");
Copy link
Member

Choose a reason for hiding this comment

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

Should this lead to a fatal error? Does it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, and fixed.

Copy link
Member

Choose a reason for hiding this comment

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

IMHO, I wish that the third party libs had "lightweight" releases that could be brought into our repo without docs/tests/readme/etc. Just the code, dependencies, and build rules. It's not a big deal, just a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The last check-in should be more lightweight.

Copy link
Member

Choose a reason for hiding this comment

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

I actually thought that nlohmann provided a single-file include-only header option. I could definitely be wrong there though. But if that was the case, it would be really nice to just use that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Modified as discussed on Slack; we'll see if everything is still happy.

@Myoldmopar Myoldmopar added this to the EnergyPlus 24.1 IOFreeze milestone Sep 11, 2023
@tanaya-mankad tanaya-mankad marked this pull request as ready for review September 15, 2023 14:02
@tanaya-mankad
Copy link
Collaborator Author

Currently, the Windows 10 build shows a build warning emanating from alphanum.hpp. The cause appears to be the custom E+ use of alphanum in the nlohmann json header; the EnergyPlus implementation of json changed nlohmann's std::less to doj::alphanum_less. Our own third-party libraries rely on the original source implementation. I'm not really clear what the best solution here is.

@Myoldmopar
Copy link
Member

@mbadams5 do you have a second to look at the compiler warning being emitted from doj/alphanum on Windows? This PR doesn't change that file that I can see, but something is causing it to be emitted. It is an odd looking expression in there, but that code looks like magic in a number of places, so that's not surprising.

@tanaya-mankad
Copy link
Collaborator Author

There is something wrong with the error reporting here...check out this ERR diff http://energyplus.s3-website-us-east-1.amazonaws.com/regressions/2023-10/7636e6b3e972dad33c41815304938b2139dde367-1bf2590b9b5581199ecd76c704e2b5b445ef2846/ASHRAE901_OfficeLarge_STD2019_Denver_Chiller205/x86_64-MacOS-10.17-clang-14.0.0/eplusout.err.diff.html

Wow, there sure is. I'm afraid I don't remember if this was a known issue that I addressed or not. I'll look into it.

@tanaya-mankad
Copy link
Collaborator Author

tanaya-mankad commented Oct 18, 2023

Looks like I'd missed an implementation detail! I'm checking in a fix now.

@Myoldmopar Myoldmopar self-assigned this Oct 25, 2023
@Myoldmopar
Copy link
Member

@tanaya-mankad thanks for fixing this up. It looks totally ready. I've got several PRs that I need to line up for merging, but it appears that I don't need anything else here. This should merge today.

@tanaya-mankad
Copy link
Collaborator Author

Thank you @Myoldmopar !

@Myoldmopar
Copy link
Member

This has waited long enough, and tests out all happily here, merging. Thanks @tanaya-mankad

@Myoldmopar Myoldmopar merged commit 08e876b into NREL:develop Nov 14, 2023
4 checks passed
@Myoldmopar Myoldmopar deleted the fix-btwxt-error-handling branch November 14, 2023 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Btwxt error handler is a global object
8 participants