-
Notifications
You must be signed in to change notification settings - Fork 193
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 Utility for Generating Alfalfa Metadata to OpenStudio #5236
Conversation
@kbenne what do you think about the language of Right now all the |
@kbenne this is pretty much there.
|
@TShapinsky as we discussed, it would be a good idea to test a workflow that excerses this new feature. You can see an example of workflow tests here. Note they are not Google Tests, but instead these are implemented purely in the CTest wrapper. |
I created a new issue to create documentation for this new API. |
@kbenne I'm happy where everything is, with the exception of the behaviour for dealing with duplicate ids. One possible approach is to modify duplicate ids on export so they become unique. This would work, but it could be confusing and it is also non-deterministic. If someone was expecting a certain set of IDs from a measure they might not get them if a previous measure adds points of the same id. Another approach is to throw an error on export which could be annoying. It also runs the possibility of weird behaviour where based on naming of model objects certain models would error while others didn't. Are names unique across an IDF? or are they just unique to an idd type? A possible third approach would be to refactor the id out of the point and have it be set in the AlfalfaJSON. This is probably the most correct as it is a key used to refer to the point and thus not something that the point needs to know about. This would allow for runtime checking of point Id against the existing points. I think the best option may be a combination of the first and third. Refactoring the point id to be stored in the AlfalfaJSON object and dynamically renaming point ids to prevent overlap. A warning could also be printed to alert of this happening. But that would only be shown locally, so it wouldn't include weird behaviour that happens when the measures interact with the baked in alfalfa measures. Maybe after this we need to reevaluate if we want to be automatically baking points into alfalfa or if we should just provide the measures we create for generating generic points as a resource for people putting together workflows. That would allow for the maximum amount of reproducibility between alfalfa and local development. |
@jmarrec I would grateful to have you weigh in on this. The challenge is that I'm not sure that you have enough context or any available time. If you don't have time, that's understandable, just say so. My intention is to merge this in time for the next release unless there are any serious red flags that emerge. |
@wenyikuang can you investigate the CI failures? |
Looks the windows-incremental is lost connection from the jenkins, let me look |
If i remember correctly, the osx build fails were from tests failing for BCL measures. |
alfalfa.exposeConstant(10, "safe value") | ||
alfalfa.exposeMeter("Facility:Electricity", "Facility Electricity") | ||
alfalfa.exposeActuator("somehting", "another thing", "key", "example actuator") | ||
alfalfa.exposeOutputVariable("Whole Building", "Facility Total Purchased Electricity Energy", "output variable") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a change? I seem to recall that these originally took ModelObject instances. I think when we @TShapinsky last spoke you were contemplating a change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A risk I can think of is that the final names might not be known at ModelMeasure time.
Resolve the issue of connection between jenkins and windows-incre-on-aws (From another PR but using the same node) Or are you mentioning these one?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good work. I'm just generally picky.
There are a couple of constructs I'd change, I'd also suggest taking your files for a spin with clang-tidy to modernize the code a bit and follow best practices.
My main point is more around the articulation of the classes between themselves, and what public API should be like (probably use actual type values to store stuff and not JSON, provide getters, some methods should probably be private, and error handling should be reworked a bit).
m_impl->exposePoint(point); | ||
} | ||
|
||
boost::optional<AlfalfaPoint> AlfalfaJSON::exposeFromObject(const openstudio::IdfObject& idf_object, const std::string& display_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THe vast majority of the code I've read was "throwy", but here you go with LOG and return boost::none. That's fine, just noting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general pattern was I log and return boost::none
everywhere possible, but in ctors you can't do that (to my knowledge) to I throw a std::runtime_error
.
@wenyikuang cppcheck is broken, you should fix that: https://github.com/NREL/OpenStudio/actions/runs/10853524579/job/30432985755#step:3:16 |
|
810224f
to
66b50e3
Compare
@jmarrec I'm starting to get into the cleaning phase. I think it would be useful if you could go over the Component code (ComponentBase, AlfalfaComponent, AflalfaActuator, AlfalfaConstant, AlfalfaMeter, AlfalfaOutputVariable, AlfalfaGlobalVariable) and let me know what you think. I'm decently happy with the new architecture, but it isn't exactly something that is elsewhere in the code base so I'd like your opinion. |
CI Results for f54b39d:
|
@@ -28,6 +28,7 @@ | |||
from . import openstudioosversion as osversion | |||
from . import openstudioradiance as radiance | |||
from . import openstudiosdd as sdd | |||
from . import openstudioualfalfa as alfalfa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's that extra "u" in there? I think you meant openstudioalfalfa
@TShapinsky
template <typename T, std::enable_if_t<std::is_base_of<ComponentBase, T>::value, bool> = true> | ||
AlfalfaComponent(T component) : m_component(std::make_unique<T>(std::move(component))) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seeing this while looking diagonally at this PR changes since I was out of office. Makes me wonder if I should investigate what's up or not. @kbenne I'm assuming you reviewed the changes already while I wasn't around and I don't need to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm failing to see directly why this AlfalfaComponent class is needed. Instead of just keeping ComponentBase (renamed to AlfalfaComponent probably, but basically an abstract class with the pure virtual methods and maybe a couple of other defaulted virtual methods that would define that common API) and just be done with it... That "interface" templated class seems superfluous (and overcomplicated) at first glance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I was getting compiler errors with the full virtual abstract base class. But I'll do a quick test to see exactly what the issue was. Maybe there's a better solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, the biggest issue appears to be that you can't boost::optional
an abstract base class. I can obviously use a unique_ptr
but I don't think that translates to swig very well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmarrec It wouldn't hurt to have your touch on this for one more round. If you and @TShapinsky agree to a simplification then I'm all for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. We don't have that problem with abstract base classes in model namespace for eg because of the pImpl pattern...
I'll take a quick look tomorrow to check if I see a simpler way of doing it, otherwise this is fine.
(We should fix the python import I reported though)
|
||
void exposePoint(const AlfalfaPoint& point); | ||
|
||
std::vector<AlfalfaPoint> points(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be const. cppcheck catches this (now that I fixed the workflow on a separate PR...)
Alfalfa is a platform which allows users to interact with OpenStudio/EnergyPlus models in real time. In order to accomplish this users must specify what components of the model to connect with Alfalfa as input and output points. This PR moves the mechanisms for creating "Alfalfa Points" into the OpenStudio runner so that they may be accessed during the measure workflow.
Pull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.