idaholab / raven

RAVEN is a flexible and multi-purpose probabilistic risk analysis, validation and uncertainty quantification, parameter optimization, model reduction and data knowledge-discovering framework.
https://raven.inl.gov/
Apache License 2.0
220 stars 133 forks source link

[UNDER-DISCUSSION] Plugin Entities Design #1486

Closed PaulTalbot-INL closed 2 years ago

PaulTalbot-INL commented 3 years ago

Under Discussion Topic

Discussion Plugin Entities (Entities in Plugins that are meant to be available as RAVEN Entities such as Sampler, ROMs, PostProcessors, etc) can potentially be done a lot of ways philosophically.

  1. New PluginBase types for each Entity (e.g. SamplerPluginBase) can be created that does not inherit from the base type (e.g. Sampler), but provides a simplified interface for users. This results in the loss of some potential entity functionality, but results in a streamlined experience for Plugin development.
  2. New PluginBase types for each Entity can inherit directly from the base Entity. This results in keeping the messageHandler and similar base properties and preserves full flexibility; however, this results in a potentially complex and easily breakable API if RAVEN core changes its API.

Design decision March 15, 2021 Option 2, Each <Entity>PluginBase should inherit directly from the Entity base, preserving flexibility over simplicity. The discussion pointed out that if we used interfaces (option 1), as we steadily add more and more features to the interface, it will eventually converge on the actual base class, only duplicated in two places. We elected to preserve utility over simplicity.

NOTE this decision was reversed later that week, see comments below.

Discussion Given this decision, the question becomes what objects should be base Entities for plugins. Nominally, the base entities in Simulation.entityModules seems like a good start, as this is where the factories live; however, this includes Models as a single entity, which is in reality an umbrella for ROMs, PostProcessors, Codes, and ExternalModels. Also note that (with the exception of ongoing development in the PostProcessors) none of the actual algorithms used in these models inherits from the base Model; for example, the Model.ROM has a SupervisedLearningEngine member that does not inherit from Model but its own base class.

Does this mean that there should be a SupervisedLearning base class instead? If so, the factory for SupervisedLearning needs to be available to the PluginHandler alongside the other more "basic" entities.


For Change Control Board: Issue Review

This review should occur before any development is performed as a response to this issue.


For Change Control Board: Issue Closure

This review should occur when the issue is imminently going to be closed.

PaulTalbot-INL commented 3 years ago

Discussion Summary of several discussions ending March 19, 2021:

Glossary:

The question is whether Entities should follow an “inheritance” approach or a “interfacing” approach.

Either way,

The summary of pro-con for strategies we discussed, as I recall from my notes:

INHERITANCE

INTERFACING:

Current Entities that use Inheritance:

Current Entities that use Interfacing:

PaulTalbot-INL commented 3 years ago

Comments from Andrea via email:

I think we need to be in the middle of the two approaches. Inheritance to the base class of the “Plugin” (and not the base raven entity) with a clear light API and interface to the different algorithms. The basic Plugin base class should have the minimum required methods:

PaulTalbot-INL commented 3 years ago

This decision using interfaces suggests an inheritance structure, for example:

BaseType

EntityType(BaseType) StrategyType(BaseType) or InterfaceType(BaseType)

SamplerHandler(EntityType) MonteCarlo(StrategyType/InterfaceType)

etc

PaulTalbot-INL commented 3 years ago

EntityBase.pptx Here is a PPT showing the current and proposed structures for this discussion.

As of discussion on March 22, 2021, we have the following "going forward" approach for my development work:

PaulTalbot-INL commented 3 years ago

Things the BaseType currently knows about, and how they might be redistributed:

BaseType(MessageUser)

Assembler(MessageUser)


Proposed redistribution of these features:

MessageUser()

InputDataUser()

Assembler(MessageUser)

BaseType(MessageUser) -> add InputDataUser inheritance once everyone is using it

BaseEntity(BaseType, Assembler) -> not everyone is an InputDataUser

BaseInterface(BaseType) -> not everyone is an InputDataUser

Other

PaulTalbot-INL commented 3 years ago

On second glance, I don't think the Entity really reads any input; it's a handler that passes input to the Interfaces. This functionally seems to suggest there is no functionality for a BaseType; rather, everything is either BaseEntity or BaseInterface.

wangcj05 commented 2 years ago

I would archive this issue, since we have implemented the plugin structure for most entities. Specific issue can be created if there is new request.