https://dagster.io/ logo
#ask-ai
Title
# ask-ai
t

TruffleOil

03/08/2024, 2:59 PM
What is the difference between using
ins
and
deps
in the asset decorator?
s

Scout

03/08/2024, 2:59 PM
In the context of Dagster's asset decorator,
ins
and
deps
serve different purposes for defining dependencies between assets. - `ins`: This parameter is used to define input dependencies for an asset. When you specify
ins
, you are indicating that the asset takes data from another asset as an input. This creates a direct data dependency where the output of one asset is used as the input for another. The
ins
parameter expects a dictionary where the keys are the names of the input parameters of the asset function and the values are instances of
AssetIn
, which can specify the key of the upstream asset. - `deps`: This parameter is used to define dependencies that do not correspond to a direct data input to the asset. It allows you to specify upstream assets that the current asset depends on, without those assets passing data directly into it. This can be useful for cases where the execution of an asset should be triggered by the materialization of another asset, but no data is passed between them. The
deps
parameter is a more recent addition to the asset decorator and is meant to replace the now-deprecated
non_argument_deps
parameter, which served a similar purpose. The
deps
parameter accepts a list of assets, which allows for better type checking and error detection during development. Here's an example from the documentation illustrating the use of `deps`:
Copy code
python
@asset(deps=[iris_dataset])
def iris_setosa(duckdb: DuckDBResource) -> None:
    with duckdb.get_connection() as conn:
        conn.execute(
            "CREATE TABLE iris.iris_setosa AS"
            " SELECT * FROM iris.iris_dataset"
            " WHERE species = 'Iris-setosa'"
        )
In this example,
iris_setosa
is an asset that depends on the
iris_dataset
asset. The
deps
parameter is used to declare this dependency, even though
iris_setosa
does not take
iris_dataset
as a direct input. It's important to note that the
deps
parameter is part of Dagster's ongoing efforts to improve the asset model, and it is recommended to use
deps
over
non_argument_deps
for defining non-data dependencies between assets. add
deps
parameter to @graph_asset and... button Assets vs Ops button The future of I/O managers: an opt-in la... button Different concepts to define an asset button Thank you for your feedback!
t

TruffleOil

03/08/2024, 3:17 PM
@Scout Where does
AssetDep
come into play?
s

Scout

03/08/2024, 3:17 PM
AssetDep
is not a term that is directly referenced in the documentation provided. It's possible that
AssetDep
could be a term used in a different context or in earlier versions of Dagster, or it might be a misunderstanding or typo related to
AssetIn
or
deps
. In the context of defining dependencies between assets in Dagster, you would use
AssetIn
to specify the key of an upstream asset when defining input dependencies using the
ins
parameter, and you would use
deps
to specify dependencies that do not correspond to direct data inputs. If you are looking for information on how to define dependencies between assets, you should use the
ins
parameter with
AssetIn
for input dependencies and the
deps
parameter for non-data dependencies, as described in the previous messages. If
AssetDep
is something specific to your codebase or a plugin you are using, or if it's a term from an older version of Dagster that has since been updated, I would recommend checking the relevant code or documentation for that specific context. If you have more information or a different context where
AssetDep
is used, please provide additional details, and I'll do my best to assist you further.
70 Views