Source code for api.api_gateway

""" Entry point for the MORe API

This module is the sole entry point to the MORe API.

"""
from more.api.postprocessor import PostprocessorSetup
from more.api.project_handling import ProjectHandlerSetup

from more.api.simulation import SimulationSetup
from more.api.utils.interface_registries import get_api_setup_klass



[docs] class ApiGateway: """ Entry point for the MORe API Only this object needs to be imported and initialized by the API user. All other objects are created by this object. Parameters ---------- proj : Project The project instance """ def __init__(self, proj): self._proj = proj
[docs] def create_simulation_setup(self) -> SimulationSetup: """ Creates a :class:`~api.simulation.simulation_setup.SimulationSetup` object for managing simulations .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> setup = ApiGateway(proj=proj).create_simulation_setup() .. >>> isinstance(setup, SimulationSetup) True Returns ------- :class:`~api.simulation.simulation_setup.SimulationSetup` A :class:`~api.simulation.simulation_setup.SimulationSetup` instance for managing the simulation state """ api_class = get_api_setup_klass(SimulationSetup) return api_class(proj=self._proj)
[docs] def create_postprocessor_setup(self) -> PostprocessorSetup: """ Creates a :class:`~api.postprocessor.postprocessor_setup.PostprocessorSetup` object for managing postprocessing of experiments .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> setup = ApiGateway(proj=proj).create_postprocessor_setup() .. >>> isinstance(setup, PostprocessorSetup) True Returns ------- :class:`~api.postprocessor.postprocessor_setup.PostprocessorSetup` A :class:`~api.postprocessor.postprocessor_setup.PostprocessorSetup` instance for managing the postprocessor state """ api_class = get_api_setup_klass(PostprocessorSetup) return api_class(proj=self._proj)
[docs] def create_project_handler_setup(self) -> ProjectHandlerSetup: """ Creates a :class:`~api.project_handling.project_handler_setup.ProjectHandlerSetup` object for file handling operations, such as import, export, save and load .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> setup = ApiGateway(proj=proj).create_project_handler_setup() .. >>> isinstance(setup, ProjectHandlerSetup) True Returns ------- :class:`~api.project_handling.project_handler_setup.ProjectHandlerSetup` A :class:`~api.project_handling.project_handler_setup.ProjectHandlerSetup` instance for managing file operations """ api_class = get_api_setup_klass(ProjectHandlerSetup) return api_class(proj=self._proj)