Hi folks - is it possible to access the actual DAG...
# ask-the-community
h
Hi folks - is it possible to access the actual DAG contained in a workflow? That is, to see how the nodes are dependent on one another? (Obviously this is known when the DAG is created, but it's somewhat implicit, and we'd like to have an explicit representation to look at for data validation...)
For static workflows, this can be done via the following, but I'm curious if something similar can be done for dynamic workflows
Copy code
def get_node_dependencies(workflow) -> dict[str, list[str]]:
    links = {}
    for node in workflow.nodes:
        links[node.flyte_entity.name] = [n.flyte_entity.name for n in node.upstream_nodes]
    return links
k
Can you help me understand how does this help
h
Fair question @Ketan (kumare3) - basically I have a dynamic workflow which runs some tasks if a user requests them based on an input object
A
. However, some of those tasks have upstream dependencies, which can also be requested independently. If a user requests a task which has upstream dependencies, but they do not explicitly request those dependencies in
A
, we'd like to automatically add them to
A
so that the workflow can complete successfully. While we can manually describe the relationships between these tasks, since they're already part of a workflow which already converts these tasks into a DAG, we were wondering if it was possible to leverage that DAG directly 🤔