Skip to content
Framework

Publishing

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 networkx.DiGraph (or pgmpy DAG), DAGitty text, or a Path to a .dagitty file.

labels Mapping[Any, Any] | None None

Display labels by node name. They win over label node attributes.

code str | None None

The Python code that built the graph, shown with it.

analysis Mapping[str, Any] | None None

What the producer computed: effect ("total" or "direct"), adjustment_sets (a list of lists of names: [[]] when no adjustment is needed, [] when no set works), and implications ({"x", "y", "given"} conditional independencies).

pos Mapping[Any, Any] | None None

Positions by node, such as {"age": (0, 0)} or a networkx layout. For networkx graphs.

y str | None None

Which way y points in a graph's positions: "up", as networkx and matplotlib draw, or "down", as DAGitty reads. Default: "up". DAGitty text is always read with y pointing down.

slug str | None None

Artifact slug. Default: from title, else dag. Name each DAG, or a second one publishes as a new version of the first.

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: description, analysis, dagitty, and code start off, and title, author, credit, and legend start on. Pass {"code": True, "analysis": True} to show the code and analysis. True shows an item and False hides it; settings left out keep their value.

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.

Search guides and reference for R, Python, Stata, the CLI, and Framework Cloud.