Mondaic

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

def migrate_salvus_project(
    project_path: pathlib.Path, from_revision: str | None, to_revision: str
) -> None: ...

Migrate a SalvusProject from one revision to another.

Currently it can only migrate from older to newer revisions.

Parameters
  • project_path pathlib.Path — The path to the Salvus project.
  • from_revision str | None — The revision to start at.
  • to_revision str — The revision to end at.
Returns None

Classes

Migration

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

A migration from one version of the SalvusProject file structure to another.

Parameters
  • revision str — The revision hash.
  • title str — The title of the migration.
  • down_revision str | None — The hash of the previous revision. Only the initial migration is allowed to not have this set.
  • applies_after_salvus_version str — 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.
  • upgrade_function typing.Callable[[pathlib.Path], None] — The upgrading function to go from the previous to this revision.
  • downgrade_function typing.Callable[[pathlib.Path], None] | None — An optional downgrade function that is currently not used for anything but could be added.
Methods
parse_file()
def parse_file(filename: pathlib.Path) -> Migration: ...

Parse a file containing one migration.

Parameters
  • filename pathlib.Path — The file containing the migration.
Returns Migration

Migrations

class Migrations(builtins.object):
    def __init__(
        self, order: list[str], migrations: list[Migration]
    ) -> None: ...

Class to store the order and the actual migrations.

Parameters
  • order list[str] — The order of the migrations.
  • migrations list[Migration] — The actual migrations.

SalvusProjectVersion

class SalvusProjectVersion(builtins.object):
    def __init__(
        self, project_path: pathlib.Path, apply_migrations: bool | None = None
    ): ...

Versioning of the SalvusProject data structure.

Parameters
  • project_path pathlib.Path — Path to the Salvus project.
  • apply_migrations bool | None — If True, automatically apply necessary migrations, if False, raise if migrations are needed. If None, ask the user with an interactive prompt.
Attributes
version_number str | None

Get the current version number of the project file structure.