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

👌 IMPROVE: Add 'exception' to projection mapping #4786

Merged
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion aiida/cmdline/utils/query/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class CalculationQueryBuilder:
_default_projections = ('pk', 'ctime', 'process_label', 'state', 'process_status')
_valid_projections = (
'pk', 'uuid', 'ctime', 'mtime', 'state', 'process_state', 'process_status', 'exit_status', 'sealed',
'process_label', 'label', 'description', 'node_type', 'paused', 'process_type', 'job_state', 'scheduler_state'
'process_label', 'label', 'description', 'node_type', 'paused', 'process_type', 'job_state', 'scheduler_state',
'exception'
)

def __init__(self, mapper=None):
Expand Down
2 changes: 2 additions & 0 deletions aiida/cmdline/utils/query/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, projections, projection_labels=None, projection_attributes=No
process_state_key = f'attributes.{ProcessNode.PROCESS_STATE_KEY}'
process_status_key = f'attributes.{ProcessNode.PROCESS_STATUS_KEY}'
exit_status_key = f'attributes.{ProcessNode.EXIT_STATUS_KEY}'
exception_key = f'attributes.{ProcessNode.EXCEPTION_KEY}'

default_labels = {'pk': 'PK', 'uuid': 'UUID', 'ctime': 'Created', 'mtime': 'Modified', 'state': 'Process State'}

Expand All @@ -104,6 +105,7 @@ def __init__(self, projections, projection_labels=None, projection_attributes=No
'process_state': process_state_key,
'process_status': process_status_key,
'exit_status': exit_status_key,
'exception': exception_key,
}

default_formatters = {
Expand Down
2 changes: 1 addition & 1 deletion aiida/engine/processes/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def on_except(self, exc_info: Tuple[Any, Exception, TracebackType]) -> None:
:param exc_info: the sys.exc_info() object (type, value, traceback)
"""
super().on_except(exc_info)
self.node.set_exception(''.join(traceback.format_exception(exc_info[0], exc_info[1], None)))
self.node.set_exception(''.join(traceback.format_exception(exc_info[0], exc_info[1], None)).rstrip())
self.report(''.join(traceback.format_exception(*exc_info)))

@override
Expand Down
3 changes: 2 additions & 1 deletion aiida/manage/external/rmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""Components to communicate tasks to RabbitMQ."""
from collections.abc import Mapping
import logging
import traceback

from kiwipy import communications, Future
import pamqp.encode
Expand Down Expand Up @@ -154,7 +155,7 @@ def handle_continue_exception(node, exception, message):

if not node.is_excepted and not node.is_sealed:
node.logger.exception(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason thy this goes to the logger rather than to the process report as in the other case?

Could one factor out these two lines into a private node member function that is called in both places?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The report method is on the Process class, not ProcessNode. report then calls the process logger, which in practice should always be the node logger.

But I agree it would be good to streamline more

node.set_exception(str(exception))
node.set_exception(''.join(traceback.format_exception(type(exception), exception, None)).rstrip())
node.set_process_state(ProcessState.EXCEPTED)
node.seal()

Expand Down