Differential D4847 Diff 24311 python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_composition.py
Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_composition.py
Show First 20 Lines • Show All 542 Lines • ▼ Show 20 Lines | with pytest.warns(None) as record: | ||||
single_input_solid() | single_input_solid() | ||||
assert len(record) == 0 | assert len(record) == 0 | ||||
def test_alias_invoked(recwarn): | def test_alias_invoked(recwarn): | ||||
@pipeline | @pipeline | ||||
def _(): | def _(): | ||||
return [single_input_solid.alias("foo")(), single_input_solid.alias("bar")()] | _ = [single_input_solid.alias("foo")(), single_input_solid.alias("bar")()] | ||||
schrockn: So this is a potential breaking change in this diff, although mitigations are available. We… | |||||
maxUnsubmitted Not Done Inline Actionsit'd be nice to have a test for the breaking case marked xfail max: it'd be nice to have a test for the breaking case marked `xfail` | |||||
assert len(recwarn) == 0 | assert len(recwarn) == 0 | ||||
def test_alias_not_invoked(): | def test_alias_not_invoked(): | ||||
with pytest.warns( | with pytest.warns( | ||||
UserWarning, | UserWarning, | ||||
match=( | match=( | ||||
r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | ||||
r"'single_input_solid'\.\n'single_input_solid' was aliased as '(foo|bar)'." | r"'single_input_solid'\.\n'single_input_solid' was aliased as '(foo|bar)'." | ||||
), | ), | ||||
) as record: | ) as record: | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
return [single_input_solid.alias("foo"), single_input_solid.alias("bar")] | _ = [single_input_solid.alias("foo"), single_input_solid.alias("bar")] | ||||
assert len(record) == 2 # This pipeline should raise a warning for each aliasing of the solid. | assert len(record) == 2 # This pipeline should raise a warning for each aliasing of the solid. | ||||
def test_tag_invoked(): | def test_tag_invoked(): | ||||
with pytest.warns(None) as record: | with pytest.warns(None) as record: | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
return single_input_solid.tag({})() | single_input_solid.tag({})() | ||||
execute_pipeline(_my_pipeline) | execute_pipeline(_my_pipeline) | ||||
assert len(record) == 0 | assert len(record) == 0 | ||||
def test_tag_not_invoked(): | def test_tag_not_invoked(): | ||||
with pytest.warns( | with pytest.warns( | ||||
UserWarning, | UserWarning, | ||||
match=( | match=( | ||||
r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | ||||
r"'single_input_solid'\." | r"'single_input_solid'\." | ||||
), | ), | ||||
) as record: | ) as record: | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
return [single_input_solid.tag({}), single_input_solid.tag({})] | _ = single_input_solid.tag({}), single_input_solid.tag({}) | ||||
execute_pipeline(_my_pipeline) | execute_pipeline(_my_pipeline) | ||||
assert len(record) == 1 # We should only raise one warning because solids have same name. | assert len(record) == 1 # We should only raise one warning because solids have same name. | ||||
with pytest.warns( | with pytest.warns( | ||||
UserWarning, | UserWarning, | ||||
match=( | match=( | ||||
r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | ||||
r"'single_input_solid'\.\nProvided tags: {'a': 'b'}\." | r"'single_input_solid'\.\nProvided tags: {'a': 'b'}\." | ||||
), | ), | ||||
): | ): | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
return single_input_solid.tag({"a": "b"}) | single_input_solid.tag({"a": "b"}) | ||||
execute_pipeline(_my_pipeline) | execute_pipeline(_my_pipeline) | ||||
def test_with_hooks_invoked(): | def test_with_hooks_invoked(): | ||||
with pytest.warns(None) as record: | with pytest.warns(None) as record: | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
return single_input_solid.with_hooks(set())() | single_input_solid.with_hooks(set())() | ||||
execute_pipeline(_my_pipeline) | execute_pipeline(_my_pipeline) | ||||
assert len(record) == 0 | assert len(record) == 0 | ||||
@event_list_hook(required_resource_keys=set()) | @event_list_hook(required_resource_keys=set()) | ||||
def a_hook(_context, _): | def a_hook(_context, _): | ||||
return HookExecutionResult("a_hook") | return HookExecutionResult("a_hook") | ||||
def test_with_hooks_not_invoked(): | def test_with_hooks_not_invoked(): | ||||
with pytest.warns( | with pytest.warns( | ||||
UserWarning, | UserWarning, | ||||
match=( | match=( | ||||
r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | ||||
r"'single_input_solid'\." | r"'single_input_solid'\." | ||||
), | ), | ||||
) as record: | ) as record: | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
return [single_input_solid.with_hooks(set()), single_input_solid.with_hooks(set())] | _ = single_input_solid.with_hooks(set()), single_input_solid.with_hooks(set()) | ||||
execute_pipeline(_my_pipeline) | execute_pipeline(_my_pipeline) | ||||
# Note not returning out of the pipe causes warning count to go up to 2 | |||||
assert len(record) == 1 # We should only raise one warning because solids have same name. | assert len(record) == 1 # We should only raise one warning because solids have same name. | ||||
with pytest.warns( | with pytest.warns( | ||||
UserWarning, | UserWarning, | ||||
match=( | match=( | ||||
r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | ||||
r"'single_input_solid'\.\nProvided hook definitions: \['a_hook'\]\." | r"'single_input_solid'\.\nProvided hook definitions: \['a_hook'\]\." | ||||
), | ), | ||||
): | ): | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
return single_input_solid.with_hooks({a_hook}) | single_input_solid.with_hooks({a_hook}) | ||||
execute_pipeline(_my_pipeline) | execute_pipeline(_my_pipeline) | ||||
def test_with_hooks_not_empty(): | def test_with_hooks_not_empty(): | ||||
@pipeline | @pipeline | ||||
def _(): | def _(): | ||||
return [single_input_solid.with_hooks({a_hook})] | single_input_solid.with_hooks({a_hook}) | ||||
assert 1 == 1 | assert 1 == 1 | ||||
def test_multiple_pending_invocations(): | def test_multiple_pending_invocations(): | ||||
with pytest.warns( | with pytest.warns( | ||||
UserWarning, | UserWarning, | ||||
match=( | match=( | ||||
r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | r"While in @pipeline context '_my_pipeline', received an uninvoked solid " | ||||
r"'single_input_solid'\.\n'single_input_solid' was aliased as 'bar'\.\n" | r"'single_input_solid'\.\n'single_input_solid' was aliased as 'bar'\.\n" | ||||
r"Provided hook definitions: \['a_hook'\]\." | r"Provided hook definitions: \['a_hook'\]\." | ||||
), | ), | ||||
) as record: | ) as record: | ||||
@pipeline | @pipeline | ||||
def _my_pipeline(): | def _my_pipeline(): | ||||
foo = single_input_solid.alias("foo") | foo = single_input_solid.alias("foo") | ||||
bar = single_input_solid.alias("bar") | bar = single_input_solid.alias("bar") | ||||
foo_tag = foo.tag({}) | foo_tag = foo.tag({}) | ||||
_bar_hook = bar.with_hooks({a_hook}) | _bar_hook = bar.with_hooks({a_hook}) | ||||
return foo_tag() | foo_tag() | ||||
assert ( | assert ( | ||||
len(record) == 1 | len(record) == 1 | ||||
) # ensure that one warning is thrown per solid_name / alias instead of per every CallableSolidNode. | ) # ensure that one warning is thrown per solid_name / alias instead of per every CallableSolidNode. | ||||
def test_compose_nothing(): | def test_compose_nothing(): | ||||
@lambda_solid(input_defs=[InputDefinition("start", Nothing)]) | @lambda_solid(input_defs=[InputDefinition("start", Nothing)]) | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |
So this is a potential breaking change in this diff, although mitigations are available. We were ignoring returns out of the pipeline definition but in the composite solid case outputs are meaningful so these can trigger errors in the output mapping.