Hi everyone, nice to meet you all. I've a doubt: S...
# ask-community
e
Hi everyone, nice to meet you all. I've a doubt: Suppose i have an @op without output, but with an asset materialization.
Copy code
@op(ins={"path": In(str)})
def my_op(conxtext, path):
    metadata = load_file_into_data_lake(path)
    yield AssetMaterialization(
        asset_key=AssetKey(metadata["index"]),
        metadata=metadata
    )
it raises an error:
dagster.core.errors.DagsterStepOutputNotFoundError: Core compute for op "<op_name>" did not return an output for non-optional output "result"
. I imagine that the asset materialization event requires an output, is that true? Nevertheless i found a workaround with:
Copy code
@op(
    ins={"path": "<cloud://cloud_path>"},
    out={"result": Out(Nothing)}  # workround
)
def my_op(conxtext, path):
    ...
Thanks!
a
I forget where, but I recall reading that if an asset is yielded, an output must also be yielded, so that’s a reasonable workaround. Sometimes, I’ll just put a
yield Output(True)
on ops that materialize assets but don’t need to actually return anything; your approach is likely better 🙂
👍 1
o
Alex's answer is correct, but another option is to use
context.log_event(AssetMaterialization(...))
instead of yielding the event.
💯 1
e
Thanks you all! I'll switch to Owen's approach, definitely cleaner.