Skip to content

Commit 501c0c9

Browse files
committed
Contains all the job_list changes
Fixing issues fixing post rebase issues Remove an innecesary call Contains all the job_list changes small fix for update from file fix bug in check_running Fix for a large amount of inserts Fix for split Fixed postgres init Finished the integration tests wip ( only one case missing) WIP moved to db, Integration test for differences wip docs fix regression test fix docs not working Fix pipeline docs try update version Fixing remaining issues Main loop changes, db changes, test changes, check_alljobs changes wrapper checker reworked (wip) wrappers not quite working yet rebase fixing wrappers not all working yet trying un succesfully to fix tests Fixing and adding tests for horizontal wrapper trying to add tests fix tests rebase + fix for docker ( not sure why I needed to do it) Contains all as-postgres-joblist implementation Fixing tests, deleting unused code, main wrapped db is no longer deleted Fixed stats, set_status, recovery # maybe something is not working properly Recover last_log/ready_data moved to a db consult instead of files post rebase fix Sqlalchemy was not fully supporting sqlite Changes recovery #2577, #2563 fix comment backups/restore, fix monitor unused code fixing docker issue ( revert 5fcfc8f) fix tests fix rebase bug Fix platform issue for local platform and status for create Adding more tests, monitor is not working well in wrappers, fixed issue with job.parents not being filled Renamed db fields and other fixes adding tests remove unused code Contains all as-postgres-joblist implementation fix wrong ident postgres was failing due not getting the table from the schema more efficient rework clean_unused_nodes to cover all cases Adding some tests for wrappers section.. disabling tests for code that is not on this branch fixing ident after GUI conflict resolve Fixing tests some tests delete debug stuff Wrappers run, ( could be optimized tho) fixed some wrapper issues, but not all Revised the todo's Fixed issues with multi-wrappers ( run untested) added more fields Attempt to fix concurrent runs fixed -H, added expid protection, fixed create_required_folders marking xfail, testing option some XFAIL marked tests fixing tests ( some integration fails rng) Rebase + trying to fix tests after rebase. Integration fixed, regression failling the config one I think is due a change of TYPE: pkl -> type: sqlite 27 unit tests not working yet Super commit - Changed joblist, change Status filters, tests passing All current tests passing non-skipped Unit tests working fixing wrapper tests almost there fixing wrapper tests ( last kind of tests) unit job_list test remade more tests and trying to renable run_members ( -rom) another test fixing commit Modifying one test REmove tests that doesn't make sense now, added one more todo lint added TODO of missing scenarios for the checkpoints edges.. Added more tests added tests regression and integration working fixing tests... fixing regression tests Added calculate_auto_splits in the brother autosubmitconfigparser (sqlite_joblist branch) fix basic detect WIP trying to remove chunks > EXPERIMENT.numchunks Adding code to detect dynamic changes more fix fixes fixing stuff... all kinda works kinda not wrapper fix wrapper working and not at the same time (know why) wrappers fixes fix call monitor working wrapper methods very wip stuff fix display issues tests fixing bugs intregation tests updated test some cleanup Trying to save preview wrappers... added some wrapper methods fixing adding tests Revising integration tests.. Revising tests.. ( 36 pending) Revising tests.. ( 121 pending) Regression tests working unload working ( with issues in the last log) log and job_data working again Fix total jobs output, added count statments Full Run working Almost getting the load of the full list Run working! ( kinda, dynamic load missing) Fixing the different issues with special_conditions.. as I needed to adapt it anyway to the new format.. [wip] [wip] add if to setstate for log process Load working, but run fails ( logical it has old code still) Load almost working Re-arranged. Now we will only have self.graph. Added property self.graph_dict , self.job_list that are dynamic views of self.graph Renamed _job_list to job_list Added upsert, save loads etc save working wip added check_folders to make compatible older expids renamed pkl -> db Renamed tables
1 parent 5dc4332 commit 501c0c9

File tree

114 files changed

+9504
-5472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+9504
-5472
lines changed

.github/workflows/docker.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ permissions:
1111
jobs:
1212
build-docker-images:
1313
name: Build Docker images
14-
env:
15-
DOCKERHUB_SECRET: ${{ secrets.DOCKERHUB_TOKEN }}
16-
# NOTE: Secrets are not available for external contributors, so we skip the job.
17-
if: ${{ secrets.DOCKERHUB_TOKEN }}
14+
# NOTE: The Docker loging command apparently stopped working at some point
15+
# probably due to some security changes in either/both GitHub and
16+
# Dependabot. To solve this, we do not build docker images here.
17+
if: ${{ github.actor != 'dependabot[bot]' }}
1818
runs-on: ubuntu-latest
1919
timeout-minutes: 15
2020

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.15
1+
4.2

autosubmit/autosubmit.py

Lines changed: 695 additions & 719 deletions
Large diffs are not rendered by default.

autosubmit/config/basicconfig.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#
1515
# You should have received a copy of the GNU General Public License
1616
# along with Autosubmit. If not, see <http://www.gnu.org/licenses/>.
17-
1817
try:
1918
# noinspection PyCompatibility
2019
from configparser import SafeConfigParser
@@ -223,3 +222,27 @@ def read():
223222

224223
BasicConfig._update_config()
225224
return
225+
226+
@staticmethod
227+
def generate_dirs():
228+
"""
229+
Generates the directory structure needed for Autosubmit operation
230+
"""
231+
Path(BasicConfig.DB_DIR).mkdir(parents=True, exist_ok=True)
232+
Path(BasicConfig.LOCAL_ROOT_DIR).mkdir(parents=True, exist_ok=True)
233+
Path(BasicConfig.STRUCTURES_DIR).mkdir(parents=True, exist_ok=True)
234+
Path(BasicConfig.GLOBAL_LOG_DIR).mkdir(parents=True, exist_ok=True)
235+
Path(BasicConfig.DEFAULT_OUTPUT_DIR).mkdir(parents=True, exist_ok=True)
236+
Path(BasicConfig.JOBDATA_DIR).mkdir(parents=True, exist_ok=True)
237+
Path(BasicConfig.HISTORICAL_LOG_DIR).mkdir(parents=True, exist_ok=True)
238+
239+
os.chmod(BasicConfig.DB_DIR, 0o770)
240+
os.chmod(BasicConfig.LOCAL_ROOT_DIR, 0o770)
241+
os.chmod(BasicConfig.STRUCTURES_DIR, 0o770)
242+
os.chmod(BasicConfig.GLOBAL_LOG_DIR, 0o770)
243+
os.chmod(BasicConfig.DEFAULT_OUTPUT_DIR, 0o770)
244+
os.chmod(BasicConfig.JOBDATA_DIR, 0o770)
245+
os.chmod(BasicConfig.HISTORICAL_LOG_DIR, 0o770)
246+
247+
# Local experiment directories are created when needed
248+
return

autosubmit/config/configcommon.py

Lines changed: 208 additions & 74 deletions
Large diffs are not rendered by default.

autosubmit/config/files/autosubmit-dummy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ MAIL:
1212
NOTIFICATIONS: False
1313
TO:
1414
STORAGE:
15-
TYPE: "pkl"
15+
TYPE: "db"
1616
COPY_REMOTE_LOGS: True

autosubmit/config/files/autosubmit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ MAIL:
1212
NOTIFICATIONS: False
1313
TO:
1414
STORAGE:
15-
TYPE: "pkl"
15+
TYPE: "db"
1616
COPY_REMOTE_LOGS: True

autosubmit/database/db_common.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,19 @@
2424
from pathlib import Path
2525
from typing import List, Optional, cast
2626

27-
from autosubmit.config.basicconfig import BasicConfig
2827
from sqlalchemy import delete, select, Connection, insert, text, update, func
2928
from sqlalchemy.schema import CreateTable
3029

30+
from autosubmit.config.basicconfig import BasicConfig
3131
from autosubmit.database import tables, session
3232
from autosubmit.log.log import Log, AutosubmitCritical
3333

3434
Log.get_logger("Autosubmit")
3535

36-
3736
CURRENT_DATABASE_VERSION = 1
3837
TIMEOUT = 15
3938

4039

41-
4240
def create_db(qry):
4341
"""
4442
Creates a new database for autosubmit
@@ -96,22 +94,16 @@ def open_conn(check_version=True):
9694
version = row[0]
9795
except sqlite3.OperationalError:
9896
# If this exception is thrown it's because db_version does not exist.
99-
# Database is from 2.x or 3.0 beta releases
100-
try:
101-
cursor.execute('SELECT type FROM experiment;')
102-
# If type field exists, it's from 2.x
103-
version = -1
104-
except sqlite3.Error:
105-
# If raises and error , it's from 3.0 beta releases
106-
version = 0
97+
version = 0
98+
Log.warning("Database version table does not exist. Assuming version 0.")
10799

108100
# If database version is not the expected, update database....
109-
if version < CURRENT_DATABASE_VERSION:
101+
if int(version) < int(CURRENT_DATABASE_VERSION):
110102
if not _update_database(version, cursor):
111103
raise AutosubmitCritical('Database version does not match', 7001)
112104

113105
# ... or ask for autosubmit upgrade
114-
elif version > CURRENT_DATABASE_VERSION:
106+
elif int(version) > int(CURRENT_DATABASE_VERSION):
115107
raise AutosubmitCritical('Database version is not compatible with this autosubmit version. '
116108
'Please execute pip install autosubmit --upgrade', 7002)
117109
return conn, cursor
@@ -159,9 +151,9 @@ def save_experiment(name: str, description: Optional[str], version: Optional[str
159151

160152
try:
161153
result = queue.get(True, TIMEOUT)
162-
except Exception:
163-
raise AutosubmitCritical(f"The database process exceeded the timeout limit {TIMEOUT}s. "
164-
f"Your experiment {name} couldn't be stored in the database.")
154+
except BaseException:
155+
raise AutosubmitCritical(
156+
"The database process exceeded the timeout limit {0}s. Your experiment {1} couldn't be stored in the database.".format(TIMEOUT, name))
165157
finally:
166158
proc.terminate()
167159
return result
@@ -235,7 +227,7 @@ def get_autosubmit_version(expid):
235227
:type expid: str
236228
:return: If experiment exists returns the autosubmit version for it, if not returns None
237229
:rtype: str
238-
"""
230+
"""
239231
fn = _get_autosubmit_version
240232
if BasicConfig.DATABASE_BACKEND == 'postgres':
241233
fn = _get_autosubmit_version_sqlalchemy
@@ -246,9 +238,9 @@ def get_autosubmit_version(expid):
246238

247239
try:
248240
result = queue.get(True, TIMEOUT)
249-
except Exception:
241+
except Exception as e:
250242
raise AutosubmitCritical(f"The database process exceeded the timeout limit {TIMEOUT}s. "
251-
f"Get experiment {expid} version failed to complete.")
243+
f"Get experiment {expid} version failed to complete. {str(e)}")
252244
finally:
253245
proc.terminate()
254246
return result
@@ -297,7 +289,6 @@ def delete_experiment(experiment_id):
297289
fn = _delete_experiment
298290
if BasicConfig.DATABASE_BACKEND == 'postgres':
299291
fn = _delete_experiment_sqlalchemy
300-
301292
queue = multiprocessing.Queue(1)
302293
proc = multiprocessing.Process(target=fn_wrapper, args=(fn, queue, experiment_id))
303294
proc.start()
@@ -408,10 +399,8 @@ def _check_experiment_exists(name, error_on_inexistence=True):
408399
def get_experiment_description(expid: str):
409400
if BasicConfig.DATABASE_BACKEND == 'postgres':
410401
return _get_experiment_description_sqlalchemy(expid)
411-
412-
check_db()
413-
414402
try:
403+
check_db()
415404
(conn, cursor) = open_conn()
416405
except DbException as e:
417406
raise AutosubmitCritical(
@@ -488,7 +477,7 @@ def _get_autosubmit_version(expid):
488477
# behaviour with the next sentence
489478
conn.text_factory = str
490479
cursor.execute('SELECT autosubmit_version FROM experiment WHERE name=:expid', {
491-
'expid': expid})
480+
'expid': expid})
492481
row = cursor.fetchone()
493482
close_conn(conn, cursor)
494483
if row is None:
@@ -508,7 +497,7 @@ def _last_name_used(test=False, operational=False, evaluation=False):
508497
:type test: bool
509498
:return: last experiment identifier used, 'empty' if there is none
510499
:rtype: str
511-
"""
500+
"""
512501
check_db()
513502

514503
try:
@@ -734,7 +723,7 @@ def _get_experiment_description_sqlalchemy(expid) -> List[List[str]]:
734723

735724

736725
def _update_experiment_description_version_sqlalchemy(
737-
name: str, description: Optional[str] = None, version: Optional[str] = None
726+
name: str, description: Optional[str] = None, version: Optional[str] = None
738727
) -> bool:
739728
# Conditional update statement
740729
if description is None and version is None:
@@ -808,7 +797,7 @@ def _last_name_used_sqlalchemy(test=False, operational=False, evaluation=False)
808797

809798
def _delete_experiment_sqlalchemy(experiment_id: str) -> bool:
810799
if not _check_experiment_exists_sqlalchemy(
811-
experiment_id, False
800+
experiment_id, False
812801
): # Reference the no anti-lock version.
813802
return True
814803

@@ -862,3 +851,13 @@ def get_connection_url(db_path: Optional['Path'] = None) -> str:
862851
raise ValueError('For SQLite databases you MUST provide a database file.')
863852

864853
return f'sqlite:///{str(Path(db_path).resolve())}'
854+
855+
856+
def check_db_path(db_path: Optional[Path], must_exists: bool = True) -> bool:
857+
"""Check if the database path exists."""
858+
if db_path and not db_path.exists() and must_exists:
859+
raise ValueError(f'Database path not found {str(db_path)}!')
860+
elif db_path and not db_path.exists() and not must_exists:
861+
return False
862+
else:
863+
return True

0 commit comments

Comments
 (0)