diff --git a/aiida/orm/nodes/data/__init__.py b/aiida/orm/nodes/data/__init__.py index 0023f8a107..9734c08d2d 100644 --- a/aiida/orm/nodes/data/__init__.py +++ b/aiida/orm/nodes/data/__init__.py @@ -10,7 +10,7 @@ """Module with `Node` sub classes for data structures.""" from .array import ArrayData, BandsData, KpointsData, ProjectionData, TrajectoryData, XyData -from .base import BaseType +from .base import BaseType, to_aiida_type from .bool import Bool from .cif import CifData from .code import Code @@ -31,5 +31,5 @@ __all__ = ( 'Data', 'BaseType', 'ArrayData', 'BandsData', 'KpointsData', 'ProjectionData', 'TrajectoryData', 'XyData', 'Bool', 'CifData', 'Code', 'Float', 'FolderData', 'Int', 'List', 'OrbitalData', 'Dict', 'RemoteData', 'SinglefileData', - 'Str', 'StructureData', 'UpfData', 'NumericType' + 'Str', 'StructureData', 'UpfData', 'NumericType', 'to_aiida_type' ) diff --git a/docs/source/reference/api/public.rst b/docs/source/reference/api/public.rst index 66d30f5c87..0464d7a1ac 100644 --- a/docs/source/reference/api/public.rst +++ b/docs/source/reference/api/public.rst @@ -102,6 +102,7 @@ If a module is mentioned, then all the resources defined in its ``__all__`` are load_code load_computer load_group + to_aiida_type ``aiida.parsers`` diff --git a/docs/source/topics/processes/include/snippets/serialize/workchain_serialize.py b/docs/source/topics/processes/include/snippets/serialize/workchain_serialize.py index c8ce2b81dd..5980207626 100644 --- a/docs/source/topics/processes/include/snippets/serialize/workchain_serialize.py +++ b/docs/source/topics/processes/include/snippets/serialize/workchain_serialize.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- from aiida.engine import WorkChain -from aiida.orm.nodes.data import to_aiida_type -# The basic types need to be loaded such that they are registered with -# the 'to_aiida_type' function. -from aiida.orm.nodes.data.base import * +from aiida.orm import to_aiida_type class SerializeWorkChain(WorkChain): diff --git a/docs/source/topics/processes/usage.rst b/docs/source/topics/processes/usage.rst index a883be92f1..7ab5bfb043 100644 --- a/docs/source/topics/processes/usage.rst +++ b/docs/source/topics/processes/usage.rst @@ -201,12 +201,14 @@ This function, passed as ``serializer`` parameter to ``spec.input``, is invoked For inputs which are stored in the database (``non_db=False``), the serialization function should return an AiiDA data type. For ``non_db`` inputs, the function must be idempotent because it might be applied more than once. -The following example work chain takes three inputs ``a``, ``b``, ``c``, and simply returns the given inputs. The :func:`aiida.orm.nodes.data.base.to_aiida_type` function is used as serialization function. +The following example work chain takes three inputs ``a``, ``b``, ``c``, and simply returns the given inputs. +The :func:`~aiida.orm.nodes.data.base.to_aiida_type` function is used as serialization function. .. include:: include/snippets/serialize/workchain_serialize.py :code: python -This work chain can now be called with native Python types, which will automatically be converted to AiiDA types by the :func:`aiida.orm.nodes.data.base.to_aiida_type` function. Note that the module which defines the corresponding AiiDA type must be loaded for it to be recognized by :func:`aiida.orm.nodes.data.base.to_aiida_type`. +This work chain can now be called with native Python types, which will automatically be converted to AiiDA types by the :func:`~aiida.orm.nodes.data.base.to_aiida_type` function. +Note that the module which defines the corresponding AiiDA type must be loaded for it to be recognized by :func:`~aiida.orm.nodes.data.base.to_aiida_type`. .. include:: include/snippets/serialize/run_workchain_serialize.py :code: python diff --git a/tests/orm/data/test_to_aiida_type.py b/tests/orm/data/test_to_aiida_type.py index ea60034bc0..dd16d7f2e8 100644 --- a/tests/orm/data/test_to_aiida_type.py +++ b/tests/orm/data/test_to_aiida_type.py @@ -10,7 +10,7 @@ """ This module contains tests for the to_aiida_type serializer """ -from aiida.orm.nodes.data.base import to_aiida_type +from aiida.orm import to_aiida_type from aiida.orm import Dict, Int, Float, Bool, Str from aiida.backends.testbase import AiidaTestCase