Abhishek Tripathi
02/24/2024, 8:59 AMScout
02/24/2024, 8:59 AMpython @asset def my_asset(upstream_asset): # Logic to compute the asset from the upstream_asset return computed_value
In this example, my_asset
is a software-defined asset that depends on upstream_asset
. The function my_asset
contains the logic to compute the asset's contents. For a graph-based asset, consider the following example: python @op def extract(): # Logic to extract data return data @op def transform(extracted_data): # Logic to transform data return transformed_data @op def load(transformed_data): # Logic to load data return loaded_data @asset @graph def etl(): return load(transform(extract))
In this example, etl
is a graph-based asset that is composed of a graph of operations (extract
, transform
, and load
). The @graph
decorator is used to define a graph of ops, and the @asset
decorator indicates that the result of this graph is a software-defined asset. The asset graph would show the dependencies between these operations and how they contribute to the creation of the etl
asset. The key difference is that while all graph-based assets are software-defined assets, not all software-defined assets are necessarily graph-based. A software-defined asset can be a simple asset defined by a single function, while a graph-based asset is specifically part of an interconnected graph of assets.