1
- from sqlalchemy import MetaData , Integer , String , Text , Table
2
- from sqlalchemy .orm import DeclarativeBase , mapped_column , Mapped
3
-
4
-
5
- metadata_obj = MetaData ()
6
-
1
+ from sqlalchemy import Integer , Text , Table
2
+ from sqlalchemy .orm import mapped_column , Mapped
3
+ from autosubmit .database .tables import (
4
+ BaseTable ,
5
+ ExperimentTable ,
6
+ ExperimentStatusTable ,
7
+ JobPackageTable ,
8
+ WrapperJobPackageTable ,
9
+ )
7
10
8
11
## SQLAlchemy ORM tables
9
- class BaseTable (DeclarativeBase ):
10
- metadata = metadata_obj
11
-
12
-
13
- class ExperimentTable (BaseTable ):
14
- """
15
- Is the main table, populated by Autosubmit. Should be read-only by the API.
16
- """
17
-
18
- __tablename__ = "experiment"
19
-
20
- id : Mapped [int ] = mapped_column (Integer , nullable = False , primary_key = True )
21
- name : Mapped [str ] = mapped_column (String , nullable = False )
22
- description : Mapped [str ] = mapped_column (String , nullable = False )
23
- autosubmit_version : Mapped [str ] = mapped_column (String )
24
-
25
-
26
12
class DetailsTable (BaseTable ):
27
13
"""
28
14
Stores extra information. It is populated by the API.
@@ -38,20 +24,6 @@ class DetailsTable(BaseTable):
38
24
hpc : Mapped [str ] = mapped_column (Text , nullable = False )
39
25
40
26
41
- class ExperimentStatusTable (BaseTable ):
42
- """
43
- Stores the status of the experiments
44
- """
45
-
46
- __tablename__ = "experiment_status"
47
-
48
- exp_id : Mapped [int ] = mapped_column (Integer , primary_key = True )
49
- name : Mapped [str ] = mapped_column (Text , nullable = False )
50
- status : Mapped [str ] = mapped_column (Text , nullable = False )
51
- seconds_diff : Mapped [int ] = mapped_column (Integer , nullable = False )
52
- modified : Mapped [str ] = mapped_column (Text , nullable = False )
53
-
54
-
55
27
class GraphDataTable (BaseTable ):
56
28
"""
57
29
Stores the coordinates and it is used exclusively to speed up the process
@@ -66,33 +38,6 @@ class GraphDataTable(BaseTable):
66
38
y : Mapped [int ] = mapped_column (Integer , nullable = False )
67
39
68
40
69
- class JobPackageTable (BaseTable ):
70
- """
71
- Stores a mapping between the wrapper name and the actual job in slurm
72
- """
73
-
74
- __tablename__ = "job_package"
75
-
76
- exp_id : Mapped [str ] = mapped_column (Text )
77
- package_name : Mapped [str ] = mapped_column (Text , primary_key = True )
78
- job_name : Mapped [str ] = mapped_column (Text , primary_key = True )
79
-
80
-
81
- class WrapperJobPackageTable (BaseTable ):
82
- """
83
- It is a replication. It is only created/used when using inspectand create or monitor
84
- with flag -cw in Autosubmit.\n
85
- This replication is used to not interfere with the current autosubmit run of that experiment
86
- since wrapper_job_package will contain a preview, not the real wrapper packages
87
- """
88
-
89
- __tablename__ = "wrapper_job_package"
90
-
91
- exp_id : Mapped [str ] = mapped_column (Text )
92
- package_name : Mapped [str ] = mapped_column (Text , primary_key = True )
93
- job_name : Mapped [str ] = mapped_column (Text , primary_key = True )
94
-
95
-
96
41
## SQLAlchemy Core tables
97
42
98
43
# MAIN_DB TABLES
@@ -107,4 +52,4 @@ class WrapperJobPackageTable(BaseTable):
107
52
108
53
# Job package TABLES
109
54
job_package_table : Table = JobPackageTable .__table__
110
- wrapper_job_package_table : Table = WrapperJobPackageTable .__table__
55
+ wrapper_job_package_table : Table = WrapperJobPackageTable .__table__
0 commit comments