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

restructure hybrid model #1203

Merged
merged 7 commits into from
May 6, 2020
Merged

restructure hybrid model #1203

merged 7 commits into from
May 6, 2020

Conversation

wangcj05
Copy link
Collaborator

@wangcj05 wangcj05 commented Apr 7, 2020


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.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual and xsd schema. If the input syntax change deprecates existing input files, a conversion script needs to be added (see Conversion Scripts).
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Automated Tests should pass, including run_tests, pylint, manual building and xsd tests. If there are changes to Simulation.py or JobHandler.py the qsub tests must pass.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test. If new development on the internal JobHandler parallel system is performed, a cluster test must be added setting, in XML block, the node <internalParallel> to True.
  • 6. If the change modifies or adds a requirement or a requirement based test case, the Change Control Board's Chair or designee also needs to approve the change. The requirements and the requirements test shall be in sync.
  • 7. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.
  • 8. If an analytic test is changed/added is the the analytic documentation updated/added?
  • 9. If any test used as a basis for documentation examples (currently found in raven/tests/framework/user_guide and raven/docs/workshop) have been changed, the associated documentation must be reviewed and assured the text matches the example.

@wangcj05
Copy link
Collaborator Author

wangcj05 commented Apr 7, 2020

@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.

@PaulTalbot-INL
Copy link
Collaborator

Just for clarification, HybridModelBase is the eventual name for the Logic and Hybrid model parent class?

Copy link
Collaborator

@PaulTalbot-INL PaulTalbot-INL left a 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.

framework/Models/HybridModels/Factory.py Outdated Show resolved Hide resolved
framework/Models/HybridModels/Factory.py Outdated Show resolved Hide resolved
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)))
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

framework/Models/HybridModels/HybridModel.py Show resolved Hide resolved
"""
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))
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator Author

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):
Copy link
Collaborator

Choose a reason for hiding this comment

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

newline between methods

Copy link
Collaborator Author

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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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':
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

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.

@PaulTalbot-INL
Copy link
Collaborator

I would really like to see that error message rewritten before merging; otherwise, no outstanding changes requested in the code.

@moosebuild
Copy link

Job Test Fedora 28 on 52f6dd0 : invalidated by @wangcj05

conda error when setting python environment

@PaulTalbot-INL
Copy link
Collaborator

it looks like we're getting an error only on Windows for the following:

(379/717) Diff   ( 15.55sec)tests\framework\PostProcessors\LimitSurface\testLimitSurfaceIntegralPPWihtBoundingError

@alfoa may have thoughts?

@moosebuild
Copy link

Job Mingw Test on 52f6dd0 : invalidated by @wangcj05

retest

@moosebuild
Copy link

Job Mingw Test on 52f6dd0 : invalidated by @wangcj05

@wangcj05
Copy link
Collaborator Author

wangcj05 commented May 6, 2020

@PaulTalbot-INL @alfoa Tests are green for this PR. Could you merge this?

@PaulTalbot-INL PaulTalbot-INL requested a review from alfoa May 6, 2020 17:06
@PaulTalbot-INL
Copy link
Collaborator

Checklists have passed, but merging is blocked by @alfoa change requests.

@alfoa
Copy link
Collaborator

alfoa commented May 6, 2020

Approved. Please @wangcj05 open an issue regarding the outstanding changes that you want to do in a follow-up PR.

@PaulTalbot-INL PaulTalbot-INL merged commit 381c013 into devel May 6, 2020
@alfoa alfoa deleted the wangc/hybrid_rework branch May 6, 2020 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants