Hello, How can I use an asset from “Group A” in “...
# ask-community
l
Hello, How can I use an asset from “Group A” in “Group B”? Context: I organize my assets in groups.
Copy code
assets/
├─ group_a/
│  ├─ __init__.py
│  ├─ ...
├─ group_b/
│  ├─ __init__.py
│  ├─ ...
├─ __init__.py
in assets/__init__.py I do the following (as described in the documentation):
Copy code
load_assets_from_package_module(
    group_a,
    group_name="group_a",
    key_prefix="group_a"
)
load_assets_from_package_module(
    group_b,
    group_name="group_b",
    key_prefix="group_b"
)
t
Hey Lukas! Source assets are a way to import an asset into another Python module. They're used to tell a Python module that an asset exists elsewhere but to not try and compute it. Here are some docs on how to declare Source Assets. Let me know if your situation is more complicated than this and it doesn't work. https://docs.dagster.io/concepts/assets/software-defined-assets#defining-external-asset-dependencies
l
Hi Tim, Thank you for your message. I have tried using the SourceAsset as you described. However, I am having trouble with the Group Name of the Asset. I suppose I am missing a central concept here. Here is the thing that I can’t seem to understand: If I try to use an asset from Group B within Group A (as described in my initial post), I do the following:
Copy code
from dagster import AssetKey, SourceAsset, asset

my_source_asset = SourceAsset(key=AssetKey(["group_b", "some_asset_from_group_b"]))


@asset
def my_derived_asset(some_asset_from_group_b):
    return some_asset_from_group_b + [4]
The following error occurs: “Input asset ‘[“some_asset_from_group_b”]’ for asset ‘[“group_a”, “my_derived_asset”]’ is not produced by any of the provided asset ops and is not one of the provided sources.” So what do I have to pass exactly to my_derived_asset?