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

ORM: Cache the logger adapter for ProcessNode #6492

Merged
Merged
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
11 changes: 10 additions & 1 deletion src/aiida/orm/nodes/process/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,16 @@ def logger(self):
"""
from aiida.orm.utils.log import create_logger_adapter

return create_logger_adapter(self._logger, self)
# If the node is not yet stored, there is no point in creating the logger adapter yet, as the ``DbLogHandler``
# it configures, is only triggered for stored nodes, otherwise it cannot link the log message to the node.
if not self.pk:
return self._logger

# First time the property is called after the node is stored, create the logger adapter
if not hasattr(self, '_logger_adapter'):
self._logger_adapter = create_logger_adapter(self._logger, self)

return self._logger_adapter

@classmethod
def recursive_merge(cls, left: dict[Any, Any], right: dict[Any, Any]) -> None:
Expand Down