Skip to content

Commit

Permalink
Document bare check result in op behavior (#26726)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Test behavior when a bare asset check result is yielded inside an op
(both invocation and execution).

Similar test cases exist elsewhere; but I think it's useful to have one
specifically targeted at the op decorator.
  • Loading branch information
dpeng817 authored Jan 6, 2025
1 parent 4e280b4 commit 9d6c964
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import partial
from typing import Any, Dict, Generator, List, Tuple

import dagster as dg
import pytest
from dagster import (
AssetMaterialization,
Expand Down Expand Up @@ -1673,3 +1674,26 @@ def bar(x, y=2):
):
bar_2 = partial(bar, x=1)
bar_2(1)


def test_bare_asset_check_result() -> None:
"""Document behavior when a bare asset check result is yielded from an op."""

@dg.op
def the_op():
return dg.AssetCheckResult(
asset_key="asset_key",
check_name="my_check",
metadata={"foo": "bar"},
passed=True,
)

# test direct invocation - direction invocation allows this through erroneously.
result = the_op()
assert isinstance(result, dg.AssetCheckResult)

# test execution - we correctly raise an error here
with pytest.raises(
dg.DagsterInvariantViolationError, match="Received unexpected AssetCheckResult."
):
execute_op_in_graph(the_op)

0 comments on commit 9d6c964

Please sign in to comment.