Skip to content

Commit

Permalink
Merge pull request #809 from greschd/feature_get_prefix
Browse files Browse the repository at this point in the history
Add RMQ_PREFIX to profile, use when creating RabbitMQ queues
  • Loading branch information
sphuber authored Jan 17, 2018
2 parents b82c2e3 + a140af9 commit c34d928
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .travis-data/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from aiida.common.exceptions import NotExistent
from aiida.orm import DataFactory
from aiida.orm.data.base import Int
from aiida.work.run import run
from aiida.work.launch import run_get_node
from workchains import ParentWorkChain

ParameterData = DataFactory('parameter')
Expand Down Expand Up @@ -145,8 +145,8 @@ def main():
expected_results_workchains = {}
for index in range(1, number_workchains + 1):
inp = Int(index)
future = run(ParentWorkChain, inp=inp)
expected_results_workchains[future.pk] = index * 2
result, node = run_get_node(ParentWorkChain, inp=inp)
expected_results_workchains[node.pk] = index * 2


calculation_pks = sorted(expected_results_calculations.keys())
Expand Down
2 changes: 1 addition & 1 deletion aiida/backends/tests/work/work_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_dict(self):
self.assertEqual(wc.ctx['new_attr'], 5)

del wc.ctx['new_attr']
with self.assertRaises(AttributeError):
with self.assertRaises(KeyError):
wc.ctx['new_attr']


Expand Down
2 changes: 2 additions & 0 deletions aiida/cmdline/verdilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ def setup(profile, only_config, non_interactive=False, **kwargs):
click.echo("Error during configuation: {}".format(e.message), err=True)
sys.exit(1)
except KeyError as e:
import traceback
click.echo(traceback.format_exc())
click.echo("--non-interactive requires all values to be given on the commandline! Missing argument: {}".format(e.message), err=True)
sys.exit(1)
else:
Expand Down
14 changes: 13 additions & 1 deletion aiida/common/additions/config_migrations/_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
Defines the migration functions between different config versions.
"""

import uuid

# The current configuration version. Increment this value whenever a change
# to the config.json structure is made.
CURRENT_CONFIG_VERSION = 1
CURRENT_CONFIG_VERSION = 2
# The oldest config version where no backwards-incompatible changes have been
# made since. When doing backwards-incompatible changes, set this to the current
# version.
Expand Down Expand Up @@ -43,11 +45,21 @@ def apply(self, config):
)
return config

def _1_add_rmq_prefix(config):
for profile in config.get('profiles', {}).values():
profile['RMQ_PREFIX'] = uuid.uuid4().hex
return config

# Maps the initial config version to the ConfigMigration which updates it.
_MIGRATION_LOOKUP = {
0: ConfigMigration(
migrate_function=lambda x: x,
current_version=1,
oldest_version=0
),
1: ConfigMigration(
migrate_function=_1_add_rmq_prefix,
current_version=2,
oldest_version=0
)
}
10 changes: 8 additions & 2 deletions aiida/common/additions/config_migrations/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
# For further information please visit http://www.aiida.net #
###########################################################################
import os
import unittest
import uuid
import json
import unittest
try:
from unittest import mock
except ImportError:
import mock

from ._utils import check_and_migrate_config
from ._migrations import _MIGRATION_LOOKUP
Expand All @@ -28,7 +33,8 @@ def test_check_and_migrate(self):
Test the full config migration.
"""
initial_config = load_config_sample('input/0.json')
final_config = check_and_migrate_config(initial_config, store=False)
with mock.patch.object(uuid, 'uuid4', return_value=uuid.UUID(hex='0'*32)):
final_config = check_and_migrate_config(initial_config, store=False)
reference_config = load_config_sample('reference/final.json')
self.assertEqual(final_config, reference_config)

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"CONFIG_VERSION": {"CURRENT": 1, "OLDEST_COMPATIBLE": 0}, "default_profiles": {"daemon": "default", "verdi": "default"}, "profiles": {"quicksetup": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "some_random_password", "AIIDADB_NAME": "aiidadb_qs_some_user", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "5432", "default_user_email": "email@aiida.net", "AIIDADB_REPOSITORY_URI": "file:////home/some_user/.aiida/repository-quicksetup/", "AIIDADB_USER": "aiida_qs_greschd"}}}
{"CONFIG_VERSION": {"CURRENT": 2, "OLDEST_COMPATIBLE": 0}, "default_profiles": {"daemon": "default", "verdi": "default"}, "profiles": {"quicksetup": {"RMQ_PREFIX": "00000000000000000000000000000000", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "some_random_password", "AIIDADB_NAME": "aiidadb_qs_some_user", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "5432", "default_user_email": "email@aiida.net", "AIIDADB_REPOSITORY_URI": "file:////home/some_user/.aiida/repository-quicksetup/", "AIIDADB_USER": "aiida_qs_greschd"}}}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from aiida.common.additions.old_migrations.migration_05dj_to_06dj import (
Migration)

from ..config_migrations import check_and_migrate_config


class MigrationTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"default_profiles": {"daemon": "default", "verdi": "default"}, "profiles": {"default": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "AIIDADB_BACKEND": "django", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
{"default_profiles": {"daemon": "default", "verdi": "default"}, "CONFIG_VERSION": {"CURRENT": 2, "OLDEST_COMPATIBLE": 0}, "profiles": {"default": {"RMQ_PREFIX": "84a80e34878441b6a6bdf2a54bf1445f", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"default_profiles": {"daemon": "default", "verdi": "default"}, "profiles": {"default": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
{"default_profiles": {"daemon": "default", "verdi": "default"}, "CONFIG_VERSION": {"CURRENT": 2, "OLDEST_COMPATIBLE": 0}, "profiles": {"default": {"RMQ_PREFIX": "84a80e34878441b6a6bdf2a54bf1445f", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"default_profiles": {"daemon": "default", "verdi": "default"}, "modules_for_verdi_shell": "aiida.workflows.user.epfl_theos.TheosWorkflowFactory", "profiles": {"default": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "AIIDADB_BACKEND": "django", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida_user_2/.aiida/repository/", "AIIDADB_USER": "aiida"}, "smalldbpostgres": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "smalldb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "AIIDADB_BACKEND": "django", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_postgres_database/repository/", "AIIDADB_USER": "aiida"}, "sssp": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "ssspdb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "AIIDADB_BACKEND": "django", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/sssp_database/repository_sssp/", "AIIDADB_USER": "aiida"}, "smalldb": {"AIIDADB_ENGINE": "sqlite3", "AIIDADB_PASS": "234", "AIIDADB_NAME": "/scratch/aiida_user_2/small_sqlite_database/smallsqlite.db", "AIIDADB_HOST": "", "AIIDADB_PORT": "", "default_user_email": "aiida_user_2@epfl.ch", "AIIDADB_BACKEND": "django", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_sqlite_database/repository/", "AIIDADB_USER": ""}, "castelli": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadbcastelli2015", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_3@epfl.ch", "AIIDADB_BACKEND": "django", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/database/repository/", "AIIDADB_USER": "aiida"}}}
{"default_profiles": {"daemon": "default", "verdi": "default"}, "modules_for_verdi_shell": "aiida.workflows.user.epfl_theos.TheosWorkflowFactory", "profiles": {"default": {"RMQ_PREFIX": "82b505bca1514c558d065cfb7a555709", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida_user_2/.aiida/repository/", "AIIDADB_USER": "aiida"}, "smalldbpostgres": {"RMQ_PREFIX": "982f6468964f43d2b9b69247c011f054", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "smalldb", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_postgres_database/repository/", "AIIDADB_USER": "aiida"}, "sssp": {"RMQ_PREFIX": "b124262fbe564efd80a589cabc7ac93e", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "ssspdb", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/sssp_database/repository_sssp/", "AIIDADB_USER": "aiida"}, "smalldb": {"RMQ_PREFIX": "a4299508a9e64a5a913d225d4be6cde1", "AIIDADB_ENGINE": "sqlite3", "AIIDADB_PASS": "234", "AIIDADB_NAME": "/scratch/aiida_user_2/small_sqlite_database/smallsqlite.db", "AIIDADB_HOST": "", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_sqlite_database/repository/", "AIIDADB_USER": ""}, "castelli": {"RMQ_PREFIX": "fe298fdb80a046fd81fad1ee0623290c", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadbcastelli2015", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "django", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_3@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/database/repository/", "AIIDADB_USER": "aiida"}}, "CONFIG_VERSION": {"CURRENT": 2, "OLDEST_COMPATIBLE": 0}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"default_profiles": {"daemon": "default", "verdi": "default"}, "modules_for_verdi_shell": "aiida.workflows.user.epfl_theos.TheosWorkflowFactory", "profiles": {"default": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida_user_2/.aiida/repository/", "AIIDADB_USER": "aiida"}, "smalldbpostgres": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "smalldb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_postgres_database/repository/", "AIIDADB_USER": "aiida"}, "sssp": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "ssspdb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/sssp_database/repository_sssp/", "AIIDADB_USER": "aiida"}, "smalldb": {"AIIDADB_ENGINE": "sqlite3", "AIIDADB_PASS": "234", "AIIDADB_NAME": "/scratch/aiida_user_2/small_sqlite_database/smallsqlite.db", "AIIDADB_HOST": "", "AIIDADB_PORT": "", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_sqlite_database/repository/", "AIIDADB_USER": ""}, "castelli": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadbcastelli2015", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_3@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/database/repository/", "AIIDADB_USER": "aiida"}}}
{"default_profiles": {"daemon": "default", "verdi": "default"}, "modules_for_verdi_shell": "aiida.workflows.user.epfl_theos.TheosWorkflowFactory", "profiles": {"default": {"RMQ_PREFIX": "82b505bca1514c558d065cfb7a555709", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida_user_2/.aiida/repository/", "AIIDADB_USER": "aiida"}, "smalldbpostgres": {"RMQ_PREFIX": "982f6468964f43d2b9b69247c011f054", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "smalldb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_postgres_database/repository/", "AIIDADB_USER": "aiida"}, "sssp": {"RMQ_PREFIX": "b124262fbe564efd80a589cabc7ac93e", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "ssspdb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/sssp_database/repository_sssp/", "AIIDADB_USER": "aiida"}, "smalldb": {"RMQ_PREFIX": "a4299508a9e64a5a913d225d4be6cde1", "AIIDADB_ENGINE": "sqlite3", "AIIDADB_PASS": "234", "AIIDADB_NAME": "/scratch/aiida_user_2/small_sqlite_database/smallsqlite.db", "AIIDADB_HOST": "", "AIIDADB_PORT": "", "default_user_email": "aiida_user_2@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/small_sqlite_database/repository/", "AIIDADB_USER": ""}, "castelli": {"RMQ_PREFIX": "fe298fdb80a046fd81fad1ee0623290c", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "123", "AIIDADB_NAME": "aiidadbcastelli2015", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida_user_3@epfl.ch", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///scratch/aiida_user_2/database/repository/", "AIIDADB_USER": "aiida"}}, "CONFIG_VERSION": {"CURRENT": 2, "OLDEST_COMPATIBLE": 0}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"default_profiles": {"daemon": "default", "verdi": "default"}, "profiles": {"default": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "AIIDADB_BACKEND": "sqlalchemy", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
{"default_profiles": {"daemon": "default", "verdi": "default"}, "CONFIG_VERSION": {"CURRENT": 2, "OLDEST_COMPATIBLE": 0}, "profiles": {"default": {"RMQ_PREFIX": "ccdbdc2bd4ca49799c5a45b3be229848", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "sqlalchemy", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"default_profiles": {"daemon": "default", "verdi": "default"}, "profiles": {"default": {"AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "AIIDADB_BACKEND": "sqlalchemy", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
{"default_profiles": {"daemon": "default", "verdi": "default"}, "CONFIG_VERSION": {"CURRENT": 2, "OLDEST_COMPATIBLE": 0}, "profiles": {"default": {"RMQ_PREFIX": "ccdbdc2bd4ca49799c5a45b3be229848", "AIIDADB_ENGINE": "postgresql_psycopg2", "AIIDADB_PASS": "aiida_pass", "AIIDADB_NAME": "aiidadb", "AIIDADB_HOST": "localhost", "AIIDADB_BACKEND": "sqlalchemy", "AIIDADB_PORT": "5432", "default_user_email": "aiida@localhost", "TIMEZONE": "Europe/Zurich", "AIIDADB_REPOSITORY_URI": "file:///home/aiida/.aiida/repository/", "AIIDADB_USER": "aiida"}}}
Loading

0 comments on commit c34d928

Please sign in to comment.