https://dagster.io/ logo
#ask-community
Title
# ask-community
я

Яхья Сакалов

02/13/2023, 12:31 PM
Hi, Is there way to stop materializing assets without getting error dagster._core.errors.DagsterTypeCheckDidNotPass. For example, I do requests into DB, if there rows I want to pass them to next assets, if not then just stop without error. Also i don`t want check incoming data in asset. Is there way to validate incoming data, if it not valid just not run asset?
o

owen

02/13/2023, 6:14 PM
hi @Яхья Сакалов! In this case, I think you'd want to mark your asset with
output_required=False
, then only yield an Output if rows exist. Something like
Copy code
@asset(output_required=False)
def my_asset():
    rows = ...
    if len(rows) > 0:
        yield Output(rows)
я

Яхья Сакалов

02/13/2023, 6:19 PM
thanks for answer, yes, I already found this argument for
asset
but this method works only if your function is decodator, but it will be good if there will be same behaviour for classical function
is there way to write middleware to implement into application lifecycle single logic for all assets?
o

owen

02/13/2023, 10:52 PM
I might not be following that question 100%, but one pattern some users have found success with is writing their own custom wrapper for the asset decorator. So you can define some custom behavior inside your own
my_custom_asset
decorator, then annotate your assets with
Copy code
@my_custom_asset
def some_asset():
    ...
👍 1
2 Views