Differential D8684 Diff 40955 examples/docs_snippets/docs_snippets/concepts/modes_resources/modes_resources.py
Changeset View
Changeset View
Standalone View
Standalone View
examples/docs_snippets/docs_snippets/concepts/modes_resources/modes_resources.py
"""isort:skip_file""" | """isort:skip_file""" | ||||
# pylint: disable=unused-argument | # pylint: disable=unused-argument | ||||
from dagster import ModeDefinition, ResourceDefinition, execute_pipeline, pipeline, resource, solid | from dagster import ( | ||||
ModeDefinition, | |||||
ResourceDefinition, | |||||
execute_pipeline, | |||||
pipeline, | |||||
resource, | |||||
solid, | |||||
) | |||||
# start_resource_example | # start_resource_example | ||||
class ExternalCerealFetcher: | class ExternalCerealFetcher: | ||||
def fetch_new_cereals(self, start_ts, end_ts): | def fetch_new_cereals(self, start_ts, end_ts): | ||||
pass | pass | ||||
Show All 36 Lines | |||||
from dagster import build_init_resource_context | from dagster import build_init_resource_context | ||||
def test_my_resource_with_context(): | def test_my_resource_with_context(): | ||||
init_context = build_init_resource_context( | init_context = build_init_resource_context( | ||||
resources={"foo": "foo_str"}, config={"bar": "bar_str"} | resources={"foo": "foo_str"}, config={"bar": "bar_str"} | ||||
) | ) | ||||
assert my_resource_requires_context(init_context) == ("foo_str", "bar_str") | assert my_resource_requires_context(init_context) == ( | ||||
"foo_str", | |||||
"bar_str", | |||||
) | |||||
# end_resource_testing_with_context | # end_resource_testing_with_context | ||||
# start_cm_resource_testing | # start_cm_resource_testing | ||||
from contextlib import contextmanager | from contextlib import contextmanager | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |