Version:

salvus.project.version.salvus_project_version

salvus.project.version.salvus_project_version salvus project version salvus_project_version
Versioning and migration of SalvusProject's file structure.

Functions

migrate_salvus_project()

Migrate a SalvusProject from one revision to another.
Currently it can only migrate from older to newer revisions.
SIGNATURE
def migrate_salvus_project(
    project_path: pathlib.Path, from_revision: str | None, to_revision: str
) -> None: ...
ARGUMENTS
Required
project_path
Type:pathlib.Path
Description:
The path to the Salvus project.
Required
from_revision
Type:str | None
Description:
The revision to start at.
Required
to_revision
Type:str
Description:
The revision to end at.

Classes

Migration

A migration from one version of the SalvusProject file structure to another.
SIGNATURE
class Migration(builtins.object):
    def __init__(
        self,
        revision: str,
        title: str,
        down_revision: str | None,
        applies_after_salvus_version: str,
        upgrade_function: typing.Callable[[pathlib.Path], None],
        downgrade_function: typing.Callable[[pathlib.Path], None] | None,
    ) -> None: ...
ARGUMENTS
Required
revision
Type:str
Description:
The revision hash.
Required
title
Type:str
Description:
The title of the migration.
Required
down_revision
Type:str | None
Description:
The hash of the previous revision. Only the initial migration is allowed to not have this set.
Required
applies_after_salvus_version
Type:str
Description:
The Salvus version users would need to use to not apply this migration. E.g. the next Salvus version will make a change that mandates this migration.
Required
upgrade_function
Type:typing.Callable[[pathlib.Path], None]
Description:
The upgrading function to go from the previous to this revision.
Required
downgrade_function
Type:typing.Callable[[pathlib.Path], None] | None
Description:
An optional downgrade function that is currently not used for anything but could be added.

Class Methods

Migration.parse_file()
Parse a file containing one migration.
SIGNATURE
def parse_file(filename: pathlib.Path) -> Migration: ...
ARGUMENTS
Required
filename
Type:pathlib.Path
Description:
The file containing the migration.

Migrations

Class to store the order and the actual migrations.
SIGNATURE
class Migrations(builtins.object):
    def __init__(
        self, order: list[str], migrations: list[Migration]
    ) -> None: ...
ARGUMENTS
Required
order
Type:list[str]
Description:
The order of the migrations.
Required
migrations
Type:list[Migration]
Description:
The actual migrations.

SalvusProjectVersion

Versioning of the SalvusProject data structure.
SIGNATURE
class SalvusProjectVersion(builtins.object):
    def __init__(
        self, project_path: pathlib.Path, apply_migrations: bool | None = None
    ): ...
ARGUMENTS
Required
project_path
Type:pathlib.Path
Description:
Path to the Salvus project.
Optional
apply_migrations
Type:bool | None
Default value:None
Description:
If True, automatically apply necessary migrations, if False, raise if migrations are needed. If None, ask the user with an interactive prompt.

Properties

  • version_number(str | None)-Get the current version number of the project file structure.
PAGE CONTENTS