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

Jordan

06/16/2022, 1:13 PM
Hi! When I use
AssetDefinitions.from_graph
with a graph from the
@graph
decorator or directly using the
GraphDefinition
class I don't have the same behaviour. In the first case, I get the job and the asset group in my repo while in the second case my repo is composed only of the job and there is no asset. I used this example for the GraphDefinition: https://docs.dagster.io/concepts/ops-jobs-graphs/graphs#using-yaml-graphdsl
Copy code
build_assets_job(
        "my_job",
        assets=[
            AssetsDefinition.from_graph(
                graph_def = define_dep_dsl_graph(), 
                partitions_def = DailyPartitionsDefinition(start_date="2022-01-01")
            )
        ]
    )
c

claire

06/16/2022, 5:50 PM
Hi Jordan. The reason why this is occurring is that the
GraphDefinition
defined in the example doesn't have a defined output, and a graph must have a defined output in order to be converted to an asset. You can modify the
GraphDefinition
to have the
output_mappings
arg:
Copy code
from dagster import (
    ...
    OutputMapping,
)
from dagster.core.definitions.output import OutputPointer


def construct_graph_with_yaml(yaml_file, op_defs) -> GraphDefinition:
    ...

    return GraphDefinition(
        name=yaml_data["name"],
        description=yaml_data.get("description"),
        node_defs=op_defs,
        dependencies=deps,
        output_mappings=[OutputMapping(OutputDefinition(), OutputPointer("subtract", "result"))],
    )
I've just hardcoded an output based on the yaml file for now
👍 1
j

Jordan

06/16/2022, 6:29 PM
Ah yes indeed, I understand better. Thank you !
2 Views