Skip to content

Commit 591927a

Browse files
use autosubmit db_structure
1 parent a0d6996 commit 591927a

File tree

5 files changed

+14
-173
lines changed

5 files changed

+14
-173
lines changed

autosubmit_api/autosubmit_legacy/job/job_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from autosubmit_api.common.utils import Status
3838
from bscearth.utils.date import date2str, parse_date
3939
# from autosubmit_legacy.job.tree import Tree
40-
from autosubmit_api.database import db_structure as DbStructure
40+
from autosubmit.database import db_structure as DbStructure
4141
from autosubmit_api.database.db_jobdata import JobDataStructure, JobRow
4242
from autosubmit_api.builders.experiment_history_builder import ExperimentHistoryDirector, ExperimentHistoryBuilder
4343
from autosubmit_api.history.data_classes.job_data import JobData

autosubmit_api/components/jobs/joblist_loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from fnmatch import fnmatch
55
from autosubmit_api.components.jobs.joblist_helper import JobListHelper
66
from autosubmit_api.components.jobs.job_factory import StandardJob, Job
7-
from autosubmit_api.database.db_structure import get_structure
7+
from autosubmit.database import db_structure
88
from autosubmit_api.common.utils import Status
99
from bscearth.utils.date import date2str
1010
from typing import Dict, List, Set
@@ -144,7 +144,7 @@ def _generate_job_dictionary(self):
144144
self._job_dictionary[job.name] = job
145145

146146
def load_existing_structure_adjacency(self):
147-
self._structure_adjacency = get_structure(self.expid, self.configuration_facade.structures_path)
147+
self._structure_adjacency = db_structure.get_structure(self.expid, self.configuration_facade.structures_path)
148148

149149
def distribute_adjacency_into_jobs(self):
150150
parents_adjacency = {}

autosubmit_api/database/db_structure.py

Lines changed: 0 additions & 104 deletions
This file was deleted.

autosubmit_api/database/tables.py

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
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+
)
710

811
## 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-
2612
class DetailsTable(BaseTable):
2713
"""
2814
Stores extra information. It is populated by the API.
@@ -38,20 +24,6 @@ class DetailsTable(BaseTable):
3824
hpc: Mapped[str] = mapped_column(Text, nullable=False)
3925

4026

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-
5527
class GraphDataTable(BaseTable):
5628
"""
5729
Stores the coordinates and it is used exclusively to speed up the process
@@ -66,33 +38,6 @@ class GraphDataTable(BaseTable):
6638
y: Mapped[int] = mapped_column(Integer, nullable=False)
6739

6840

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-
9641
## SQLAlchemy Core tables
9742

9843
# MAIN_DB TABLES
@@ -107,4 +52,4 @@ class WrapperJobPackageTable(BaseTable):
10752

10853
# Job package TABLES
10954
job_package_table: Table = JobPackageTable.__table__
110-
wrapper_job_package_table: Table = WrapperJobPackageTable.__table__
55+
wrapper_job_package_table: Table = WrapperJobPackageTable.__table__

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def get_authors():
3232
"scipy~=1.7.3",
3333
"python-dotenv",
3434
"autosubmitconfigparser~=1.0.48",
35-
"autosubmit>=3.13",
35+
"autosubmit>=4.2.0",
3636
"Flask-APScheduler",
3737
"gunicorn",
3838
"pydantic~=2.5.2",

0 commit comments

Comments
 (0)