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

BC A

06/01/2023, 7:22 PM
Hello everyone, I'm trying to create dynamically generated assets using dynamic upstream names, the problem is that I can't set a key prefix and a key using assetIn, I'm getting the following error : _key and key_prefix cannot both be set on AssetIn._
from dagster import AssetIn, dagster
########## empty asset
@asset(key_prefix = "PARENT_KEY_PREFIX", group_name="empty")
def empty(context):
return pd.DataFrame([])
@asset(
name = "asset_name",
key_prefix = "key_prefix",
required_resource_keys = {"custom_io_manager"},
io_manager_key = "custom_io_manager",
group_name = "outputs",
ins = {"upstream": AssetIn(key="empty", key_prefix="PARENT_KEY_PREFIX")}
)
def asset_def(context, upstream) -> None:
print("do stuff w/ asset")
return asset_def
c

claire

06/01/2023, 10:41 PM
Try defining your asset key like this:
Copy code
AssetIn(key=AssetKey(["PARENT_KEY_PREFIX", "empty"]))
b

BC A

06/06/2023, 11:01 AM
Hi @claire, thanks for you reply. I overcame this issue by defining everything in the key but I was just wondering that adding a param w/ key prefix in AssetIn would add some consistency overall the asset definitions module
2 Views