diff --git a/src/aiida/orm/nodes/data/code/installed.py b/src/aiida/orm/nodes/data/code/installed.py index 6454c8b0ce..5f9fb39749 100644 --- a/src/aiida/orm/nodes/data/code/installed.py +++ b/src/aiida/orm/nodes/data/code/installed.py @@ -37,6 +37,7 @@ class InstalledCode(Code): """Data plugin representing an executable code on a remote computer.""" + _EMIT_CODE_DEPRECATION_WARNING: bool = False _KEY_ATTRIBUTE_FILEPATH_EXECUTABLE: str = 'filepath_executable' class Model(AbstractCode.Model): diff --git a/src/aiida/orm/nodes/data/code/legacy.py b/src/aiida/orm/nodes/data/code/legacy.py index 30f04b8264..5f62b1cf97 100644 --- a/src/aiida/orm/nodes/data/code/legacy.py +++ b/src/aiida/orm/nodes/data/code/legacy.py @@ -75,13 +75,17 @@ class Code(AbstractCode): def __init__(self, remote_computer_exec=None, local_executable=None, input_plugin_name=None, files=None, **kwargs): super().__init__(**kwargs) - warn_deprecation( - 'The `Code` class is deprecated. To create an instance, use the ' - '`aiida.orm.nodes.data.code.installed.InstalledCode` or `aiida.orm.nodes.data.code.portable.PortableCode` ' - 'for a "remote" or "local" code, respectively. If you are using this class to compare type, e.g. in ' - '`isinstance`, use `aiida.orm.nodes.data.code.abstract.AbstractCode`.', - version=3, - ) + # The ``_EMIT_CODE_DEPRECATION_WARNING`` attribute is set in subclasses to avoid the deprecation message below + # is also shown when they are instantiated, since they are not deprecated. + if getattr(self, '_EMIT_CODE_DEPRECATION_WARNING', True): + warn_deprecation( + 'The `Code` class is deprecated. To create an instance, use the ' + '`aiida.orm.nodes.data.code.installed.InstalledCode` or ' + '`aiida.orm.nodes.data.code.portable.PortableCode` for a "remote" or "local" code, respectively. If ' + 'you are using this class to compare type, e.g. in ' + '`isinstance`, use `aiida.orm.nodes.data.code.abstract.AbstractCode`.', + version=3, + ) if remote_computer_exec and local_executable: raise ValueError('cannot set `remote_computer_exec` and `local_executable` at the same time') diff --git a/src/aiida/orm/nodes/data/code/portable.py b/src/aiida/orm/nodes/data/code/portable.py index 48b927c9ca..a09ccb90a4 100644 --- a/src/aiida/orm/nodes/data/code/portable.py +++ b/src/aiida/orm/nodes/data/code/portable.py @@ -39,6 +39,7 @@ class PortableCode(Code): """Data plugin representing an executable code stored in AiiDA's storage.""" + _EMIT_CODE_DEPRECATION_WARNING: bool = False _KEY_ATTRIBUTE_FILEPATH_EXECUTABLE: str = 'filepath_executable' class Model(AbstractCode.Model):