Skip to content

Commit

Permalink
Remove the FrozenDict data sub class
Browse files Browse the repository at this point in the history
The `FrozenDict` class was added to allow `ProcessNode` instances to be
passed to `Process` classes. However, its implementation is flawed as it
uses the pks of the nodes it wraps, which are not persistent across
databases and as such provenance will be lost when it is imported. We
remove the source code here. In a future commit, it will have to be
decided how to migrate existing data.
  • Loading branch information
sphuber committed Feb 26, 2019
1 parent a3e36e5 commit 97c5b30
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 172 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
aiida/backends/tests/test_generic.py|
aiida/backends/tests/__init__.py|
aiida/backends/tests/test_nodes.py|
aiida/backends/tests/orm/data/test_frozendict.py|
aiida/backends/tests/orm/data/test_remote.py|
aiida/backends/tests/orm/utils/test_loaders.py|
aiida/backends/tests/test_parsers.py|
Expand Down
1 change: 0 additions & 1 deletion aiida/backends/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
'orm.authinfos': ['aiida.backends.tests.orm.test_authinfos'],
'orm.comments': ['aiida.backends.tests.orm.test_comments'],
'orm.computer': ['aiida.backends.tests.test_computer'],
'orm.data.frozendict': ['aiida.backends.tests.orm.data.test_frozendict'],
'orm.data.remote': ['aiida.backends.tests.orm.data.test_remote'],
'orm.data.upf': ['aiida.backends.tests.orm.data.test_upf'],
'orm.entities': ['aiida.backends.tests.orm.test_entities'],
Expand Down
19 changes: 1 addition & 18 deletions aiida/backends/tests/engine/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
from aiida.backends.testbase import AiidaTestCase
from aiida.backends.tests.utils import processes as test_processes
from aiida.common.lang import override
from aiida.engine import Process, run, run_get_pid, calcfunction
from aiida.engine import Process, run, run_get_pid
from aiida.orm import load_node
from aiida.orm.nodes.data.int import Int
from aiida.orm.nodes.data.str import Str
from aiida.orm.nodes.data.frozendict import FrozenDict
from aiida.orm.nodes.data.parameter import ParameterData
from aiida.orm import WorkflowNode

Expand Down Expand Up @@ -151,22 +150,6 @@ def test_work_calc_finish(self):
run(p)
self.assertTrue(p.node.is_finished_ok)

def test_calculation_input(self):

@calcfunction
def simple_wf():
return {'a': Int(6), 'b': Int(7)}

outputs, pid = run_get_pid(simple_wf)
calc = load_node(pid)

dp = test_processes.DummyProcess(inputs={'calc': calc})
run(dp)

input_calc = dp.node.get_incoming().get_node_by_label('calc')
self.assertTrue(isinstance(input_calc, FrozenDict))
self.assertEqual(input_calc['a'], outputs['a'])

def test_save_instance_state(self):
proc = test_processes.DummyProcess()
# Save the instance state
Expand Down
43 changes: 0 additions & 43 deletions aiida/backends/tests/orm/data/test_frozendict.py

This file was deleted.

5 changes: 1 addition & 4 deletions aiida/engine/processes/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def define(cls, spec):
spec.input(
'{}.description'.format(spec.metadata_key), valid_type=six.string_types[0], required=False, non_db=True)
spec.input('{}.label'.format(spec.metadata_key), valid_type=six.string_types[0], required=False, non_db=True)
spec.inputs.valid_type = (orm.Data, ProcessNode)
spec.inputs.valid_type = (orm.Data,)
spec.outputs.valid_type = (orm.Data,)

@classmethod
Expand Down Expand Up @@ -556,9 +556,6 @@ def _setup_inputs(self):
if isinstance(node, Code) and not node.is_local() and not self.node.computer:
self.node.computer = node.get_remote_computer()

if isinstance(node, ProcessNode):
node = utils.get_or_create_output_group(node)

# Need this special case for tests that use ProcessNodes as classes
if isinstance(self.node, ProcessNode) and not isinstance(self.node, (CalculationNode, WorkflowNode)):
self.node.add_incoming(node, LinkType.INPUT_WORK, name)
Expand Down
20 changes: 1 addition & 19 deletions aiida/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import

import contextlib
import logging

from six.moves import range
import tornado.ioloop
from tornado import concurrent, gen

from aiida.common.links import LinkType
from aiida.orm.nodes.data.frozendict import FrozenDict

__all__ = ('RefObjectStore', 'interruptable_task', 'InterruptableFuture')

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -172,22 +170,6 @@ def is_process_function(function):
return False


def get_or_create_output_group(node):
"""
For a given ProcessNode, get or create a new frozendict Data node that
has as its values all output Data nodes of the ProcessNode.
:param node: ProcessNode
"""
from aiida.orm import ProcessNode

if not isinstance(node, ProcessNode):
raise TypeError('Can only create output groups for type ProcessNode')

outputs = node.get_outgoing(link_type=(LinkType.CREATE, LinkType.RETURN))
return FrozenDict(dict={entry.link_label: entry.node for entry in outputs})


@contextlib.contextmanager
def loop_scope(loop):
"""
Expand Down
5 changes: 2 additions & 3 deletions aiida/orm/nodes/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from .data import Data
from .float import Float
from .folder import FolderData
from .frozendict import FrozenDict
from .int import Int
from .list import List
from .orbital import OrbitalData
Expand All @@ -32,5 +31,5 @@
from .upf import UpfData

__all__ = ('Data', 'BaseType', 'ArrayData', 'BandsData', 'KpointsData', 'ProjectionData', 'TrajectoryData', 'XyData',
'Bool', 'CifData', 'Code', 'Float', 'FolderData', 'FrozenDict', 'Int', 'List', 'OrbitalData',
'ParameterData', 'RemoteData', 'SinglefileData', 'Str', 'StructureData', 'UpfData')
'Bool', 'CifData', 'Code', 'Float', 'FolderData', 'Int', 'List', 'OrbitalData', 'ParameterData',
'RemoteData', 'SinglefileData', 'Str', 'StructureData', 'UpfData')
82 changes: 0 additions & 82 deletions aiida/orm/nodes/data/frozendict.py

This file was deleted.

1 change: 0 additions & 1 deletion setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
"code = aiida.orm.nodes.data.code:Code",
"float = aiida.orm.nodes.data.float:Float",
"folder = aiida.orm.nodes.data.folder:FolderData",
"frozendict = aiida.orm.nodes.data.frozendict:FrozenDict",
"int = aiida.orm.nodes.data.int:Int",
"list = aiida.orm.nodes.data.list:List",
"numeric = aiida.orm.nodes.data.numeric:NumericType",
Expand Down

0 comments on commit 97c5b30

Please sign in to comment.