Skip to content

Commit

Permalink
Rename PsqlDostoreMigrator to PsqlDosMigrator
Browse files Browse the repository at this point in the history
This makes the naming consistent with the `PsqlDosBackend` storage
backend implementation to which it belongs.
  • Loading branch information
sphuber committed Nov 15, 2022
1 parent 230243e commit 2651058
Show file tree
Hide file tree
Showing 40 changed files with 95 additions and 99 deletions.
4 changes: 2 additions & 2 deletions aiida/storage/psql_dos/alembic_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from aiida.cmdline import is_verbose
from aiida.cmdline.groups.verdi import VerdiCommandGroup
from aiida.cmdline.params import options
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


class AlembicRunner:
Expand All @@ -33,7 +33,7 @@ def execute_alembic_command(self, command_name, connect=True, **kwargs):
"""
if self.profile is None:
raise click.ClickException('No profile specified')
migrator = PsqlDostoreMigrator(self.profile)
migrator = PsqlDosMigrator(self.profile)

context = migrator._alembic_connect() if connect else nullcontext(migrator._alembic_config()) # pylint: disable=protected-access
with context as config:
Expand Down
4 changes: 2 additions & 2 deletions aiida/storage/psql_dos/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from aiida.orm.entities import EntityTypes
from aiida.orm.implementation import BackendEntity, StorageBackend
from aiida.storage.log import STORAGE_LOGGER
from aiida.storage.psql_dos.migrator import REPOSITORY_UUID_KEY, PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import REPOSITORY_UUID_KEY, PsqlDosMigrator
from aiida.storage.psql_dos.models import base

from .orm import authinfos, comments, computers, convert, groups, logs, nodes, querybuilder, users
Expand Down Expand Up @@ -71,7 +71,7 @@ class PsqlDosBackend(StorageBackend): # pylint: disable=too-many-public-methods
The `django` backend was removed, to consolidate access to this storage.
"""

migrator = PsqlDostoreMigrator
migrator = PsqlDosMigrator

@classmethod
def version_head(cls) -> str:
Expand Down
2 changes: 1 addition & 1 deletion aiida/storage/psql_dos/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
REPOSITORY_UUID_KEY = 'repository|uuid'


class PsqlDostoreMigrator:
class PsqlDosMigrator:
"""Class for validating and migrating `psql_dos` storage instances.
.. important:: This class should only be accessed via the storage backend class (apart from for test purposes)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/internals/storage/psql_dos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Between nodes themselves (Links)
Storage schema migrations
=========================

Migrations of the storage schema, to bring it inline with updates to the ``aiida-core`` API, are implemented by :py:class:`~aiida.storage.psql_dos.migrator.PsqlDostoreMigrator` , using `alembic <https://alembic.sqlalchemy.org>`_.
Migrations of the storage schema, to bring it inline with updates to the ``aiida-core`` API, are implemented by :py:class:`~aiida.storage.psql_dos.migrator.PsqlDosMigrator` , using `alembic <https://alembic.sqlalchemy.org>`_.

Legacy schema
-------------
Expand Down
4 changes: 2 additions & 2 deletions tests/cmdline/commands/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def storage_cls(*args, **kwargs): # pylint: disable=unused-argument
from aiida.common.exceptions import IncompatibleStorageSchema
raise IncompatibleStorageSchema()

monkeypatch.setattr(migrator.PsqlDostoreMigrator, 'validate_storage', storage_cls)
monkeypatch.setattr(migrator.PsqlDosMigrator, 'validate_storage', storage_cls)

result = run_cli_command(cmd_status.verdi_status, raises=True)
assert 'verdi storage migrate' in result.output
Expand All @@ -90,7 +90,7 @@ def storage_cls(*args, **kwargs): # pylint: disable=unused-argument
from aiida.common.exceptions import CorruptStorage
raise CorruptStorage()

monkeypatch.setattr(migrator.PsqlDostoreMigrator, 'validate_storage', storage_cls)
monkeypatch.setattr(migrator.PsqlDosMigrator, 'validate_storage', storage_cls)

result = run_cli_command(cmd_status.verdi_status, raises=True)
assert 'Storage is corrupted' in result.output
Expand Down
4 changes: 2 additions & 2 deletions tests/storage/psql_dos/migrations/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sqlalchemy import text

from aiida.manage.configuration import Profile
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator
from aiida.storage.psql_dos.utils import create_sqlalchemy_engine


Expand Down Expand Up @@ -114,7 +114,7 @@ def uninitialised_profile(empty_pg_cluster: PGTest, tmp_path): # pylint: disabl
@pytest.fixture()
def perform_migrations(uninitialised_profile): # pylint: disable=redefined-outer-name
"""A fixture to setup a database for migration tests."""
yield PsqlDostoreMigrator(uninitialised_profile)
yield PsqlDosMigrator(uninitialised_profile)


def _generate_column_schema(profile: Profile) -> dict:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_dblog_update(perform_migrations: PsqlDostoreMigrator): # pylint: disable=too-many-locals
def test_dblog_update(perform_migrations: PsqlDosMigrator): # pylint: disable=too-many-locals
"""Test the update to the ``DbLog`` table."""
# starting revision
perform_migrations.migrate_up('django@django_0023')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from aiida.storage.psql_dos.backend import get_filepath_container
from aiida.storage.psql_dos.migrations.utils import utils
from aiida.storage.psql_dos.migrations.utils.create_dbattribute import create_rows
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_traj_data(perform_migrations: PsqlDostoreMigrator):
def test_traj_data(perform_migrations: PsqlDosMigrator):
"""Test `TrajectoryData` nodes migration, moving symbol lists from repository array to attributes."""
# starting revision
perform_migrations.migrate_up('django@django_0025')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"""Test alterations to `db_dbnode.type`values."""
from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_node_repository(perform_migrations: PsqlDostoreMigrator):
def test_node_repository(perform_migrations: PsqlDosMigrator):
"""Test migration adding the `repository_metadata` column to the `Node` model."""
# starting revision
perform_migrations.migrate_up('django@django_0027')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"""Test removing legacy workflows."""
from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_node_repository(perform_migrations: PsqlDostoreMigrator):
def test_node_repository(perform_migrations: PsqlDosMigrator):
"""Test removing legacy workflows."""
# starting revision
perform_migrations.migrate_up('django@django_0031')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_text_to_jsonb(perform_migrations: PsqlDostoreMigrator): # pylint: disable=too-many-locals
def test_text_to_jsonb(perform_migrations: PsqlDosMigrator): # pylint: disable=too-many-locals
"""Test replacing the use of text fields to store JSON data with JSONB fields.
`db_dbauthinfo.auth_params`, `db_dbauthinfo.metadata`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from sqlalchemy import select

from aiida.common import timezone
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_attr_extra_migration(perform_migrations: PsqlDostoreMigrator):
def test_attr_extra_migration(perform_migrations: PsqlDosMigrator):
"""
A "simple" test for the attributes and extra migration from EAV to JSONB.
It stores a sample dictionary using the EAV deserialization of AiiDA Django
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_attr_extra_migration(perform_migrations: PsqlDostoreMigrator):
assert extras == {'extra_0': 'test', 'extra_1': 1, 'extra_2': True, 'extra_3': 1.0, 'extra_4': 2022}


def test_settings_migration(perform_migrations: PsqlDostoreMigrator):
def test_settings_migration(perform_migrations: PsqlDosMigrator):
"""
This test checks the correct migration of the settings.
Setting records were used as an example from a typical settings table of Django EAV.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from aiida.common import timezone
from aiida.storage.psql_dos.migrations.utils.calc_state import STATE_MAPPING, StateMapping
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_legacy_jobcalcstate(perform_migrations: PsqlDostoreMigrator):
def test_legacy_jobcalcstate(perform_migrations: PsqlDosMigrator):
"""Test the migration that performs a data migration of legacy `JobCalcState`."""
# starting revision
perform_migrations.migrate_up('django@django_0037')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"""Test the node hash reset."""
from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_reset_hash(perform_migrations: PsqlDostoreMigrator):
def test_reset_hash(perform_migrations: PsqlDosMigrator):
"""Test the node hash reset."""
# starting revision
perform_migrations.migrate_up('django@django_0038')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from uuid import uuid4

from aiida.common import timezone
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_legacy_jobcalc_attrs(perform_migrations: PsqlDostoreMigrator):
def test_legacy_jobcalc_attrs(perform_migrations: PsqlDosMigrator):
"""Test the migration that performs a data migration of legacy `JobCalcState`."""
# starting revision
perform_migrations.migrate_up('django@django_0039')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from uuid import uuid4

from aiida.common import timezone
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_legacy_jobcalc_attrs(perform_migrations: PsqlDostoreMigrator):
def test_legacy_jobcalc_attrs(perform_migrations: PsqlDosMigrator):
"""Test sealing of unsealed processes."""
# starting revision
perform_migrations.migrate_up('django@django_0040')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from uuid import uuid4

from aiida.common import timezone
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_legacy_jobcalc_attrs(perform_migrations: PsqlDostoreMigrator):
def test_legacy_jobcalc_attrs(perform_migrations: PsqlDosMigrator):
"""Test update of link labels."""
# starting revision
perform_migrations.migrate_up('django@django_0042')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from uuid import uuid4

from aiida.common import timezone
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_group_type_string(perform_migrations: PsqlDostoreMigrator):
def test_group_type_string(perform_migrations: PsqlDosMigrator):
"""Test migration of `type_string` after the `Group` class became pluginnable."""
# starting revision
perform_migrations.migrate_up('django@django_0043')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from uuid import uuid4

from aiida.common import timezone
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_group_extras(perform_migrations: PsqlDostoreMigrator):
def test_group_extras(perform_migrations: PsqlDosMigrator):
"""Test migration to add the `extras` JSONB column to the `DbGroup` model."""
# starting revision
perform_migrations.migrate_up('django@django_0044')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"""Test migration adding the `repository_metadata` column to the `Node` model."""
from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_node_repository(perform_migrations: PsqlDostoreMigrator):
def test_node_repository(perform_migrations: PsqlDosMigrator):
"""Test migration adding the `repository_metadata` column to the `Node` model."""
# starting revision
perform_migrations.migrate_up('django@django_0045')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from aiida.common import timezone
from aiida.storage.psql_dos.backend import get_filepath_container
from aiida.storage.psql_dos.migrations.utils import utils
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator

REPOSITORY_UUID_KEY = 'repository|uuid'


def test_node_repository(perform_migrations: PsqlDostoreMigrator): # pylint: disable=too-many-locals
def test_node_repository(perform_migrations: PsqlDosMigrator): # pylint: disable=too-many-locals
"""Test migration of the old file repository to the disk object store."""
# starting revision
perform_migrations.migrate_up('django@django_0046')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
###########################################################################
"""Test the renaming of `name` to `label` for `db_dbcomputer`."""
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_computer_name_to_label(perform_migrations: PsqlDostoreMigrator):
def test_computer_name_to_label(perform_migrations: PsqlDosMigrator):
"""Test the renaming of `name` to `label` for `db_dbcomputer`.
Verify that the column was successfully renamed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"""Test migration that updates node types after `core.` prefix was added to entry point names."""
from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_entry_point_core_prefix(perform_migrations: PsqlDostoreMigrator):
def test_entry_point_core_prefix(perform_migrations: PsqlDosMigrator):
"""Test the renaming of `name` to `label` for `db_dbcomputer`.
Verify that the column was successfully renamed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"""Test migration that renames all index/constraint names, to have parity between django/sqlalchemy."""
from aiida.common import timezone
from aiida.common.utils import get_new_uuid
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_schema_parity(perform_migrations: PsqlDostoreMigrator):
def test_schema_parity(perform_migrations: PsqlDosMigrator):
"""Test the renaming of indexes and constaints works, when data is in the database."""
# starting revision
perform_migrations.migrate_up('django@django_0049')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"""
import sqlalchemy as sa

from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_v0x_django_0003(perform_migrations: PsqlDostoreMigrator, reflect_schema, data_regression): # pylint: disable=too-many-locals
def test_v0x_django_0003(perform_migrations: PsqlDosMigrator, reflect_schema, data_regression): # pylint: disable=too-many-locals
"""Test against an archive database schema, created in aiida-core v0.x, at revision django_0003."""
metadata = generate_schema()
with perform_migrations._connection_context() as conn: # pylint: disable=protected-access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# For further information please visit http://www.aiida.net #
###########################################################################
"""Test migrating from the base of the django branch, to the main head."""
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_migrate(perform_migrations: PsqlDostoreMigrator):
def test_migrate(perform_migrations: PsqlDosMigrator):
"""Test that the migrator can migrate from the base of the django branch, to the main head."""
perform_migrations.migrate_up('django@django_0001') # the base of the django branch
perform_migrations.migrate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# For further information please visit http://www.aiida.net #
###########################################################################
"""Tests for group migrations: 118349c10896 -> 0edcdd5a30f0"""
from aiida.storage.psql_dos.migrator import PsqlDostoreMigrator
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_group_typestring(perform_migrations: PsqlDostoreMigrator):
def test_group_typestring(perform_migrations: PsqlDosMigrator):
"""Test the migration that renames the DbGroup type strings.
Verify that the type strings are properly migrated.
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_group_typestring(perform_migrations: PsqlDostoreMigrator):
assert group_autorun.type_string == 'core.auto'


def test_group_extras(perform_migrations: PsqlDostoreMigrator):
def test_group_extras(perform_migrations: PsqlDosMigrator):
"""Test migration to add the `extras` JSONB column to the `DbGroup` model.
Verify that the model now has an extras column with empty dictionary as default.
Expand Down
Loading

0 comments on commit 2651058

Please sign in to comment.