Beispiel #1
0
class ExamplePlugin(BaseExtensionPlugin):
    id = plugin_id("itwm", "example", PLUGIN_VERSION)

    def get_name(self):
        return "ITWM Example"

    def get_description(self):
        return (
            "An example plugin from ITWM to evaluate a simple chemical "
            "reaction")

    def get_version(self):
        return PLUGIN_VERSION

    def get_factory_classes(self):
        return [
            MCOFactory,
            FixedValueDataSourceFactory,
            ProductionCostDataSourceFactory,
            ArrheniusParametersFactory,
            MaterialCostDataSourceFactory,
            ImpurityConcentrationDataSourceFactory,
            PureDensitiesFactory,
            CSVWriterFactory
        ]
class EggboxPlugin(BaseExtensionPlugin):
    """ This plugin provides the following classes and associated
    factories:

    :obj:`EggboxPESDataSource`: a data source that defines a random PES with
    arbitrary dimensions and optionally locally optimises it at the
    points it receives.

    :obj:`RandomSamplingMCO`: an MCO that randomly samples potentials of
    arbitrary dimensions.


    """
    id = plugin_id("pes", "sampler", PLUGIN_VERSION)

    def get_name(self):
        return "Potential energy surface sampler"

    def get_description(self):
        return ("An example plugin for sampling arbitrary-dimensional eggbox "
                "potential energy surfaces, developed by Enthought.")

    def get_version(self):
        return PLUGIN_VERSION

    def get_factory_classes(self):
        return [EggboxPESDataSourceFactory, RandomSamplingMCOFactory]

    def get_data_views(self):
        # This import is only needed if data views are ever requested
        from eggbox_potential_sampler.sampling_data_view.sampling_data_view \
            import SamplingDataView
        return [SamplingDataView]
class TroughsAndWavesPlugin(BaseExtensionPlugin):
    """ Contributes data-sources useful for testing optimizers.
    It is useful to test optimizers with "ground-truth" objective functions
    where the minima, maxima and Pareto set are known.
    This plugin contributes several such functions as data-sources which
    can be used alone or mix-and-matched to create multi-objective functions.
    The data-sources involve Gaussians, sine-waves, steps and slopes.
    """
    id = plugin_id("enthought", "troughs_waves", PLUGIN_VERSION)

    def get_name(self):
        return "Troughs and Waves"

    def get_description(self):
        return "Useful data sources for testing optimizers."

    def get_version(self):
        return PLUGIN_VERSION

    #: Define the factory classes that you want to export to this list.
    def get_factory_classes(self):
        return [
            GaussianFactory,
            PerpendicularWavesFactory,
            CircularWaveFactory,
            GaussValleyFactory,
        ]
class PUFoamPlugin(BaseExtensionPlugin):
    """This is an example plugin for the BDSS investigating polyurethane
    (PU) foams.
    """

    id = plugin_id("pufoam", "example", PLUGIN_VERSION)

    def get_name(self):
        return "PUFoam Example"

    def get_description(self):
        return ("An example plugin to investigate"
                "properties of polyurethane foams")

    def get_version(self):
        return PLUGIN_VERSION

    def get_factory_classes(self):
        return [
            MCOFactory, ChemicalFactory, FormulationFactory,
            MeshBuilderFactory, ReactionParametersFactory, CostFactory,
            PUFoamPostProcessingFactory, PUFoamFactory, SimPUFoamFactory,
            PUFoamCSVWriterFactory, TimeSeriesProfilerFactory
        ]

    def get_data_views(self):
        # This import is only needed if data views are ever requested
        from pufoam_example.data_view.pufoam_data_view import PUFoamDataView
        return [PUFoamDataView]
Beispiel #5
0
    def test_ui_select(self):

        contributed_ui = DummyContributedUI2()

        class MockUIModal:
            def __init__(self, **kwargs):
                self.selected_ui = contributed_ui

            def edit_traits(self):
                pass

        ui_wfmanager = DummyUIWfManager()
        # Get a reference to the plugins we expect to use in the modal dialog
        ui_plugin = ui_wfmanager.get_plugin(plugin_id("enthought", "uitest",
                                                      2))
        ui_plugin_old = ui_wfmanager.get_plugin(
            plugin_id("enthought", "uitest", 1))
        setup_task, _ = get_probe_wfmanager_tasks(
            wf_manager=ui_wfmanager, contributed_uis=[contributed_ui])

        with mock.patch(UI_SELECT_MODAL_PATH) as mock_ui_modal:
            mock_ui_modal.side_effect = MockUIModal
            setup_task.ui_select()
        # Check the plugins were sorted
        mock_ui_modal.assert_called_with(
            available_plugins=[ui_plugin_old, ui_plugin],
            contributed_uis=[contributed_ui],
        )
        # Press the 'update workflow' button
        with self.assertTraitChanges(setup_task, "workflow_model"):
            setup_task.selected_contributed_ui.update_workflow = True

        # Press the 'run simulation' button
        with mock.patch(RUN_BDSS_PATH) as _mock_run:
            with self.assertTraitChanges(setup_task, "workflow_model"):
                setup_task.selected_contributed_ui.run_workflow = True
        _mock_run.assert_called()
class MonteCarloPlugin(BaseExtensionPlugin):

    id = plugin_id("enthought", "monte_carlo", PLUGIN_VERSION)

    def get_name(self):
        return "Monte Carlo"

    def get_description(self):
        return "Random sampling and optimization."

    def get_version(self):
        return PLUGIN_VERSION

    #: Define the factory classes that you want to export to this list.
    def get_factory_classes(self):
        return [MonteCarloFactory]
class UINotificationPlugin(BaseExtensionPlugin):
    id = plugin_id("enthought", "ui_notification", PLUGIN_VERSION)

    def get_name(self):
        return u"Workflow Manager support"

    def get_description(self):
        return u"Plugin required to support the workflow manager UI interface."

    def get_version(self):
        return PLUGIN_VERSION

    def get_factory_classes(self):
        return [
            UINotificationFactory,
            UINotificationHooksFactory,
        ]
Beispiel #8
0
class DummyUIPluginOld(ServiceOfferExtensionPlugin):

    id = plugin_id("enthought", "uitest", 1)

    def get_name(self):
        return "An Older Example"

    def get_version(self):
        return 1

    def get_factory_classes(self):
        return [DummyFactory]

    def get_contributed_uis(self):
        return [DummyContributedUI, DummyContributedUI2]

    def get_service_offer_factories(self):
        return [(IContributedUI, self.get_contributed_uis())]
class ChemtoolsPlugin(BaseExtensionPlugin):
    """This plugin provides useful classes and DatsSource subclasses
    for creating and running chemtools.
    """

    id = plugin_id("chemtools", "wrapper", PLUGIN_VERSION)

    def get_name(self):
        return "Chemtools Plugin"

    def get_description(self):
        return ("A plugin containing useful chemical objects")

    def get_version(self):
        return PLUGIN_VERSION

    #: Define the factory classes that you want to export to this list.
    def get_factory_classes(self):
        return []
class GromacsPlugin(BaseExtensionPlugin):
    """This plugin provides useful classes and DatsSource subclasses
    for creating and running Gromacs MD simulations.
    """

    id = plugin_id("gromacs", "wrapper", PLUGIN_VERSION)

    def get_name(self):
        return "Gromacs Plugin"

    def get_description(self):
        return ("A plugin containing useful objects for running "
                "Gromacs simulations")

    def get_version(self):
        return PLUGIN_VERSION

    #: Define the factory classes that you want to export to this list.
    def get_factory_classes(self):
        return [FragmentFactory, MoleculeFactory, HPCWriterFactory]
class NevergradPlugin(BaseExtensionPlugin):
    """This plugin provides useful classes and DataSource subclasses
    for using the Nevergrad library.
    """

    id = plugin_id("nevergrad", "wrapper", PLUGIN_VERSION)

    def get_name(self):
        return "Nevergrad Plugin"

    def get_description(self):
        return ("A plugin containing force-bdss compatible objects "
                "using functionalities of the Nevergrad library")

    def get_version(self):
        return PLUGIN_VERSION

    #: Define the factory classes that you want to export to this list.
    def get_factory_classes(self):
        return [NevergradMCOFactory]
Beispiel #12
0
class ExampleCustomUIPlugin(ServiceOfferExtensionPlugin):

    id = plugin_id("enthought", "test", 4)

    def get_name(self):
        return "Example Custom UI"

    def get_version(self):
        return 4

    def get_factory_classes(self):
        return [DummyFactory]

    def get_contributed_uis(self):
        return [ContributedUI, ContributedUI]

    def get_base_plots(self):
        return [ProbePlot, ProbePlot]

    def get_service_offer_factories(self):
        return [(IDataView, self.get_base_plots()),
                (IContributedUI, self.get_contributed_uis())]
Beispiel #13
0
from traits.api import (on_trait_change, Instance)
from traitsui.api import (Group, Heading, Item, InstanceEditor)

from force_bdss.api import plugin_id
from force_wfmanager.ui import ContributedUI

from .templates import (MCOTemplate, ExecutionLayerTemplate,
                        NotificationListenerTemplate)

_GROMACS_PLUGIN_ID = plugin_id("gromacs", "wrapper", 0)
SURFACTANT_PLUGIN_ID = plugin_id("surfactant", "example", 0)


class SurfactantContributedUI(ContributedUI):
    """A simplified UI for the surfactant formulation user case, allowing
    for selection of fragment ingredient and concentrations for a
    set of Gromacs experiments"""

    # ------------------
    # Regular Attributes
    # ------------------

    #: Name for the UI in selection screen
    name = "Simplified Surfactant Workflow"

    #: Description of the UI
    desc = ("A simplified UI which allows the selection concentration"
            " ranges for a set of pre-defined chemicals")

    #: The Template that generates MCO components of the Workflow
    mco_template = Instance(MCOTemplate)
Beispiel #14
0
class ExamplePlugin(ServiceOfferExtensionPlugin):
    """This is an example of the plugin system for the BDSS.
    This class provides access points for the various entities
    that the plugin system supports:

    - data sources: entities that perform calculations or
      retrieve data from external sources
    - MCO: multi criteria optimizer support. Note that the MCO
      must obey an execution model as in Dakota, that is,
      this plugin spawns the MCO, which spawns subprocesses
      performing the single-point evaluation.
    - Notification listeners: entities that handle notifications
      from the MCO as it computes data and can perform actions
      accordingly. The MCO plugin must trigger the appropriate
      events, otherwise no notification will be triggered.
      You can use notification listeners to submit data to a
      database as they are computed.
    - UI Hooks: provides hook methods that are called in some
      specific moments of the FORCE UI.
    """
    #: Define the id of the plugin by calling the plugin_id function, and
    #: passing three information:
    #: - the producer: a unique string identifying the company or research
    #: institute.
    #: - the plugin identifier: a unique string identifying the plugin.
    #: - the version number of the plugin, as an integer.
    id = plugin_id("enthought", "example", PLUGIN_VERSION)

    def get_name(self):
        return "Enthought example"

    def get_description(self):
        return "An example plugin from Enthought"

    def get_version(self):
        return PLUGIN_VERSION

    #: Define the factory classes that you want to export to this list.
    def get_factory_classes(self):
        return [
            ExampleDataSourceFactory,
            ExampleMCOFactory,
            ExampleNotificationListenerFactory,
            ExampleUIHooksFactory,
        ]

    # The following functionalities are optional (the plugin can be run on the
    # bdss without a GUI), so the quite expensive imports are done
    # inside each method.
    def get_contributed_uis(self):
        """Get any ContributedUI classes included in the plugin"""
        from enthought_example.example_contributed_ui\
            .example_contributed_ui import ExampleContributedUI

        return [ExampleContributedUI]

    def get_data_views(self):
        """Get any BasePlot classes included in the plugin"""
        from enthought_example.example_data_views.example_data_view import \
            ExampleCustomPlot

        return [ExampleCustomPlot]

    def get_service_offer_factories(self):
        """Overloaded method of ServiceOffersPlugin class used to define
        service_offers trait. In this example, we import 2 types of custom UI
        objects using the Interfaces for ContributedUI and DataView classes,
        found in force-wfmanager. The methods get_contributed_uis and
        get_data_views return the example UI subclasses provided by this
        plugin"""
        from force_wfmanager.ui import IContributedUI
        from force_wfmanager.ui import IDataView

        contributed_uis = self.get_contributed_uis()
        data_views = self.get_data_views()

        return [
            (IContributedUI, contributed_uis),
            (IDataView, data_views)
        ]