Replies: 2 comments
-
for example, given the following code, @asset()
def square_1(config: IntegTestConfig) -> int:
return config.initial_val**2
@asset()
def square_2(square_1: int) -> int:
return square_1**2
@asset()
def square_3(square_2: int) -> int:
return square_2**2 how can I materialize just square_2 and square_3 while inputting some integer to square_2? |
Beta Was this translation helpful? Give feedback.
-
Hey @takerfume - alas, there isn't a super straightforward way to do this, but one thing that works is to convert it to a graph: from dagster import asset, define_asset_job
from dagster._core.definitions.asset_graph import AssetGraph
@asset()
def square_1() -> int:
return 5
@asset()
def square_2(square_1: int) -> int:
return square_1**2
@asset()
def square_3(square_2: int) -> int:
return square_2**2
if __name__ == "__main__":
define_asset_job("job1", selection=[square_2, square_3]).resolve(
AssetGraph.from_assets([square_1, square_2, square_3])
).graph.execute_in_process(run_config={"ops": {"square_2": {"inputs": {"square_1": 6}}}}) The general thinking is that an asset is defined as pulling its data from some particular upstream asset - i.e. it's inputs are"bound". If you want something that's more like an arbitrarily parameterizable function with unbound inputs, then you'd want to use a graph. |
Beta Was this translation helpful? Give feedback.
-
Hello Dagster, I
have a question about working with multiple assets.
I'm looking for guidance on how to materialize a subset of assets, specifically from the 3rd to the 5th asset, and how to run a job defined by these assets.
My primary focus is on understanding the process for inputting this manually instantiated instance into the 3rd asset (input is a mock of 2nd asset output), especially when considering the materialization of a subset of assets, from the 3rd to the 5th.
And I also know how to run the jobs defined by 3 to 5th assets. Any advice or examples on how to effectively achieve this in Dagster would be highly beneficial.
Beta Was this translation helpful? Give feedback.
All reactions