simulation_api.model¶
Package contents¶
Submodules¶
simulation_api.model.crud¶
This program manages database querys. CRUD comes from: Create, Read, Update, and Delete.
-
simulation_api.model.crud._create_parameters(db: sqlalchemy.orm.session.Session, parameters: List[simulation_api.controller.schemas.ParameterDBSchCreate]) → None[source]¶ Insert parameter entry into parameters table.
- Parameters
db (Session) – Database Session.
parameters (List[ParameterDBSchCreate]) – Parameter row in
parameters’ table.
- Returns
- Return type
None
-
simulation_api.model.crud._create_plot_query_values(db: sqlalchemy.orm.session.Session, plot_query_params: List[simulation_api.controller.schemas.PlotDBSchCreate]) → None[source]¶ Insert row in plots table (contains plot query params)
- Parameters
db (Session) – Database Session.
plot_query_params (List[PlotDBSchCreate]) – List of rows to be inserted in
plotstable.
- Returns
- Return type
None
-
simulation_api.model.crud._create_simulation(db: sqlalchemy.orm.session.Session, simulation: simulation_api.controller.schemas.SimulationDBSchCreate) → simulation_api.model.models.SimulationDB[source]¶ Inserts simulation in simulations table.
- Parameters
db (Session) – Database Session.
simulation (SimulationDBSchCreate) – Simulation row in
simulationstable.
- Returns
db_simulation – Updated
simulation’s row.- Return type
-
simulation_api.model.crud._create_user(db: sqlalchemy.orm.session.Session, user: simulation_api.controller.schemas.UserDBSchCreate) → simulation_api.model.models.UserDB[source]¶ Inserts
userinuserstable.- Parameters
db (Session) – Database Session.
user (UserDBSchCreate) – User row in database.
- Returns
db_user – Updated inserted row (with
user_id.)- Return type
-
simulation_api.model.crud._get_all_simulations(db: sqlalchemy.orm.session.Session) → Tuple[simulation_api.model.models.SimulationDB][source]¶ Get all simulation entries in
simulationstable.- Parameters
db (Session) – Database Session.
- Returns
Querry of all rows in
simulationstable.- Return type
sqlalchemy.orm.Query
-
simulation_api.model.crud._get_parameters(db: sqlalchemy.orm.session.Session, sim_id: str, param_type: simulation_api.controller.schemas.ParamType) → Union[List[float], Dict[str, float]][source]¶ Get parameters from parameters table.
- Parameters
db (Session) – Database Session.
sim_id (str) – Simulation ID.
param_type (ParamType) – Type of parameter, wether
'initial condition'or'parameter'.
- Returns
listof initial conditions ordictmapping parameter names to parameter values.- Return type
List[float] or Dict[str, float]
-
simulation_api.model.crud._get_plot_query_values(db: sqlalchemy.orm.session.Session, sim_id: str)[source]¶ Return plot query parameters for a given simulation.
- Parameters
db (Session) – Database Session.
sim_id (str) – Simulation ID.
- Returns
Plot query values associated to
sim_id.- Return type
List[
PlotQueryValues]
-
simulation_api.model.crud._get_simulation(db: sqlalchemy.orm.session.Session, sim_id: str) → simulation_api.model.models.SimulationDB[source]¶ Get simulation with specific id from simulations table.
- Parameters
db (Session) – Database Session.
sim_id (str) – Simulation ID.
- Returns
Query with simulation information of
sim_id.- Return type
sqlalchemy.orm.Query
simulation_api.model.db_manager¶
This module starts the database engine, the database session and the basemodel for the database tables.
simulation_api.model.models¶
This program creates all the models and tables in the database
-
class
simulation_api.model.models.ParameterDB(**kwargs)[source]¶ Bases:
sqlalchemy.orm.decl_api.BaseParmaeters table model.
Stores parameters and initial conditions of simulations.
-
__init__(**kwargs)¶ A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
ini_cndtn_id¶ Initial condition position in array of initial conditions.
-
param_id¶
-
param_key¶ Name of parameter. Must be one of the required parameters related to the system being simulated.
-
param_type¶ Parameter type, wether
'initial condition'or'parameter'.
-
sim_id¶ Simulation ID.
-
simulation¶ ORM relationship with simulations’ table.
-
value¶ Value of
'parameter'orinitial contidion.
-
-
class
simulation_api.model.models.PlotDB(**kwargs)[source]¶ Bases:
sqlalchemy.orm.decl_api.BasePlots table model.
Stores query parameter values of plots needed to access simulation results via GET in route
/api/results/{sim_id}/plot?value={plot_query_value}.-
__init__(**kwargs)¶ A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
plot_id¶ Primary key.
-
plot_query_value¶ Label of each plot, used as query value for query param
valuein route/api/results/{sim_id}/plot.
-
sim_id¶ Simulation ID.
-
simulation¶ ORM relationship with simulations’ table.
-
-
class
simulation_api.model.models.SimulationDB(**kwargs)[source]¶ Bases:
sqlalchemy.orm.decl_api.BaseSimulation Status table model.
-
__init__(**kwargs)¶ A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
date¶
-
message¶ Message with further information about the simulation status.
-
method¶ Integration method.
-
parameters¶ ORM relationship with parameters’ table.
-
plots¶ ORM relationship with plots’ table.
-
route_pickle¶ API route to GET simulation results in pickle format.
-
route_plots¶ API route to GET simulation plots.
-
route_results¶ API route to GET simulation results displayed in frontend web page.
-
sim_id¶ Simulation ID.
-
success¶ Tells if the simulation was successful or not.
-
system¶ Simulated system.
-
user¶ ORM relationship with users’ table.
-
-
class
simulation_api.model.models.UserDB(**kwargs)[source]¶ Bases:
sqlalchemy.orm.decl_api.BaseUsers table model.
This table stores basic user information.
Note
hash_valueand thisuserstable is not appropiately used yet because logging is not yet implemented in the app.-
__init__(**kwargs)¶ A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
hash_value¶ Hash value of the usser’s password.
-
simulations¶ ORM relationship with simulations’ table.
-
user_id¶
-
username¶
-