Hi there, How can I retrieve results from material...
# ask-community
a
Hi there, How can I retrieve results from materialize for one asset? What is the best way to test assets in Dagster?
Copy code
# %%
from dagster import asset, materialize_to_memory

@asset(
    name='simple',
    key_prefix='prefix'
)
def simple() -> str:
    return "simple"

result = materialize_to_memory(
    [simple]
)

simple_res = result.output_for_node(simple.key)
This code throws an error
Copy code
ParameterCheckError: Param "handle_str" is not a str. Got AssetKey(['prefix', 'simple']) which is type <class 'dagster._core.definitions.events.AssetKey'>.
What is the str key for this asset then? I used not to put a key_prefix and fetch asset results by just calling
Copy code
result.output_for_node('simple')
🤖 1
I've found the final op name is "prefix__simple". That should be included in key_prefix_ docs
s
Thanks Airton, we'd appreciate it if you could file an issue: https://github.com/dagster-io/dagster/issues
a
Sure, I'll do this, thanks!
https://github.com/dagster-io/dagster/issues/11341 here I've discussed about this usage. I'll try to find some time and request a PR to the simpler part