autosubmit.database#
Module containing functions to manage autosubmit’s general database.
All access goes through SQLAlchemy Core, so the same code works with both the SQLite and the PostgreSQL backends.
- autosubmit.database.db_common.check_db() None#
Check that the general database is available.
Only SQLite is checked, as its absence means the file was not created and SQLAlchemy would silently create an empty one. PostgreSQL surfaces a missing database or tables as a query error.
- Raises:
AutosubmitCritical – If the SQLite database file does not exist.
- autosubmit.database.db_common.check_experiment_exists(name: str, error_on_inexistence: bool = True) bool#
Check whether an experiment with the given name exists.
- Parameters:
name – Experiment name.
error_on_inexistence – When
True, raise if the experiment does not exist.
- Returns:
Trueif the experiment exists,Falseotherwise.- Raises:
AutosubmitCritical – If it does not exist and
error_on_inexistenceis set.
- autosubmit.database.db_common.create_db() bool#
Create the general database tables and record the schema version.
- Returns:
Trueif the database was created successfully.- Raises:
AutosubmitCritical – If the database could not be created.
- autosubmit.database.db_common.database_backup(expid: str) None#
Back up the experiment’s historical database.
- Parameters:
expid – Experiment identifier.
- autosubmit.database.db_common.delete_experiment(experiment_id: str) bool#
Remove an experiment from the database.
- Parameters:
experiment_id – Experiment identifier.
- Returns:
Trueif the experiment was deleted,Falseif it did not exist or no row was deleted.
- autosubmit.database.db_common.get_autosubmit_version(expid: str) str | None#
Get the minimum Autosubmit version needed for the experiment.
- Parameters:
expid – Experiment name.
- Returns:
The Autosubmit version for the experiment.
- Raises:
AutosubmitCritical – If the experiment does not exist.
- autosubmit.database.db_common.get_experiment_description(expid: str) list[list[str]]#
Get an experiment’s description.
- Parameters:
expid – Experiment name (expid).
- Returns:
A list with a single list containing the description, or an empty list.
- autosubmit.database.db_common.get_experiment_expids(expids: list[str] | None = None) set[str]#
Get the expids of all experiments in the database, or only the requested ones.
- Parameters:
expids – Optional list of expids to look up. When
None, all are returned.- Returns:
A set of experiment expids.
- autosubmit.database.db_common.get_experiment_id(name: str) int#
Get the experiment numerical id from the database.
- Parameters:
name – Experiment name.
- Returns:
The experiment numerical id.
- Raises:
AutosubmitCritical – If the experiment does not exist.
- autosubmit.database.db_common.last_name_used(test: bool = False, operational: bool = False, evaluation: bool = False) str#
Get the last experiment identifier used.
- Parameters:
test – Flag for test experiments.
operational – Flag for operational experiments.
evaluation – Flag for evaluation experiments.
- Returns:
The last experiment identifier used, or
'empty'if there is none.
- autosubmit.database.db_common.save_experiment(name: str, description: str | None, version: str | None) bool#
Store an experiment in the database.
- Parameters:
name – Experiment name.
description – Experiment description.
version – Autosubmit version.
- Returns:
Trueif the experiment was stored.- Raises:
AutosubmitCritical – If the experiment could not be stored.
- autosubmit.database.db_common.update_experiment_description_version(name: str, description: str | None = None, version: str | None = None) bool#
Update an experiment’s description and/or version.
- Parameters:
name – Experiment name (expid).
description – New experiment description.
version – New Autosubmit version.
- Returns:
Trueif the experiment was updated.- Raises:
AutosubmitCritical – If there is not enough data or the update fails.