publish_dag()
Publish a causal diagram (DAG) to Framework Cloud.
::
g = nx.DiGraph()
g.add_node("education", role="exposure")
g.add_node("health", role="outcome")
g.add_edges_from([("income", "education"), ("income", "health"),
("education", "health")])
fw.publish_dag(g, slug="education-health", code=CODE,
analysis={"adjustment_sets": [["income"]]})
Usage
publish_dag(
graph: Any,
*,
labels: Mapping[Any, Any] | None = None,
code: str | None = None,
analysis: Mapping[str, Any] | None = None,
pos: Mapping[Any, Any] | None = None,
y: str | None = None,
slug: str | None = None,
title: str | None = None,
description: str | None = None,
visibility: str | None = None,
password: str | None = None,
collection: str | int | None = None,
share_unlisted: bool = False,
to: str | None = None,
include_private: bool = False,
display: Mapping[str, bool] | None = None,
) -> str | list[str]
Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| graph required | Any |
A |
|
| labels | Mapping[Any, Any] | None | None |
Display labels by node name. They win over |
| code | str | None | None |
The Python code that built the graph, shown with it. |
| analysis | Mapping[str, Any] | None | None |
What the producer computed: |
| pos | Mapping[Any, Any] | None | None |
Positions by node, such as |
| y | str | None | None |
Which way y points in a graph's positions: |
| slug | str | None | None |
Artifact slug. Default: from |
| title | str | None | None |
Artifact title. Default: the slug. |
| description | str | None | None |
Artifact description. |
| visibility | str | None | None |
"public", "unlisted", or "private". Default: a new artifact is unlisted and an existing one keeps its setting. |
| password | str | None | None |
Password required to view the DAG. |
| collection | str | int | None | None |
Project collection ID or slug. |
| share_unlisted | bool | False |
Allow collection readers to see an unlisted DAG. |
| to | str | None | None |
A configured destination name, or "cloud". |
| include_private | bool | False |
Publish without asking about private folders. |
| display | Mapping[str, bool] | None | None |
What embeds of the DAG show, on Framework Cloud. A DAG embeds as its drawing alone: |
Value
The artifact's URL. On Framework Cloud it is a Published string with
embed_link, the link to share and embed, and artifact_url, the artifact's
page for its owner.
Details
fw.publish_dag("dag { smoking [exposure] cancer [outcome] smoking -> cancer }", slug="smoking")
A networkx.DiGraph becomes DAGitty text as dagitty() writes it: roles,
positions, and labels come from node attributes, and bidirected=True on an edge
makes it <->. Positions are read as nx.draw(G, pos) reads them, with y
pointing up, so the drawing on Framework Cloud matches. A string is DAGitty text,
sent as it is, with DAGitty's y pointing down; a Path names a .dagitty file.
publish(graph) publishes a networkx graph too, without code or analysis.
Framework Cloud checks the graph, lays it out, and draws it, with the DAGitty text
and the code to copy. A graph with a cycle, an undirected edge, more than 100 nodes,
or more than 400 edges is refused. Framework computes no adjustment sets or
implications. Pass what another tool found in analysis.