-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add explicit_mode to compute contexts
- Loading branch information
Showing
7 changed files
with
156 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
python_modules/dagster/dagster_tests/execution_tests/test_require_typed_event_stream.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from contextlib import contextmanager | ||
from typing import Iterator | ||
|
||
import pytest | ||
from dagster import OpExecutionContext, Out, asset, multi_asset, op | ||
from dagster._core.definitions.asset_spec import AssetSpec | ||
from dagster._core.definitions.events import Output | ||
from dagster._core.definitions.materialize import materialize | ||
from dagster._core.errors import DagsterInvariantViolationError | ||
from dagster._utils.test import wrap_op_in_graph_and_execute | ||
|
||
EXTRA_ERROR_MESSAGE = "Hello" | ||
|
||
|
||
@contextmanager | ||
def raises_missing_output_error() -> Iterator[None]: | ||
with pytest.raises( | ||
DagsterInvariantViolationError, | ||
match=f"did not yield or return expected outputs.*{EXTRA_ERROR_MESSAGE}$", | ||
): | ||
yield | ||
|
||
|
||
def test_explicit_mode_op(): | ||
@op(out={"a": Out(int), "b": Out(int)}) | ||
def explicit_mode_op(context: OpExecutionContext): | ||
context.set_require_typed_event_stream(error_message=EXTRA_ERROR_MESSAGE) | ||
|
||
with raises_missing_output_error(): | ||
wrap_op_in_graph_and_execute(explicit_mode_op) | ||
|
||
|
||
def test_explicit_mode_asset(): | ||
@asset | ||
def explicit_mode_asset(context: OpExecutionContext): | ||
context.set_require_typed_event_stream(error_message=EXTRA_ERROR_MESSAGE) | ||
pass | ||
|
||
with raises_missing_output_error(): | ||
materialize([explicit_mode_asset]) | ||
|
||
|
||
def test_explicit_mode_multi_asset(): | ||
@multi_asset(specs=[AssetSpec("foo"), AssetSpec("bar")]) | ||
def explicit_mode_multi_asset(context: OpExecutionContext): | ||
context.set_require_typed_event_stream(error_message=EXTRA_ERROR_MESSAGE) | ||
yield Output(None, output_name="foo") | ||
pass | ||
|
||
with raises_missing_output_error(): | ||
materialize([explicit_mode_multi_asset]) |