Coverage for mpcforces_extractor\api\db\models.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-04 18:13 +0100

1from typing import Dict 

2from sqlmodel import SQLModel, Field, Column, JSON 

3 

4 

5class MPCDBModel(SQLModel, table=True): 

6 """ 

7 Database Representation of MPC Class 

8 """ 

9 

10 id: int = Field(primary_key=True) 

11 config: str = Field() # Store MPC_CONFIG as a string 

12 master_node: int = Field() # Store master node as an integer 

13 nodes: str = Field() # Store nodes as a string 

14 part_id2nodes: Dict = Field( 

15 default_factory=dict, sa_column=Column(JSON) 

16 ) # Store part_id2nodes as a dictionary 

17 subcase_id2part_id2forces: Dict = Field( 

18 default_factory=dict, sa_column=Column(JSON) 

19 ) # Store subcase_id2part_id2forces as a dictionary 

20 

21 

22class NodeDBModel(SQLModel, table=True): 

23 """ 

24 Database Representation of Node Instance 

25 """ 

26 

27 id: int = Field(primary_key=True) 

28 coord_x: float = Field() 

29 coord_y: float = Field() 

30 coord_z: float = Field() 

31 

32 

33class SubcaseDBModel(SQLModel, table=True): 

34 """ 

35 Database Representation of Subcase Class 

36 """ 

37 

38 id: int = Field(primary_key=True) 

39 node_id2forces: Dict = Field(default_factory=dict, sa_column=Column(JSON)) 

40 time: float = Field()