Exemplo n.º 1
0
def test_experimental_decorator_class():
    @experimental
    class ExperimentalClass:
        def __init__(self, salutation="hello"):
            self.salutation = salutation

        def hello(self, name):
            return f"{self.salutation} {name}"

    @experimental
    class ExperimentalClassWithExperimentalFunction(ExperimentalClass):
        def __init__(self, sendoff="goodbye", **kwargs):
            self.sendoff = sendoff
            super().__init__(**kwargs)

        @experimental
        def goodbye(self, name):
            return f"{self.sendoff} {name}"

    with pytest.warns(
            ExperimentalWarning,
            match=
            '"ExperimentalClass" is an experimental class. It may break in future versions, even between dot releases.',
    ):
        experimental_class = ExperimentalClass(salutation="howdy")

    with assert_no_warnings():
        assert experimental_class.hello("dagster") == "howdy dagster"

    with pytest.warns(
            ExperimentalWarning,
            match=
            '"ExperimentalClassWithExperimentalFunction" is an experimental class. It may break in future versions, even between dot releases.',
    ):
        experimental_class_with_experimental_function = ExperimentalClassWithExperimentalFunction(
        )

    with assert_no_warnings():
        assert experimental_class_with_experimental_function.hello(
            "dagster") == "hello dagster"

    with pytest.warns(
            ExperimentalWarning,
            match=
            '"goodbye" is an experimental function. It may break in future versions, even between dot releases.',
    ):
        assert experimental_class_with_experimental_function.goodbye(
            "dagster") == "goodbye dagster"

    @experimental
    class ExperimentalNamedTupleClass(NamedTuple("_", [("salutation", str)])):
        pass

    with pytest.warns(
            ExperimentalWarning,
            match=
            '"ExperimentalNamedTupleClass" is an experimental class. It may break in future versions, even between dot releases.',
    ):
        assert ExperimentalNamedTupleClass(
            salutation="howdy").salutation == "howdy"
Exemplo n.º 2
0
def test_experimental_decorator():
    with assert_no_warnings():

        @experimental
        def my_experimental_function(some_arg):
            assert some_arg == 5
            return 4

    assert my_experimental_function.__name__ == "my_experimental_function"

    with pytest.warns(
        ExperimentalWarning,
        match='"my_experimental_function" is an experimental function. It may break in future'
        " versions, even between dot releases. " + EXPERIMENTAL_WARNING_HELP,
    ) as warning:
        assert my_experimental_function(5) == 4

    assert warning[0].filename.endswith("test_backcompat.py")
def test_intermediate_storage_deprecation_warning():
    @solid
    def return_one(_):
        return 1

    @pipeline
    def foo():
        return_one()

    with assert_no_warnings():
        execute_pipeline(foo)

    with pytest.warns(
        UserWarning,
        match=re.escape(
            "Intermediate Storages are deprecated in 0.10.0 and will be removed in 0.11.0."
        ),
    ):
        execute_pipeline(foo, run_config={"intermediate_storage": {"filesystem": {}}})