Skip to content

Commit

Permalink
Document bare check result in op behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dpeng817 committed Jan 6, 2025
1 parent 5514eba commit 62f6c59
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 62f6c59

Please sign in to comment.