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

fix: handle deserialization of TaskResult #108

Merged
merged 1 commit into from
Aug 9, 2024
Merged

Conversation

mikeshultz
Copy link
Member

What I did

Handles deserialization of TaskResult.

fixes: #107

How I did it

ScalarDatapoint may be in dict form.

How to verify it

>>> from silverback.types import Datapoints
>>> from taskiq import TaskiqResult
>>> from silverback.recorder import TaskResult
>>> from silverback_cluster_common.types import InstancedTaskResult
>>> result = TaskResult.from_taskiq(TaskiqResult(is_err=False, log=None, return_value={'foo': 123, 'value': 0.01}, execution_time=0.39, labels={}, error=None))
>>> TaskResult.model_validate(result.model_dump())
TaskResult(task_name='handle_transfer', execution_time=0.39, error=None, completed=datetime.datetime(2024, 8, 9, 3, 26, 39, 738962, tzinfo=TzInfo(UTC)), block_number=6464337, metrics=Datapoints(root={'foo': ScalarDatapoint(type='scalar', data=123), 'value': ScalarDatapoint(type='scalar', data=0.01)}))
>>> 

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@mikeshultz mikeshultz self-assigned this Aug 9, 2024
@mikeshultz mikeshultz merged commit 282c7ec into main Aug 9, 2024
22 checks passed
@mikeshultz mikeshultz deleted the fix/taskresult-serde branch August 9, 2024 17:33
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.

bug: TaskResult validation error
2 participants