Example #1
0
def configure(app: Optional[apps.App] = None, permissive=False):
    """
    Set the plugin manager for the Framework and configure internals to those plugins.

    Parameters
    ----------
    app :
        An :py:class:`armi.apps.App` instance with which the framework is to be
        configured. If it is not provided, then the default ARMI App will be used.
    permissive :
        Whether or not an error should be produced if ``configure`` is called more than
        once. This should only be set to ``True`` under testing or demonstration
        purposes, where the contents of otherwise independent scripts need to be run
        under the same python instance.

    Important
    ---------
    Since this affects the behavior of several modules at their import time, it is
    generally not safe to re-configure the ARMI framework once it has been configured.
    Therefore this will raise an ``OverConfiguredError`` if such a re-configuration is
    attempted, unless ``permissive`` is set to ``True``.

    Notes
    -----
    We are planning on encapsulating much of the global ARMI state that gets configured
    with an App into the App object itself (with some other things going into the Case
    object). This will provide a number of benefits, the main one being that it will
    become trivial to re-configure the framework, which is currently not possible.
    """
    global _app
    global _ARMI_CONFIGURE_CONTEXT

    if _ignoreConfigures:
        return

    app = app or apps.App()

    if _app is not None:
        if permissive and type(_app) is type(app):
            return
        else:
            raise exceptions.OverConfiguredError(_ARMI_CONFIGURE_CONTEXT)

    assert not context.BLUEPRINTS_IMPORTED, (
        "ARMI can no longer be configured after blueprints have been imported. "
        "Blueprints were imported from:\n{}".format(
            context.BLUEPRINTS_IMPORT_CONTEXT))

    _ARMI_CONFIGURE_CONTEXT = "".join(traceback.format_stack())

    _app = app

    if _liveInterpreter():
        cli.splash()

    pm = app.pluginManager
    context.APP_NAME = app.name
    parameters.collectPluginParameters(pm)
    parameters.applyAllParameters()
    flags.registerPluginFlags(pm)
Example #2
0
def configure(app: Optional[apps.App] = None):
    """
    Set the plugin manager for the Framework and configure internals to those plugins.

    Parameters
    ----------
    app :
        An :py:class:`armi.apps.App` instance with which the framework is to be
        configured. If it is not provided, then the default ARMI App will be used.

    Important
    ---------
    Since this affects the behavior of several modules at their import time, it is
    generally not safe to re-configure the ARMI framework once it has been configured.
    Therefore this will raise an ``AssertionError`` if such a re-configuration is
    attempted.

    Notes
    -----
    We are planning on encapsulating much of the global ARMI state that gets configured
    with an App into the App object itself (with some other things going into the Case
    object). This will provide a number of benefits, the main one being that it will
    become trivial to re-configure the framework, which is currently not possible.
    """
    global _app
    global _ARMI_CONFIGURE_CONTEXT

    if _ignoreConfigures:
        return

    if _app is not None:
        # ARMI cannot be reconfigured!
        raise exceptions.OverConfiguredError(_ARMI_CONFIGURE_CONTEXT)

    assert not armi.context.BLUEPRINTS_IMPORTED, (
        "ARMI can no longer be configured after blueprints have been imported. "
        "Blueprints were imported from:\n{}".format(
            armi.context.BLUEPRINTS_IMPORT_CONTEXT
        )
    )

    _ARMI_CONFIGURE_CONTEXT = "".join(traceback.format_stack())

    app = app or apps.App()

    _app = app

    pm = app.pluginManager
    armi.context.APP_NAME = app.name
    parameters.collectPluginParameters(pm)
    parameters.applyAllParameters()
    flags.registerPluginFlags(pm)
    if MPI_RANK == 0:
        runLog.raw(app.splashText)
Example #3
0
def configure(app: apps.App):
    """
    Set the plugin manager for the Framework and configure internals to those plugins.
    """
    assert not armi.context.BLUEPRINTS_IMPORTED, (
        "ARMI can no longer be configured after blueprints have been imported. "
        "Blueprints were imported from:\n{}".format(
            armi.context.BLUEPRINTS_IMPORT_CONTEXT))

    global _app
    _app = app

    pm = app.pluginManager
    armi.context.APP_NAME = app.name
    parameters.collectPluginParameters(pm)
    parameters.applyAllParameters()
    flags.registerPluginFlags(pm)
    if MPI_RANK == 0:
        runLog.raw(app.splashText)