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_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_pathpathlib.Path — The path to the Salvus project.from_revisionstr | None — The revision to start at.to_revisionstr — The revision to end at.
Returns None
Classes
Migration
Migrationclass 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
revisionstr — The revision hash.titlestr — The title of the migration.down_revisionstr | None — The hash of the previous revision. Only the initial migration is allowed to not have this set.applies_after_salvus_versionstr — 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_functiontyping.Callable[[pathlib.Path], None] — The upgrading function to go from the previous to this revision.downgrade_functiontyping.Callable[[pathlib.Path], None] | None — An optional downgrade function that is currently not used for anything but could be added.
Methods
parse_file()
parse_file()def parse_file(filename: pathlib.Path) -> Migration: ...Parse a file containing one migration.
Parameters
filenamepathlib.Path — The file containing the migration.
Returns Migration
Migrations
Migrationsclass Migrations(builtins.object):
def __init__(
self, order: list[str], migrations: list[Migration]
) -> None: ...Class to store the order and the actual migrations.
Parameters
orderlist[str] — The order of the migrations.migrationslist[Migration] — The actual migrations.
SalvusProjectVersion
SalvusProjectVersionclass SalvusProjectVersion(builtins.object):
def __init__(
self, project_path: pathlib.Path, apply_migrations: bool | None = None
): ...Versioning of the SalvusProject data structure.
Parameters
project_pathpathlib.Path — Path to the Salvus project.apply_migrationsbool | 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
version_number str | NoneGet the current version number of the project file structure.