datakiln.show_graph module

Shows the dependency graph of the tables and derive scripts.

datakiln.show_graph.is_schema(node) → bool[source]

Whether the node is a script that creates a schema.

Parameters:

node (datakiln.metadata.table.TableMeta | datakiln.metadata.script.ScriptMeta) – Table or script.

Return type:

bool

datakiln.show_graph.label(node) → List[str][source]

Lines to tell a node by: its name, and the file of a script if the name does not tell it.

Parameters:

node (datakiln.metadata.table.TableMeta | datakiln.metadata.script.ScriptMeta) – Table or script.

Return type:

list[str]

datakiln.show_graph.edges(graph: DatabaseGraph, nodes: Iterable) → List[tuple][source]

Pairs of two tables or two scripts where the second one needs the first. There are none between a table and a script.

An arrow is left out if the nodes are also linked through other nodes. If c needs b and b needs a, then c needs a through b, so the pairs are (a, b) and (b, c) but not (a, c).

Parameters:
Return type:

list[tuple]

datakiln.show_graph.select(graph: DatabaseGraph, include: Iterable[str] = None, schemas: bool = False) → List[source]

Nodes to show, ordered by name: the ones that have an arrow, as the others would only be a row of boxes, and the ones asked for.

Parameters:
  • graph (datakiln.metadata.graph.DatabaseGraph) – Dependency graph.

  • include (Iterable[str]) – Names of the nodes to show, with the nodes they need. All by default.

  • schemas (bool) – Whether to show the scripts that create schemas, which every script of the schema needs.

Raises:

ValueError – If any of the names is not a node.

Return type:

list

datakiln.show_graph.mermaid(graph: DatabaseGraph, nodes: List, direction: str = 'LR') → str[source]

Graph as a Mermaid flowchart, which GitLab and GitHub draw in a Markdown file.

Parameters:
Return type:

str

datakiln.show_graph.markdown(graph: DatabaseGraph, nodes: List, direction: str = 'LR') → str[source]

Graph as a Markdown document, which GitLab and GitHub draw when it is opened.

Parameters:
Return type:

str

datakiln.show_graph.html(graph: DatabaseGraph, nodes: List, direction: str = 'LR') → str[source]

Graph as a web page, which any browser draws. The page loads Mermaid from the internet.

Parameters:
Return type:

str

datakiln.show_graph.add_arguments(parser)[source]

Adds the options of the command.

Parameters:

parser (argparse.ArgumentParser) – Parser of the command.

datakiln.show_graph.run(args)[source]

Shows the dependency graph of the tables and scripts.

Parameters:

args (argparse.Namespace) – Arguments of the command.