diff --git a/aiida/orm/utils/builders/code.py b/aiida/orm/utils/builders/code.py index e94db906ae..0026146ded 100644 --- a/aiida/orm/utils/builders/code.py +++ b/aiida/orm/utils/builders/code.py @@ -11,7 +11,6 @@ import enum import pathlib -from aiida.cmdline.utils.decorators import with_dbenv from aiida.common.utils import ErrorAccumulator from aiida.common.warnings import warn_deprecation from aiida.orm import InstalledCode, PortableCode @@ -41,9 +40,13 @@ def validate(self, raise_error=True): self._err_acc.run(self.validate_installed) return self._err_acc.result(raise_error=self.CodeValidationError if raise_error else False) - @with_dbenv() def new(self): """Build and return a new code instance (not stored)""" + from aiida.manage import get_manager + + # Load the profile backend if not already the case. + get_manager().get_profile_storage() + self.validate() # Will be used at the end to check if all keys are known (those that are not None) diff --git a/aiida/orm/utils/builders/computer.py b/aiida/orm/utils/builders/computer.py index 3f9e9da6de..4918425498 100644 --- a/aiida/orm/utils/builders/computer.py +++ b/aiida/orm/utils/builders/computer.py @@ -8,7 +8,6 @@ # For further information please visit http://www.aiida.net # ########################################################################### """Manage computer objects with lazy loading of the db env""" -from aiida.cmdline.utils.decorators import with_dbenv from aiida.common.exceptions import ValidationError from aiida.common.utils import ErrorAccumulator @@ -62,11 +61,13 @@ def validate(self, raise_error=True): """Validate the computer options.""" return self._err_acc.result(raise_error=self.ComputerValidationError if raise_error else False) - @with_dbenv() def new(self): """Build and return a new computer instance (not stored)""" + from aiida.manage import get_manager from aiida.orm import Computer + # Load the profile backend if not already the case. + get_manager().get_profile_storage() self.validate() # Will be used at the end to check if all keys are known