Skip to content

Commit

Permalink
materialize_in_process -> materialize_to_memory (#8391)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpeng817 authored and clairelin135 committed Jun 14, 2022
1 parent e03eefe commit a60e889
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/sphinx/sections/api/apidocs/execution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Materializing Assets

.. autofunction:: materialize

.. autofunction:: materialize_in_process
.. autofunction:: materialize_to_memory

Executing Jobs
--------------
Expand Down
4 changes: 2 additions & 2 deletions python_modules/dagster/dagster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
load_assets_from_package_module,
load_assets_from_package_name,
materialize,
materialize_in_process,
materialize_to_memory,
multi_asset,
)
from dagster.core.definitions import (
Expand Down Expand Up @@ -578,7 +578,7 @@ def __dir__() -> typing.List[str]:
"load_assets_from_package_module",
"load_assets_from_package_name",
"materialize",
"materialize_in_process",
"materialize_to_memory",
# types
"Any",
"Bool",
Expand Down
2 changes: 1 addition & 1 deletion python_modules/dagster/dagster/core/asset_defs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
load_assets_from_package_module,
load_assets_from_package_name,
)
from .materialize import materialize, materialize_in_process
from .materialize import materialize, materialize_to_memory
from .source_asset import SourceAsset
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def materialize(
).execute_in_process(run_config=run_config, instance=instance)


def materialize_in_process(
def materialize_to_memory(
assets: Sequence[Union[AssetsDefinition, SourceAsset]],
run_config: Any = None,
instance: Optional[DagsterInstance] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
asset,
graph,
io_manager,
materialize_in_process,
materialize_to_memory,
multi_asset,
op,
with_resources,
)


def test_basic_materialize_in_process():
def test_basic_materialize_to_memory():
@asset
def the_asset():
return 5

result = materialize_in_process([the_asset])
result = materialize_to_memory([the_asset])
assert result.success
assert len(result.asset_materializations_for_node("the_asset")[0].metadata_entries) == 0

Expand All @@ -36,7 +36,7 @@ def test_materialize_config():
def the_asset_reqs_config(context):
assert context.op_config["foo_str"] == "foo"

assert materialize_in_process(
assert materialize_to_memory(
[the_asset_reqs_config],
run_config={"ops": {"the_asset_reqs_config": {"config": {"foo_str": "foo"}}}},
).success
Expand All @@ -48,7 +48,7 @@ def the_asset_reqs_config(context):
assert context.op_config["foo_str"] == "foo"

with pytest.raises(DagsterInvalidConfigError, match="Error in config for job"):
materialize_in_process(
materialize_to_memory(
[the_asset_reqs_config],
run_config={"ops": {"the_asset_reqs_config": {"config": {"bad": "foo"}}}},
)
Expand All @@ -59,7 +59,7 @@ def test_materialize_resources():
def the_asset(context):
assert context.resources.foo == "blah"

assert materialize_in_process([the_asset]).success
assert materialize_to_memory([the_asset]).success


def test_materialize_resource_instances():
Expand All @@ -68,7 +68,7 @@ def the_asset(context):
assert context.resources.foo == "blah"
assert context.resources.bar == "baz"

assert materialize_in_process(
assert materialize_to_memory(
[the_asset], resources={"foo": ResourceDefinition.hardcoded_resource("blah"), "bar": "baz"}
).success

Expand All @@ -82,9 +82,9 @@ def the_asset(context):
DagsterInvalidDefinitionError,
match="resource with key 'foo' required by op 'the_asset' was not provided",
):
materialize_in_process([the_asset])
materialize_to_memory([the_asset])

assert materialize_in_process(
assert materialize_to_memory(
with_resources([the_asset], {"foo": ResourceDefinition.hardcoded_resource("blah")})
).success

Expand All @@ -102,13 +102,13 @@ def second():
DagsterInvalidDefinitionError,
match="Conflicting versions of resource with key 'foo' were provided to different assets.",
):
materialize_in_process([first, second])
materialize_to_memory([first, second])

with pytest.raises(
DagsterInvalidDefinitionError,
match="resource with key 'foo' provided to job conflicts with resource provided to assets. When constructing a job, all resource definitions provided must match by reference equality for a given key.",
):
materialize_in_process(
materialize_to_memory(
[first], resources={"foo": ResourceDefinition.hardcoded_resource("2")}
)

Expand All @@ -131,7 +131,7 @@ def the_manager():
def the_asset(the_source):
return the_source + 1

result = materialize_in_process([the_asset, the_source])
result = materialize_to_memory([the_asset, the_source])
assert result.success
assert result.output_for_node("the_asset") == 6

Expand All @@ -155,19 +155,19 @@ def the_asset():
DagsterInvalidDefinitionError,
match="Conflicting versions of resource with key 'foo' were provided to different assets.",
):
materialize_in_process([the_asset, the_source])
materialize_to_memory([the_asset, the_source])

with pytest.raises(
DagsterInvalidDefinitionError,
match="resource with key 'foo' provided to job conflicts with resource provided to assets.",
):
materialize_in_process(
materialize_to_memory(
[the_source], resources={"foo": ResourceDefinition.hardcoded_resource("2")}
)


def test_materialize_no_assets():
assert materialize_in_process([]).success
assert materialize_to_memory([]).success


def test_materialize_graph_backed_asset():
Expand Down Expand Up @@ -199,7 +199,7 @@ def create_cool_thing(a, b):
node_def=create_cool_thing,
)

result = materialize_in_process([cool_thing_asset, a, b])
result = materialize_to_memory([cool_thing_asset, a, b])
assert result.success
assert result.output_for_node("create_cool_thing.combine_strings") == "aaaabb"

Expand Down Expand Up @@ -241,7 +241,7 @@ def multi_asset_with_internal_deps(thing): # pylint: disable=unused-argument
yield Output(1, "my_out_name")
yield Output(2, "my_other_out_name")

result = materialize_in_process([thing_asset, multi_asset_with_internal_deps])
result = materialize_to_memory([thing_asset, multi_asset_with_internal_deps])
assert result.success
assert result.output_for_node("multi_asset_with_internal_deps", "my_out_name") == 1
assert result.output_for_node("multi_asset_with_internal_deps", "my_other_out_name") == 2

0 comments on commit a60e889

Please sign in to comment.