jobflow_remote.jobs.upgrade module#

class jobflow_remote.jobs.upgrade.DatabaseUpgrader(job_controller: JobController)[source]#

Bases: object

Object to handle the upgrade of the database between different versions

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) list[UpgradeAction][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.

Returns:

A list of UpgradeAction objects describing all actions that would be performed during the upgrade.

Return type:

list

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)[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

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) 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.

Returns:

True if the upgrade was performed.

Return type:

bool

class jobflow_remote.jobs.upgrade.UpgradeAction(description: str, collection: str, action_type: str, details: dict, required: bool = False)[source]#

Bases: object

Details of a single upgrade action to be performed

action_type: str#
collection: str#
description: str#
details: dict#
required: bool = False#
exception jobflow_remote.jobs.upgrade.UpgradeRequiredError[source]#

Bases: Exception

An error signaling that an upgrade should be performed before performing any further action.

jobflow_remote.jobs.upgrade.upgrade_to_0_1_5(job_controller: JobController, session: ClientSession | None = None, dry_run: bool = False) list[UpgradeAction][source]#