Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entry points: add the core. prefix to all entry points #5073

Merged
merged 2 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .docker/opt/configure-aiida.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ if [[ ${NEED_SETUP_PROFILE} == true ]]; then
--label "${computer_name}" \
--description "this computer" \
--hostname "${computer_name}" \
--transport local \
--scheduler direct \
--transport core.local \
--scheduler core.direct \
--work-dir /home/aiida/aiida_run/ \
--mpirun-command "mpirun -np {tot_num_mpiprocs}" \
--mpiprocs-per-machine 1 && \
verdi computer configure local "${computer_name}" \
verdi computer configure core.local "${computer_name}" \
--non-interactive \
--safe-interval 0.0
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/config/add.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
label: add
description: add
input_plugin: arithmetic.add
input_plugin: core.arithmetic.add
on_computer: true
computer: localhost
remote_abs_path: /bin/bash
Expand Down
2 changes: 1 addition & 1 deletion .github/config/doubler.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
label: doubler
description: doubler
input_plugin: templatereplacer
input_plugin: core.templatereplacer
on_computer: true
computer: localhost
remote_abs_path: PLACEHOLDER_REMOTE_ABS_PATH_DOUBLER
Expand Down
4 changes: 2 additions & 2 deletions .github/config/localhost.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
label: localhost
description: localhost
hostname: localhost
transport: local
scheduler: direct
transport: core.local
scheduler: core.direct
shebang: '#!/usr/bin/env bash'
work_dir: PLACEHOLDER_WORK_DIR
mpirun_command: ' '
Expand Down
4 changes: 2 additions & 2 deletions .github/config/slurm-ssh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
label: slurm-ssh
description: slurm container
hostname: localhost
transport: ssh
scheduler: slurm
transport: core.ssh
scheduler: core.slurm
shebang: "#!/bin/bash"
work_dir: /home/{username}/workdir
mpirun_command: "mpirun -np {tot_num_mpiprocs}"
Expand Down
6 changes: 3 additions & 3 deletions .github/system_tests/pytest/test_memory_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from aiida.plugins import CalculationFactory
from aiida import orm

ArithmeticAddCalculation = CalculationFactory('arithmetic.add')
ArithmeticAddCalculation = CalculationFactory('core.arithmetic.add')


def run_finished_ok(*args, **kwargs):
Expand All @@ -36,7 +36,7 @@ def test_leak_run_process():

def test_leak_local_calcjob(aiida_local_code_factory):
"""Test whether running a local CalcJob leaks memory."""
inputs = {'x': orm.Int(1), 'y': orm.Int(2), 'code': aiida_local_code_factory('arithmetic.add', '/bin/bash')}
inputs = {'x': orm.Int(1), 'y': orm.Int(2), 'code': aiida_local_code_factory('core.arithmetic.add', '/bin/bash')}
run_finished_ok(ArithmeticAddCalculation, **inputs)

# check that no reference to the process is left in memory
Expand All @@ -51,7 +51,7 @@ def test_leak_ssh_calcjob():
Note: This relies on the 'slurm-ssh' computer being set up.
"""
code = orm.Code(
input_plugin_name='arithmetic.add', remote_computer_exec=[orm.load_computer('slurm-ssh'), '/bin/bash']
input_plugin_name='core.arithmetic.add', remote_computer_exec=[orm.load_computer('slurm-ssh'), '/bin/bash']
)
inputs = {'x': orm.Int(1), 'y': orm.Int(2), 'code': code}
run_finished_ok(ArithmeticAddCalculation, **inputs)
Expand Down
2 changes: 1 addition & 1 deletion .github/system_tests/pytest/test_pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ def test_aiida_localhost(aiida_localhost):
def test_aiida_local_code(aiida_local_code_factory):
"""Test aiida_local_code_factory fixture.
"""
code = aiida_local_code_factory(entry_point='templatereplacer', executable='diff')
code = aiida_local_code_factory(entry_point='core.templatereplacer', executable='diff')
assert code.computer.label == 'localhost-test'
10 changes: 5 additions & 5 deletions .github/system_tests/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def create_calculation_process(code, inputval):
"""
Create the process and inputs for a submitting / running a calculation.
"""
TemplatereplacerCalculation = CalculationFactory('templatereplacer')
TemplatereplacerCalculation = CalculationFactory('core.templatereplacer')
parameters = Dict(dict={'value': inputval})
template = Dict(
dict={
Expand All @@ -300,7 +300,7 @@ def create_calculation_process(code, inputval):
},
'max_wallclock_seconds': 5 * 60,
'withmpi': False,
'parser_name': 'templatereplacer.doubler',
'parser_name': 'core.templatereplacer.doubler',
}

expected_result = {'value': 2 * inputval, 'retrieved_temporary_files': {'triple_value.tmp': str(inputval * 3)}}
Expand All @@ -318,7 +318,7 @@ def create_calculation_process(code, inputval):

def run_arithmetic_add():
"""Run the `ArithmeticAddCalculation`."""
ArithmeticAddCalculation = CalculationFactory('arithmetic.add')
ArithmeticAddCalculation = CalculationFactory('core.arithmetic.add')

code = load_code(CODENAME_ADD)
inputs = {
Expand Down Expand Up @@ -378,7 +378,7 @@ def run_base_restart_workchain():

def run_multiply_add_workchain():
"""Run the `MultiplyAddWorkChain`."""
MultiplyAddWorkChain = WorkflowFactory('arithmetic.multiply_add')
MultiplyAddWorkChain = WorkflowFactory('core.arithmetic.multiply_add')

code = load_code(CODENAME_ADD)
inputs = {
Expand Down Expand Up @@ -524,7 +524,7 @@ def relaunch_cached(results):
"""Launch the same calculations but with caching enabled -- these should be FINISHED immediately."""
code_doubler = load_code(CODENAME_DOUBLER)
cached_calcs = []
with enable_caching(identifier='aiida.calculations:templatereplacer'):
with enable_caching(identifier='aiida.calculations:core.templatereplacer'):
for counter in range(1, NUMBER_CALCULATIONS + 1):
inputval = counter
calc, expected_result = run_calculation(code=code_doubler, counter=counter, inputval=inputval)
Expand Down
6 changes: 3 additions & 3 deletions .github/system_tests/test_plugin_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_data():
Return some Dict
"""
from aiida.plugins import DataFactory
data = DataFactory('dict')(dict={'data': 'test'})
data = DataFactory('core.dict')(dict={'data': 'test'})
data.store()
return data

Expand All @@ -58,8 +58,8 @@ def get_computer(cls, temp_dir):
label='localhost',
hostname='localhost',
description='my computer',
transport_type='local',
scheduler_type='direct',
transport_type='core.local',
scheduler_type='core.direct',
workdir=temp_dir,
backend=cls.backend
).store()
Expand Down
2 changes: 1 addition & 1 deletion .github/system_tests/test_profile_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_create_use_destroy_profile2(self):

from aiida.orm import load_node
from aiida.plugins import DataFactory
data = DataFactory('dict')(dict={'key': 'value'})
data = DataFactory('core.dict')(dict={'key': 'value'})
data.store()
data_pk = data.pk
self.assertTrue(load_node(data_pk))
Expand Down
2 changes: 1 addition & 1 deletion .github/system_tests/workchains.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from aiida.orm import Int, List, Str
from aiida.plugins import CalculationFactory

ArithmeticAddCalculation = CalculationFactory('arithmetic.add')
ArithmeticAddCalculation = CalculationFactory('core.arithmetic.add')


class ArithmeticAddBaseWorkChain(BaseRestartWorkChain):
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ verdi setup --config "${CONFIG}/profile.yaml"

# set up localhost computer
verdi computer setup --config "${CONFIG}/localhost.yaml"
verdi computer configure local localhost --config "${CONFIG}/localhost-config.yaml"
verdi computer configure core.local localhost --config "${CONFIG}/localhost-config.yaml"
verdi computer test localhost
verdi code setup --config "${CONFIG}/doubler.yaml"
verdi code setup --config "${CONFIG}/add.yaml"

# set up slurm-ssh computer
verdi computer setup --config "${CONFIG}/slurm-ssh.yaml"
verdi computer configure ssh slurm-ssh --config "${CONFIG}/slurm-ssh-config.yaml" -n # needs slurm container
verdi computer configure core.ssh slurm-ssh --config "${CONFIG}/slurm-ssh-config.yaml" -n # needs slurm container
verdi computer test slurm-ssh --print-traceback

verdi profile setdefault test_${AIIDA_TEST_BACKEND}
Expand Down
2 changes: 1 addition & 1 deletion .molecule/default/files/polish/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@click.argument('expression', type=click.STRING, required=False)
@click.option('-d', '--daemon', is_flag=True, help='Submit the workchains to the daemon.')
@options.CODE(
type=types.CodeParamType(entry_point='arithmetic.add'),
type=types.CodeParamType(entry_point='core.arithmetic.add'),
required=False,
help='Code to perform the add operations with. Required if -C flag is specified'
)
Expand Down
2 changes: 1 addition & 1 deletion .molecule/default/files/polish/lib/template/base.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from aiida.orm import Code, Int, Str, Dict
from aiida.plugins import CalculationFactory


ArithmeticAddCalculation = CalculationFactory('arithmetic.add')
ArithmeticAddCalculation = CalculationFactory('core.arithmetic.add')


def get_default_options(num_machines=1, max_wallclock_seconds=1800):
Expand Down
6 changes: 3 additions & 3 deletions .molecule/default/setup_aiida.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@
--label "localhost"
--description "this computer"
--hostname "localhost"
--transport local
--scheduler direct
--transport core.local
--scheduler core.direct
--work-dir {{ aiida_path }}/local_work_dir/
--mpirun-command "mpirun -np {tot_num_mpiprocs}"
--mpiprocs-per-machine 1

- name: verdi computer configure localhost
when: aiida_check_computer.rc != 0
command: >
{{ venv_bin }}/verdi -p {{ aiida_backend }} computer configure local "localhost"
{{ venv_bin }}/verdi -p {{ aiida_backend }} computer configure core.local "localhost"
--non-interactive
--safe-interval 0.0

Expand Down
2 changes: 1 addition & 1 deletion .molecule/default/test_polish_workchains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
command: >
{{ venv_bin }}/verdi -p {{ aiida_backend }} code setup
-D "simple script that adds two numbers"
-n -L add -P arithmetic.add
-n -L add -P core.arithmetic.add
-Y localhost --remote-abs-path=/bin/bash

- name: Copy workchain files
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ repos:
aiida/orm/nodes/node.py|
aiida/orm/nodes/process/.*py|
aiida/plugins/entry_point.py|
aiida/plugins/factories.py|
aiida/repository/.*py|
aiida/tools/graph/graph_traversers.py|
aiida/tools/groups/paths.py|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
###########################################################################
# Copyright (c), The AiiDA team. All rights reserved. #
# This file is part of the AiiDA code. #
# #
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core #
# For further information on the license, see the LICENSE.txt file #
# For further information please visit http://www.aiida.net #
###########################################################################
# pylint: disable=invalid-name,line-too-long
"""Update node types after `core.` prefix was added to entry point names."""
from django.db import migrations

from aiida.backends.djsite.db.migrations import upgrade_schema_version

REVISION = '1.0.49'
DOWN_REVISION = '1.0.48'

forward_sql = """
UPDATE db_dbnode SET node_type = 'data.core.array.ArrayData.' WHERE node_type = 'data.array.ArrayData.';
UPDATE db_dbnode SET node_type = 'data.core.array.bands.BandsData.' WHERE node_type = 'data.array.bands.BandsData.';
UPDATE db_dbnode SET node_type = 'data.core.array.kpoints.KpointData.' WHERE node_type = 'data.array.kpoints.KpointData.';
UPDATE db_dbnode SET node_type = 'data.core.array.projection.ProjectionData.' WHERE node_type = 'data.array.projection.ProjectionData.';
UPDATE db_dbnode SET node_type = 'data.core.array.trajectory.TrajectoryData.' WHERE node_type = 'data.array.trajectory.TrajectoryData.';
UPDATE db_dbnode SET node_type = 'data.core.array.xy.XyData.' WHERE node_type = 'data.array.xy.XyData.';
UPDATE db_dbnode SET node_type = 'data.core.base.BaseData.' WHERE node_type = 'data.base.BaseData.';
UPDATE db_dbnode SET node_type = 'data.core.bool.Bool.' WHERE node_type = 'data.bool.Bool.';
UPDATE db_dbnode SET node_type = 'data.core.cif.CifData.' WHERE node_type = 'data.cif.CifData.';
UPDATE db_dbnode SET node_type = 'data.core.code.Code.' WHERE node_type = 'data.code.Code.';
UPDATE db_dbnode SET node_type = 'data.core.dict.Dict.' WHERE node_type = 'data.dict.Dict.';
UPDATE db_dbnode SET node_type = 'data.core.float.Float.' WHERE node_type = 'data.float.Float.';
UPDATE db_dbnode SET node_type = 'data.core.folder.FolderData.' WHERE node_type = 'data.folder.FolderData.';
UPDATE db_dbnode SET node_type = 'data.core.int.Int.' WHERE node_type = 'data.int.Int.';
UPDATE db_dbnode SET node_type = 'data.core.list.List.' WHERE node_type = 'data.list.List.';
UPDATE db_dbnode SET node_type = 'data.core.numeric.NumericData.' WHERE node_type = 'data.numeric.NumericData.';
UPDATE db_dbnode SET node_type = 'data.core.orbital.OrbitalData.' WHERE node_type = 'data.orbital.OrbitalData.';
UPDATE db_dbnode SET node_type = 'data.core.remote.RemoteData.' WHERE node_type = 'data.remote.RemoteData.';
UPDATE db_dbnode SET node_type = 'data.core.remote.stash.RemoteStashData.' WHERE node_type = 'data.remote.stash.RemoteStashData.';
UPDATE db_dbnode SET node_type = 'data.core.remote.stash.folder.RemoteStashFolderData.' WHERE node_type = 'data.remote.stash.folder.';
UPDATE db_dbnode SET node_type = 'data.core.singlefile.SinglefileData.' WHERE node_type = 'data.singlefile.SinglefileData.';
UPDATE db_dbnode SET node_type = 'data.core.str.Str.' WHERE node_type = 'data.str.Str.';
UPDATE db_dbnode SET node_type = 'data.core.structure.StructureData.' WHERE node_type = 'data.structure.StructureData.';
UPDATE db_dbnode SET node_type = 'data.core.upf.UpfData.' WHERE node_type = 'data.upf.UpfData.';
UPDATE db_dbcomputer SET scheduler_type = 'core.direct' WHERE scheduler_type = 'direct';
UPDATE db_dbcomputer SET scheduler_type = 'core.lsf' WHERE scheduler_type = 'lsf';
UPDATE db_dbcomputer SET scheduler_type = 'core.pbspro' WHERE scheduler_type = 'pbspro';
UPDATE db_dbcomputer SET scheduler_type = 'core.sge' WHERE scheduler_type = 'sge';
UPDATE db_dbcomputer SET scheduler_type = 'core.slurm' WHERE scheduler_type = 'slurm';
UPDATE db_dbcomputer SET scheduler_type = 'core.torque' WHERE scheduler_type = 'torque';
UPDATE db_dbcomputer SET transport_type = 'core.local' WHERE transport_type = 'local';
UPDATE db_dbcomputer SET transport_type = 'core.ssh' WHERE transport_type = 'ssh';
UPDATE db_dbnode SET process_type = 'aiida.calculations:core.arithmetic.add' WHERE process_type = 'aiida.calculations:arithmetic.add';
UPDATE db_dbnode SET process_type = 'aiida.calculations:core.templatereplacer' WHERE process_type = 'aiida.calculations:templatereplacer';
UPDATE db_dbnode SET process_type = 'aiida.workflows:core.arithmetic.add_multiply' WHERE process_type = 'aiida.workflows:arithmetic.add_multiply';
UPDATE db_dbnode SET process_type = 'aiida.workflows:core.arithmetic.multiply_add' WHERE process_type = 'aiida.workflows:arithmetic.multiply_add';
UPDATE db_dbnode SET attributes = jsonb_set(attributes, '{"parser_name"}', '"core.arithmetic.add"') WHERE attributes->>'parser_name' = 'arithmetic.add';
UPDATE db_dbnode SET attributes = jsonb_set(attributes, '{"parser_name"}', '"core.templatereplacer.doubler"') WHERE attributes->>'parser_name' = 'templatereplacer.doubler';
"""


class Migration(migrations.Migration):
"""Update node types after `core.` prefix was added to entry point names."""

dependencies = [
('db', '0048_computer_name_to_label'),
]

operations = [
migrations.RunSQL(sql=forward_sql, reverse_sql=''),
upgrade_schema_version(REVISION, DOWN_REVISION),
]
2 changes: 1 addition & 1 deletion aiida/backends/djsite/db/migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DeserializationException(AiidaException):
pass


LATEST_MIGRATION = '0048_computer_name_to_label'
LATEST_MIGRATION = '0049_entry_point_core_prefix'


def _update_schema_version(version, apps, _):
Expand Down
2 changes: 1 addition & 1 deletion aiida/backends/djsite/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_bands_and_parents_structure(self, args):
pks = [_[0] for _ in this_chunk]

# get the closest structures (WITHOUT DbPath)
structure_dict = get_closest_parents(pks, Q(node_type='data.structure.StructureData.'), chunk_size=1)
structure_dict = get_closest_parents(pks, Q(node_type='data.core.structure.StructureData.'), chunk_size=1)

struc_pks = [structure_dict.get(pk) for pk in pks]

Expand Down
Loading