-
Notifications
You must be signed in to change notification settings - Fork 135
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
restructure hybrid model #1203
restructure hybrid model #1203
Conversation
@alfoa @PaulTalbot-INL @mandd This is the first step for the restructuring. This PR is simply split the current HybridModel class into HybridModelBase and HybridModel classes. Please take a look, and more comments are favorable. My plan is first merge this PR to devel, and then address all comments in additional PR, since this PR just simply replicates our current functionalities. |
Just for clarification, HybridModelBase is the eventual name for the Logic and Hybrid model parent class? |
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 couple initial comments, nothing fundamental.
self.raiseAnError(IOError,'Model XML block needs to be inputted!') | ||
if len(self.modelInstances) != 1: | ||
self.raiseAnError(IOError, 'Required one "Model" XML subnode under node "HybridModel" can be accepted!', | ||
'"{}" "Model" subnodes are provided.'.format(len(self.modelInstances))) |
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.
sorry, I'm being annoying ... "HybridModel" node can only accept exactly one <Model> subnode! {n} subnodes were provided.
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.
n subnodes is used in the base class. In HybridModel class, we only allow one model and multiple rooms, but in other model class, we can allow multiple models.
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 was a grammar fix request; the original message is quite difficult to understand.
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.
Updated.
""" | ||
for model in self.modelInstances: | ||
if isinstance(model, Models.Model): | ||
self.raiseAnError(IOError, "Model {} has already been initialized, and it can not be initialized again!".format(model.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.
This is interesting. I was under the impression each entity gets initialized once per Step that it's used in; does this mean a model used in a Step and then later as part of a Hybrid will error out?
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 means if HybridModel is already initialized , it will error out, not specific model. Basically, I'm limiting the use of HybridModel in different steps. When it is moved forward to other models, i.e. LogicalModel, it will be more clear to me how to handle this. This is just a restructure with the same capabilities.
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 valid for any model or just for the ROM? I think we added this in the Hybrid for the ROM to be sure to not perform a "destructive" process in case of already trained ROM. In here, is it going to error out for whatever model?
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.
@alfoa You are right, it is used for the ROM. As I said, I prefer to change it in the next PR.
codeInput.append(elem) | ||
modelInstance.initialize(runInfo, codeInput, initDict) | ||
self.modelInstances[model] = modelInstance | ||
def getInitParams(self): |
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.
newline between methods
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.
updated.
# limitations under the License. | ||
|
||
""" | ||
Factory for generating the instances of the HybridModels Module |
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.
do we really need a factory?
What do we buy with this?
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.
removed.
if isinstance(model, Models.Model): | ||
self.raiseAnError(IOError, "Model {} has already been initialized, and it can not be initialized again!".format(model.name)) | ||
modelInstance = self.retrieveObjectFromAssemblerDict('Model', model) | ||
if modelInstance.type == 'Code': |
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.
why do we need to be so specific?
Overall considering that in your "Logic Model" each mode can have a set of "different" input files
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.
As discussed, will change in the next PR.
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.
Do you think it is changeable in this PR? Just to be consistent.
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.
@alfoa Personally, I would like to change it in the next PR.
Dummy.__init__(self,runInfoDict) | ||
self.modelInstances = {} # dictionary {modelName: modelInstance}: instances of given model | ||
self.sleepTime = 0.005 # waiting time before checking if a run is finished. | ||
self.printTag = 'HybridModelBase MODEL' # print tag |
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 doesn't need changing, but note that in the MessageHandler the default trim length for tags is not very long (15 characters as I recall); this might be exceeding that length.
I would really like to see that error message rewritten before merging; otherwise, no outstanding changes requested in the code. |
Job Test Fedora 28 on 52f6dd0 : invalidated by @wangcj05 conda error when setting python environment |
it looks like we're getting an error only on Windows for the following:
@alfoa may have thoughts? |
Job Mingw Test on 52f6dd0 : invalidated by @wangcj05 retest |
Job Mingw Test on 52f6dd0 : invalidated by @wangcj05 |
@PaulTalbot-INL @alfoa Tests are green for this PR. Could you merge this? |
Checklists have passed, but merging is blocked by @alfoa change requests. |
Approved. Please @wangcj05 open an issue regarding the outstanding changes that you want to do in a follow-up PR. |
Pull Request Description
What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)
see issue #1202
What are the significant changes in functionality due to this change request?
For Change Control Board: Change Request Review
The following review must be completed by an authorized member of the Change Control Board.
<internalParallel>
to True.raven/tests/framework/user_guide
andraven/docs/workshop
) have been changed, the associated documentation must be reviewed and assured the text matches the example.