Skip to content

Add get_task_tracebacks method to expose stored tracebacks for Tasks#482

Open
dotsdl wants to merge 2 commits intomainfrom
feature/347-get-task-tracebacks
Open

Add get_task_tracebacks method to expose stored tracebacks for Tasks#482
dotsdl wants to merge 2 commits intomainfrom
feature/347-get-task-tracebacks

Conversation

@dotsdl
Copy link
Member

@dotsdl dotsdl commented Jan 19, 2026

Summary

Addresses #347 - Expose ability to get stored tracebacks associated with a given Task.

This PR adds a new method get_task_tracebacks() at all layers of the alchemiscale stack:

  • Statestore: Neo4jStore.get_task_tracebacks(task: ScopedKey) - queries Neo4j for Tracebacks nodes associated with failed ProtocolDAGResultRefs for the given Task
  • API: GET /tasks/{task_scoped_key}/tracebacks - new endpoint that returns traceback data
  • Client: AlchemiscaleClient.get_task_tracebacks(task: ScopedKey) - convenient client method for users

Return Format

Returns a list of dictionaries, one per failed ProtocolDAGResultRef associated with the Task. Each dictionary maps ProtocolUnitFailure GufeKey strings to their corresponding traceback strings:

[
    {
        "ProtocolUnitFailure-ABC123": "Traceback (most recent call last):\n  ...",
        "ProtocolUnitFailure-DEF456": "Traceback (most recent call last):\n  ..."
    },
    # ... more entries if task has multiple failed results
]

Results are ordered by ProtocolDAGResultRef.datetime_created in descending order (newest first).

Example Usage

>>> tracebacks = client.get_task_tracebacks(task_sk)
>>> for tb_dict in tracebacks:
...     for failure_key, traceback_str in tb_dict.items():
...         print(f"Failure {failure_key}: {traceback_str[:100]}...")

Test plan

  • Unit tests for statestore method (test_get_task_tracebacks, test_get_task_tracebacks_no_failures, test_get_task_tracebacks_multiple_failures)
  • Integration tests for client method (test_get_task_tracebacks, test_get_task_tracebacks_no_failures)
  • CI tests pass

🤖 Generated with Claude Code

dotsdl and others added 2 commits January 19, 2026 16:25
…347)

Adds the ability to retrieve traceback information from failed Tasks:

- Add `Neo4jStore.get_task_tracebacks()` method to statestore
- Add `/tasks/{task_scoped_key}/tracebacks` API endpoint
- Add `AlchemiscaleClient.get_task_tracebacks()` client method
- Add integration tests for all layers

The method returns a list of dictionaries, one per failed ProtocolDAGResultRef,
mapping ProtocolUnitFailure GufeKey to traceback string.

Closes #347

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `str` type annotation to task_scoped_key parameter in API endpoint
- Clarify in docstrings that empty list is returned for non-existent tasks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dotsdl dotsdl linked an issue Jan 20, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose ability to get stored tracebacks associated with a given Task

1 participant