Changeset View
Changeset View
Standalone View
Standalone View
python_modules/libraries/dagstermill/dagstermill_tests/test_solids.py
import os | import os | ||||
import pickle | import pickle | ||||
import tempfile | import tempfile | ||||
from contextlib import contextmanager | from contextlib import contextmanager | ||||
import nbformat | import nbformat | ||||
import pytest | import pytest | ||||
from dagster import execute_pipeline, pipeline | from dagster import execute_pipeline, pipeline | ||||
from dagster.check import CheckError | from dagster.check import CheckError | ||||
from dagster.core.definitions.event_metadata import PathMetadataEntryData | from dagster.core.definitions.event_metadata import PathMetadataEntryData | ||||
from dagster.core.definitions.reconstructable import ReconstructablePipeline | from dagster.core.definitions.reconstructable import ReconstructablePipeline | ||||
from dagster.core.test_utils import instance_for_test | from dagster.core.test_utils import instance_for_test | ||||
from dagster.utils import file_relative_path, safe_tempfile_path | from dagster.utils import file_relative_path, safe_tempfile_path | ||||
from dagstermill import DagstermillError, define_dagstermill_solid | from dagstermill import DagstermillError, define_dagstermill_solid | ||||
from jupyter_client.kernelspec import NoSuchKernel | from jupyter_client.kernelspec import NoSuchKernel | ||||
from nbclient.exceptions import CellExecutionError | |||||
from nbconvert.preprocessors import ExecutePreprocessor | from nbconvert.preprocessors import ExecutePreprocessor | ||||
from papermill import PapermillExecutionError | from papermill import PapermillExecutionError | ||||
try: | try: | ||||
import dagster_pandas as _ | import dagster_pandas as _ | ||||
DAGSTER_PANDAS_PRESENT = True | DAGSTER_PANDAS_PRESENT = True | ||||
except ImportError: | except ImportError: | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | def test_notebook_dag(): | ||||
) as result: | ) as result: | ||||
assert result.success | assert result.success | ||||
assert result.result_for_solid("add_two_numbers").output_value() == 3 | assert result.result_for_solid("add_two_numbers").output_value() == 3 | ||||
assert result.result_for_solid("mult_two_numbers").output_value() == 6 | assert result.result_for_solid("mult_two_numbers").output_value() == 6 | ||||
@pytest.mark.notebook_test | @pytest.mark.notebook_test | ||||
def test_error_notebook(): | def test_error_notebook(): | ||||
with pytest.raises(PapermillExecutionError) as exc: | with pytest.raises((PapermillExecutionError, CellExecutionError)) as exc: | ||||
with exec_for_test("error_pipeline") as result: | with exec_for_test("error_pipeline") as result: | ||||
pass | pass | ||||
assert "Someone set up us the bomb" in str(exc.value) | assert "Someone set up us the bomb" in str(exc.value) | ||||
with exec_for_test("error_pipeline", raise_on_error=False) as result: | with exec_for_test("error_pipeline", raise_on_error=False) as result: | ||||
assert not result.success | assert not result.success | ||||
assert result.step_event_list[1].event_type.value == "ASSET_MATERIALIZATION" | assert result.step_event_list[1].event_type.value == "ASSET_MATERIALIZATION" | ||||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |