jobflow_remote.jobs.upgrade module#
- class jobflow_remote.jobs.upgrade.DatabaseUpgrader(job_controller: JobController)[source]#
Bases:
objectObject to handle the upgrade of the database between different versions
- check_upgrade_conditions(versions: list[Version], force: bool = False) list[tuple[Version, dict]][source]#
- collect_upgrades(from_version: Version, target_version: Version) list[Version][source]#
Determines the upgrades that need to be performed.
- from_version
The version using as a starting point for the list of upgrades.
- target_version
The final version up to which the upgrades should be listed.
- dry_run(from_version: str | None = None, target_version: str | None = None, force: bool = False) tuple[list[UpgradeAction], list[tuple[Version, dict]]][source]#
Simulate the upgrade process and return all actions that would be performed
- Parameters:
from_version – The version from which to start the upgrade. If
None, the current version in the database is used.target_version – The target version of the upgrade. If
None, the current version of the package is used.force – Perform the upgrade even if the conditions marked as ‘skippable’ are not satisfied.
- Returns:
A list of UpgradeAction objects describing all actions that would be performed during the upgrade.
- Return type:
- open_transaction()[source]#
Open a transaction for the queue DB in the jobstore if it is supported. Does nothing and yields None if transactions are not supported
- classmethod register_upgrade(version: str, upgrade_conditions: list | None = None)[source]#
Decorator to register upgrade functions.
This decorator should be used to register functions that implement the upgrades for each version.
- Parameters:
version – The version to register the upgrade function for
upgrade_conditions – Conditions required to perform the upgrade (e.g. no jobs in a RUNNING state or no batch process submitted or running, …)
- property registered_upgrades#
- update_db_version(version: Version, session: ClientSession | None = None)[source]#
Update the jobflow-remote version information stored in the database.
- Parameters:
version – The version to update the database to
session – The client session to use to perform the update
- upgrade(from_version: str | None = None, target_version: str | None = None, force: bool = False) bool[source]#
Perform the database upgrade
This method will check if an upgrade is needed from the given version to the target version and execute the necessary upgrade functions. If no target version is provided, the current version of the package is used.
- Parameters:
from_version – The version from which to start the upgrade. If
None, the current version in the database is used.target_version – The target version of the upgrade. If
None, the current version of the package is used.force – Perform the upgrade even if the conditions marked as ‘skippable’ are not satisfied.
- Returns:
True if the upgrade was performed.
- Return type:
- class jobflow_remote.jobs.upgrade.NoDocumentsIn(*, description: str | None = None, check_func: Callable[[JobController, UpgradeCondition | None], dict | None] | None = None, skippable: bool = False, collection: str | None, query: dict | None = None)[source]#
Bases:
UpgradeConditionCondition that checks that there is no document in a given collection matching the specified query.
- class jobflow_remote.jobs.upgrade.UpgradeAction(description: str, collection: str, action_type: str, details: dict, required: bool = False)[source]#
Bases:
objectDetails of a single upgrade action to be performed
- class jobflow_remote.jobs.upgrade.UpgradeCondition(*, description: str, check_func: Callable[[JobController, UpgradeCondition | None], dict | None] | None = None, skippable: bool = False)[source]#
Bases:
objectGeneric upgrade condition
- check(job_controller: JobController) dict | None[source]#
- check_func: Callable[[JobController, UpgradeCondition | None], dict | None] | None = None#
- exception jobflow_remote.jobs.upgrade.UpgradeRequiredError[source]#
Bases:
ExceptionAn error signaling that an upgrade should be performed before performing any further action.
- jobflow_remote.jobs.upgrade.check_batches_in_auxiliary_legacy(job_controller: JobController, condition: UpgradeCondition) dict | None[source]#
- jobflow_remote.jobs.upgrade.upgrade_to_0_1_5(job_controller: JobController, session: ClientSession | None = None, dry_run: bool = False) list[UpgradeAction][source]#
- jobflow_remote.jobs.upgrade.upgrade_to_1_0(job_controller: JobController, session: ClientSession | None = None, dry_run: bool = False) list[UpgradeAction][source]#