Deividas Jodogalvis
07/05/2023, 2:59 PMValue "None" returned for non-required output "result" of op "filepaths". This value will be passed to downstream ops. For conditional execution, results must be yielded: <https://docs.dagster.io/concepts/ops-jobs-graphs/graphs#with-conditional-branching>
nothing stops there and downstream assets try to materialize 😞
Then
If I try to just yield
nothing I get
dagster._core.errors.DagsterInvariantViolationError: Compute function for op "filepaths" yielded a value of type <class 'NoneType'> rather than an instance of Output, AssetMaterialization, or ExpectationResult. Values yielded by ops must be wrapped in one of these types. If your op has a single output and yields no other events, you may want to use `return` instead of `yield` in the body of your op compute function. If you are already using `return`, and you expected to return a value of type <class 'NoneType'>, you may be inadvertently returning a generator rather than the value
Then
If I try to yield Output(None)
Asset gets materialized and downstream tries to materialize toojamie
07/05/2023, 4:08 PMOutput
but when the asset shouldn’t do anything, the function doesn’t do anything (ie an implicit return None
)
In this example
@asset(output_required=False)
def may_not_materialize():
# to simulate an asset that may not always materialize.
if random.randint(1, 10) < 5:
yield Output([1, 2, 3, 4])
@asset
def downstream(may_not_materialize):
# will not run when may_not_materialize doesn't materialize the asset
return may_not_materialize + [5]
notice how when the random int is >= 5 the function doesn’t do anything https://docs.dagster.io/concepts/assets/software-defined-assets#conditional-materializationDeividas Jodogalvis
07/07/2023, 9:03 AM@asset(output_required=False)
def may_not_materialize():
variable = 123
and this does not work, not sure why
If I add for example this, it works, no matter yield code part is unreachable
@asset(output_required=False)
def may_not_materialize():
variable = 123
if 0==1:
yield Output(value=9)