From 0d0b217175e7ec53dd35c4db24b0444b40730344 Mon Sep 17 00:00:00 2001 From: Scott Jungling Date: Mon, 22 Apr 2024 14:11:09 -0700 Subject: [PATCH] feat: update to latest visualization colors --- .gitignore | 3 +- .../cobol_relationships.ipynb | 466 +++---- .../dependency_vulnerabilities.ipynb | 1137 ++++++++++++++++- .../spring_component_relationships.ipynb | 372 +++--- pyproject.toml | 2 +- 5 files changed, 1551 insertions(+), 429 deletions(-) diff --git a/.gitignore b/.gitignore index a86edbf..210dfbf 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ build/ .DS_Store .mypy_cache/ -.python/ \ No newline at end of file +.python/ +.venv/ \ No newline at end of file diff --git a/moderne_visualizations_misc/cobol_relationships.ipynb b/moderne_visualizations_misc/cobol_relationships.ipynb index 649c837..541d53f 100644 --- a/moderne_visualizations_misc/cobol_relationships.ipynb +++ b/moderne_visualizations_misc/cobol_relationships.ipynb @@ -1,237 +1,237 @@ { - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "id": "fe0ea925", - "metadata": { - "collapsed": false, - "tags": [ - "parameters" - ] - }, - "outputs": [], - "source": [ - "node_shape: str = \"ellipse\"\n", - "filter_resources_related_to: str = \"\"\n", - "exclude_incoming_relationships: str = \"false\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1934da7b", - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "import graphviz\n", - "import re\n", - "from code_data_science import data_table as dt\n", - "import code_data_science.palette as palette\n", - "import html\n", - "\n", - "df = dt.read_csv(\"../samples/cobol_relationships.csv\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "def9e15f-7027-4ca6-88c0-84e67ca9417b", - "metadata": { - "ExecuteTime": { - "end_time": "2023-08-04T16:02:27.603653Z", - "start_time": "2023-08-04T16:02:26.607939Z" + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "fe0ea925", + "metadata": { + "collapsed": false, + "tags": [ + "parameters" + ] + }, + "outputs": [], + "source": [ + "node_shape: str = \"ellipse\"\n", + "filter_resources_related_to: str = \"\"\n", + "exclude_incoming_relationships: str = \"false\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1934da7b", + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import graphviz\n", + "import re\n", + "from code_data_science import data_table as dt\n", + "import code_data_science.palette as palette\n", + "import html\n", + "\n", + "df = dt.read_csv(\"../samples/cobol_relationships.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "def9e15f-7027-4ca6-88c0-84e67ca9417b", + "metadata": { + "ExecuteTime": { + "end_time": "2023-08-04T16:02:27.603653Z", + "start_time": "2023-08-04T16:02:26.607939Z" + } + }, + "outputs": [], + "source": [ + "graphviz.set_jupyter_format(\"svg\")\n", + "dot = graphviz.Digraph(\n", + " \"cobol-relationships\", comment=\"COBOL relationships\", engine=\"sfdp\"\n", + ")\n", + "\n", + "# clean dependent field remove all content up to first slash\n", + "df[\"dependent\"] = df[\"dependent\"].apply(lambda x: re.sub(r\"^.*\\/\", \"\", x))\n", + "\n", + "\n", + "def apply_filter(node, node_map, seen):\n", + " if node in seen or node not in node_map:\n", + " return\n", + "\n", + " seen.add(node)\n", + " to = node_map[node]\n", + " for type in to:\n", + " for next in node_map[node][type]:\n", + " apply_filter(next, node_map, seen)\n", + "\n", + "\n", + "if filter_resources_related_to:\n", + " node_map = {}\n", + " for i, z in enumerate(\n", + " zip(\n", + " df[\"dependent\"], df[\"dependentType\"], df[\"dependency\"], df[\"dependencyType\"]\n", + " )\n", + " ):\n", + " dependent = str(z[0])\n", + " dependentType = str(z[1])\n", + " dependency = str(z[2])\n", + " dependencyType = str(z[3])\n", + "\n", + " if not bool(node_map):\n", + " node_map = {}\n", + "\n", + " if dependent not in node_map:\n", + " node_map[dependent] = {}\n", + "\n", + " if dependentType not in node_map[dependent]:\n", + " node_map[dependent][dependentType] = {}\n", + "\n", + " if dependency not in node_map[dependent][dependentType]:\n", + " node_map[dependent][dependentType][dependency] = {}\n", + "\n", + " if dependencyType not in node_map[dependent][dependentType][dependency]:\n", + " node_map[dependent][dependentType][dependency][dependencyType] = {i}\n", + "\n", + " seen = set()\n", + " apply_filter(filter_resources_related_to, node_map, seen)\n", + "\n", + " df = df[\n", + " (df[\"dependent\"].isin(seen))\n", + " if exclude_incoming_relationships == \"true\"\n", + " else (df[\"dependent\"].isin(seen))\n", + " | (df[\"dependency\"].str.contains(filter_resources_related_to))\n", + " ]\n", + " dot.graph_attr[\"beautify\"] = \"true\"\n", + "\n", + "\n", + "def style_node(is_missing, dependency_type):\n", + " if is_missing == \"true\":\n", + " return palette.__moderne_color_map[\"red\"][200]\n", + " if dependency_type == \"COBOL\":\n", + " return palette.__moderne_color_map[\"blue\"][400]\n", + " if dependency_type == \"COPYBOOK\":\n", + " return palette.__moderne_color_map[\"blue\"][200]\n", + " if dependency_type == \"LINKEDIT\":\n", + " return palette.__moderne_color_map[\"yellow\"][200]\n", + " if dependency_type == \"BINDPACKAGE\":\n", + " return palette.__moderne_color_map[\"green\"][200]\n", + " if dependency_type == \"BINDPLAN\":\n", + " return palette.__moderne_color_map[\"green\"][400]\n", + " if dependency_type == \"SQL_TABLE\":\n", + " return palette.__moderne_color_map[\"indigo\"][100]\n", + " if dependency_type == \"SQL_CURSOR\":\n", + " return palette.__moderne_color_map[\"indigo\"][300]\n", + " return \"white\"\n", + "\n", + "\n", + "def add_annotation(value, docType):\n", + " return f\"<{html.escape(value)}
({html.escape(docType)})>\"\n", + "\n", + "\n", + "def map_relationship(row):\n", + " if is_node(row):\n", + " dot.node(\n", + " make_node(row[\"dependent\"], row[\"dependentType\"]),\n", + " shape=\"Mdiamond\"\n", + " if filter_resources_related_to == row[\"dependent\"]\n", + " else node_shape,\n", + " label=add_annotation(row[\"dependent\"], row[\"dependentType\"]),\n", + " style=\"filled\",\n", + " fillcolor=style_node(row[\"dependencyMissing\"], row[\"dependentType\"]),\n", + " )\n", + " dot.node(\n", + " make_node(row[\"dependency\"], row[\"dependencyType\"]),\n", + " shape=\"Mdiamond\"\n", + " if filter_resources_related_to == row[\"dependency\"]\n", + " else node_shape,\n", + " label=add_annotation(row[\"dependency\"], row[\"dependencyType\"]),\n", + " style=\"filled\",\n", + " fillcolor=style_node(row[\"dependencyMissing\"], row[\"dependencyType\"]),\n", + " )\n", + " dot.edge(\n", + " make_node(row[\"dependent\"], row[\"dependentType\"]),\n", + " make_node(row[\"dependency\"], row[\"dependencyType\"]),\n", + " label=make_label(\n", + " row[\"action\"], row[\"actionMetadata\"] if \"actionMetadata\" in df else None\n", + " ),\n", + " )\n", + "\n", + "\n", + "# Prevent multiple redundant relationships from being created when multiple COBOL sources access the same copybook\n", + "copy_chain_pairs = {}\n", + "\n", + "\n", + "def is_node(row):\n", + " if (\n", + " isinstance(row[\"dependent\"], str)\n", + " and isinstance(row[\"dependentType\"], str)\n", + " and row[\"dependentType\"] == \"COPYBOOK\"\n", + " and isinstance(row[\"dependency\"], str)\n", + " and isinstance(row[\"dependencyType\"], str)\n", + " and row[\"dependencyType\"] == \"COPYBOOK\"\n", + " ):\n", + " dependent = row[\"dependent\"]\n", + " dependency = row[\"dependency\"]\n", + " if dependent not in copy_chain_pairs:\n", + " copy_chain_pairs[dependent] = {}\n", + " copy_chain_pairs[dependent][dependency] = dependency\n", + " return True\n", + " elif dependency not in copy_chain_pairs[dependent]:\n", + " copy_chain_pairs[dependent][dependency] = dependency\n", + " return True\n", + " else:\n", + " return True\n", + "\n", + "\n", + "def make_node(resource, type):\n", + " if isinstance(resource, str) and isinstance(type, str):\n", + " return resource + \" \" + type\n", + " else:\n", + " return resource\n", + "\n", + "\n", + "def make_label(action, action_metadata):\n", + " if isinstance(action_metadata, str):\n", + " return action + \" \" + f\"({action_metadata})\"\n", + " else:\n", + " return action\n", + "\n", + "\n", + "df.apply(map_relationship, axis=1)\n", + "\n", + "dot.graph_attr = {\n", + " \"overlap\": \"prism\",\n", + " \"normalize\": \"true\",\n", + " \"overlap_scaling\": \"30\",\n", + " \"size\": \"1250,auto\",\n", + " \"nodesep\": \"1\",\n", + "}\n", + "\n", + "dot" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" } - }, - "outputs": [], - "source": [ - "graphviz.set_jupyter_format(\"svg\")\n", - "dot = graphviz.Digraph(\n", - " \"cobol-relationships\", comment=\"COBOL relationships\", engine=\"sfdp\"\n", - ")\n", - "\n", - "# clean dependent field remove all content up to first slash\n", - "df[\"dependent\"] = df[\"dependent\"].apply(lambda x: re.sub(r\"^.*\\/\", \"\", x))\n", - "\n", - "\n", - "def apply_filter(node, node_map, seen):\n", - " if node in seen or node not in node_map:\n", - " return\n", - "\n", - " seen.add(node)\n", - " to = node_map[node]\n", - " for type in to:\n", - " for next in node_map[node][type]:\n", - " apply_filter(next, node_map, seen)\n", - "\n", - "\n", - "if filter_resources_related_to:\n", - " node_map = {}\n", - " for i, z in enumerate(\n", - " zip(\n", - " df[\"dependent\"], df[\"dependentType\"], df[\"dependency\"], df[\"dependencyType\"]\n", - " )\n", - " ):\n", - " dependent = str(z[0])\n", - " dependentType = str(z[1])\n", - " dependency = str(z[2])\n", - " dependencyType = str(z[3])\n", - "\n", - " if not bool(node_map):\n", - " node_map = {}\n", - "\n", - " if dependent not in node_map:\n", - " node_map[dependent] = {}\n", - "\n", - " if dependentType not in node_map[dependent]:\n", - " node_map[dependent][dependentType] = {}\n", - "\n", - " if dependency not in node_map[dependent][dependentType]:\n", - " node_map[dependent][dependentType][dependency] = {}\n", - "\n", - " if dependencyType not in node_map[dependent][dependentType][dependency]:\n", - " node_map[dependent][dependentType][dependency][dependencyType] = {i}\n", - "\n", - " seen = set()\n", - " apply_filter(filter_resources_related_to, node_map, seen)\n", - "\n", - " df = df[\n", - " (df[\"dependent\"].isin(seen))\n", - " if exclude_incoming_relationships == \"true\"\n", - " else (df[\"dependent\"].isin(seen))\n", - " | (df[\"dependency\"].str.contains(filter_resources_related_to))\n", - " ]\n", - " dot.graph_attr[\"beautify\"] = \"true\"\n", - "\n", - "\n", - "def style_node(is_missing, dependency_type):\n", - " if is_missing == \"true\":\n", - " return palette.__moderneColorMap[\"red\"][200]\n", - " if dependency_type == \"COBOL\":\n", - " return palette.__moderneColorMap[\"blue\"][400]\n", - " if dependency_type == \"COPYBOOK\":\n", - " return palette.__moderneColorMap[\"blue\"][200]\n", - " if dependency_type == \"LINKEDIT\":\n", - " return palette.__moderneColorMap[\"yellow\"][200]\n", - " if dependency_type == \"BINDPACKAGE\":\n", - " return palette.__moderneColorMap[\"green\"][200]\n", - " if dependency_type == \"BINDPLAN\":\n", - " return palette.__moderneColorMap[\"green\"][400]\n", - " if dependency_type == \"SQL_TABLE\":\n", - " return palette.__moderneColorMap[\"indigo\"][100]\n", - " if dependency_type == \"SQL_CURSOR\":\n", - " return palette.__moderneColorMap[\"indigo\"][300]\n", - " return \"white\"\n", - "\n", - "\n", - "def add_annotation(value, docType):\n", - " return f\"<{html.escape(value)}
({html.escape(docType)})>\"\n", - "\n", - "\n", - "def map_relationship(row):\n", - " if is_node(row):\n", - " dot.node(\n", - " make_node(row[\"dependent\"], row[\"dependentType\"]),\n", - " shape=\"Mdiamond\"\n", - " if filter_resources_related_to == row[\"dependent\"]\n", - " else node_shape,\n", - " label=add_annotation(row[\"dependent\"], row[\"dependentType\"]),\n", - " style=\"filled\",\n", - " fillcolor=style_node(row[\"dependencyMissing\"], row[\"dependentType\"]),\n", - " )\n", - " dot.node(\n", - " make_node(row[\"dependency\"], row[\"dependencyType\"]),\n", - " shape=\"Mdiamond\"\n", - " if filter_resources_related_to == row[\"dependency\"]\n", - " else node_shape,\n", - " label=add_annotation(row[\"dependency\"], row[\"dependencyType\"]),\n", - " style=\"filled\",\n", - " fillcolor=style_node(row[\"dependencyMissing\"], row[\"dependencyType\"]),\n", - " )\n", - " dot.edge(\n", - " make_node(row[\"dependent\"], row[\"dependentType\"]),\n", - " make_node(row[\"dependency\"], row[\"dependencyType\"]),\n", - " label=make_label(\n", - " row[\"action\"], row[\"actionMetadata\"] if \"actionMetadata\" in df else None\n", - " ),\n", - " )\n", - "\n", - "\n", - "# Prevent multiple redundant relationships from being created when multiple COBOL sources access the same copybook\n", - "copy_chain_pairs = {}\n", - "\n", - "\n", - "def is_node(row):\n", - " if (\n", - " isinstance(row[\"dependent\"], str)\n", - " and isinstance(row[\"dependentType\"], str)\n", - " and row[\"dependentType\"] == \"COPYBOOK\"\n", - " and isinstance(row[\"dependency\"], str)\n", - " and isinstance(row[\"dependencyType\"], str)\n", - " and row[\"dependencyType\"] == \"COPYBOOK\"\n", - " ):\n", - " dependent = row[\"dependent\"]\n", - " dependency = row[\"dependency\"]\n", - " if dependent not in copy_chain_pairs:\n", - " copy_chain_pairs[dependent] = {}\n", - " copy_chain_pairs[dependent][dependency] = dependency\n", - " return True\n", - " elif dependency not in copy_chain_pairs[dependent]:\n", - " copy_chain_pairs[dependent][dependency] = dependency\n", - " return True\n", - " else:\n", - " return True\n", - "\n", - "\n", - "def make_node(resource, type):\n", - " if isinstance(resource, str) and isinstance(type, str):\n", - " return resource + \" \" + type\n", - " else:\n", - " return resource\n", - "\n", - "\n", - "def make_label(action, action_metadata):\n", - " if isinstance(action_metadata, str):\n", - " return action + \" \" + f\"({action_metadata})\"\n", - " else:\n", - " return action\n", - "\n", - "\n", - "df.apply(map_relationship, axis=1)\n", - "\n", - "dot.graph_attr = {\n", - " \"overlap\": \"prism\",\n", - " \"normalize\": \"true\",\n", - " \"overlap_scaling\": \"30\",\n", - " \"size\": \"1250,auto\",\n", - " \"nodesep\": \"1\",\n", - "}\n", - "\n", - "dot" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 5 + "nbformat": 4, + "nbformat_minor": 5 } diff --git a/moderne_visualizations_misc/dependency_vulnerabilities.ipynb b/moderne_visualizations_misc/dependency_vulnerabilities.ipynb index 95da77b..a2582ab 100644 --- a/moderne_visualizations_misc/dependency_vulnerabilities.ipynb +++ b/moderne_visualizations_misc/dependency_vulnerabilities.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "tags": [ "parameters" @@ -15,9 +15,1130 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "alignmentgroup": "True", + "customdata": [ + [ + 21.8, + 52.9, + 25.1, + 0.3 + ], + [ + 27, + 55.7, + 15.2, + 2 + ], + [ + 21.8, + 27.3, + 49.1, + 1.8 + ], + [ + 37.3, + 31.4, + 11.8, + 19.6 + ] + ], + "hovertemplate": "%{hovertext}

Severity=Critical
Type of version required to fix vulnerability=%{x}
value=%{y}
Critical %=%{customdata[0]}
High %=%{customdata[1]}
Moderate %=%{customdata[2]}
Low %=%{customdata[3]}", + "hovertext": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "legendgroup": "Critical", + "marker": { + "color": "#FF5B5B", + "pattern": { + "shape": "" + } + }, + "name": "Critical", + "offsetgroup": "Critical", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "width": 0.33, + "x": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "xaxis": "x", + "y": [ + 79, + 66, + 12, + 19 + ], + "yaxis": "y" + }, + { + "alignmentgroup": "True", + "customdata": [ + [ + 21.8, + 52.9, + 25.1, + 0.3 + ], + [ + 27, + 55.7, + 15.2, + 2 + ], + [ + 21.8, + 27.3, + 49.1, + 1.8 + ], + [ + 37.3, + 31.4, + 11.8, + 19.6 + ] + ], + "hovertemplate": "%{hovertext}

Severity=High
Type of version required to fix vulnerability=%{x}
value=%{y}
Critical %=%{customdata[0]}
High %=%{customdata[1]}
Moderate %=%{customdata[2]}
Low %=%{customdata[3]}", + "hovertext": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "legendgroup": "High", + "marker": { + "color": "#FABA49", + "pattern": { + "shape": "" + } + }, + "name": "High", + "offsetgroup": "High", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "width": 0.33, + "x": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "xaxis": "x", + "y": [ + 192, + 136, + 15, + 16 + ], + "yaxis": "y" + }, + { + "alignmentgroup": "True", + "customdata": [ + [ + 21.8, + 52.9, + 25.1, + 0.3 + ], + [ + 27, + 55.7, + 15.2, + 2 + ], + [ + 21.8, + 27.3, + 49.1, + 1.8 + ], + [ + 37.3, + 31.4, + 11.8, + 19.6 + ] + ], + "hovertemplate": "%{hovertext}

Severity=Moderate
Type of version required to fix vulnerability=%{x}
value=%{y}
Critical %=%{customdata[0]}
High %=%{customdata[1]}
Moderate %=%{customdata[2]}
Low %=%{customdata[3]}", + "hovertext": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "legendgroup": "Moderate", + "marker": { + "color": "#FEE968", + "pattern": { + "shape": "" + } + }, + "name": "Moderate", + "offsetgroup": "Moderate", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "width": 0.33, + "x": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "xaxis": "x", + "y": [ + 91, + 37, + 27, + 6 + ], + "yaxis": "y" + }, + { + "alignmentgroup": "True", + "customdata": [ + [ + 21.8, + 52.9, + 25.1, + 0.3 + ], + [ + 27, + 55.7, + 15.2, + 2 + ], + [ + 21.8, + 27.3, + 49.1, + 1.8 + ], + [ + 37.3, + 31.4, + 11.8, + 19.6 + ] + ], + "hovertemplate": "%{hovertext}

Severity=Low
Type of version required to fix vulnerability=%{x}
value=%{y}
Critical %=%{customdata[0]}
High %=%{customdata[1]}
Moderate %=%{customdata[2]}
Low %=%{customdata[3]}", + "hovertext": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "legendgroup": "Low", + "marker": { + "color": "#52BBA0", + "pattern": { + "shape": "" + } + }, + "name": "Low", + "offsetgroup": "Low", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "width": 0.33, + "x": [ + "Patch", + "Minor", + "Major", + "No fixed version" + ], + "xaxis": "x", + "y": [ + 1, + 5, + 1, + 10 + ], + "yaxis": "y" + } + ], + "layout": { + "barmode": "stack", + "legend": { + "title": { + "text": "Severity" + }, + "tracegroupgap": 0 + }, + "margin": { + "b": 0, + "l": 0, + "r": 0, + "t": 30 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Type of version required to fix vulnerability" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Vulnerability count" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import pandas as pd\n", "import warnings\n", @@ -66,10 +1187,10 @@ " x=\"Type of version required to fix vulnerability\",\n", " y=[\"Critical\", \"High\", \"Moderate\", \"Low\"],\n", " color_discrete_map={\n", - " \"Low\": palette.__moderneColorMap[\"green\"][\"main\"],\n", - " \"Moderate\": palette.__moderneColorMap[\"indigo\"][\"main\"],\n", - " \"High\": palette.__moderneColorMap[\"blue\"][\"main\"],\n", - " \"Critical\": palette.__moderneColorMap[\"red\"][\"main\"],\n", + " \"Low\": \"#52BBA0\", \n", + " \"Moderate\": \"#FEE968\", \n", + " \"High\": \"#FABA49\",\n", + " \"Critical\": \"#FF5B5B\"\n", " },\n", " barmode=\"stack\",\n", " hover_name=\"Type of version required to fix vulnerability\",\n", @@ -223,7 +1344,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/moderne_visualizations_misc/spring_component_relationships.ipynb b/moderne_visualizations_misc/spring_component_relationships.ipynb index c92b661..b6f747a 100644 --- a/moderne_visualizations_misc/spring_component_relationships.ipynb +++ b/moderne_visualizations_misc/spring_component_relationships.ipynb @@ -1,189 +1,189 @@ { - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [ - "parameters" - ] - }, - "outputs": [], - "source": [ - "node_shape: str = \"box\"\n", - "filter_to_relevant: str = \"\"" - ] + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [ + "parameters" + ] + }, + "outputs": [], + "source": [ + "node_shape: str = \"box\"\n", + "filter_to_relevant: str = \"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import graphviz\n", + "from code_data_science import data_table as dt\n", + "import code_data_science.palette as palette\n", + "import html\n", + "\n", + "df = dt.read_csv(\"../samples/spring_component_relationships.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import networkx as nx\n", + "\n", + "relevant_nodes = set()\n", + "ancestor_nodes = set()\n", + "descendant_nodes = set()\n", + "\n", + "if filter_to_relevant:\n", + " G = nx.from_pandas_edgelist(\n", + " df, \"dependantType\", \"dependencyType\", create_using=nx.DiGraph()\n", + " )\n", + "\n", + " for node in G.nodes:\n", + " if filter_to_relevant in node:\n", + " relevant_nodes.add(node) # Include the node itself\n", + " # Add all descendants and ancestors of the node\n", + " descendant_nodes.update(nx.descendants(G, node))\n", + " ancestor_nodes.update(nx.ancestors(G, node))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Continue with your Graphviz setup\n", + "graphviz.set_jupyter_format(\"svg\")\n", + "dot = graphviz.Digraph(\"spring-relationships\", comment=\"Spring component relationships\")\n", + "\n", + "dot.graph_attr = {\n", + " \"overlap\": \"true\",\n", + " \"normalize\": \"true\",\n", + " \"overlap_shrink\": \"true\",\n", + " \"overlap_scaling\": \"60\",\n", + " \"nodesep\": \"1\",\n", + "}\n", + "\n", + "added_nodes = set()\n", + "added_edges = set()\n", + "\n", + "\n", + "def map_relationship(row):\n", + " \"\"\"\n", + " For a row determine which node and relationship should be added to the graph\n", + " If a relevant filter has been applied then we only want to graph nodes that\n", + " are descendants or ancestors of the relevant nodes\n", + " \"\"\"\n", + " # Check if dependantType node already added\n", + " if row[\"dependantType\"] not in added_nodes:\n", + " if filter_to_relevant != \"\":\n", + " if row[\"dependantType\"] in relevant_nodes:\n", + " dot.node(\n", + " row[\"dependantType\"],\n", + " shape=node_shape,\n", + " style=\"filled\",\n", + " fillcolor=palette.__moderne_color_map[\"red\"][200],\n", + " )\n", + " added_nodes.add(row[\"dependantType\"])\n", + " if row[\"dependantType\"] in ancestor_nodes:\n", + " dot.node(\n", + " row[\"dependantType\"],\n", + " shape=node_shape,\n", + " style=\"filled\",\n", + " fillcolor=palette.__moderne_color_map[\"blue\"][200],\n", + " )\n", + " added_nodes.add(row[\"dependantType\"])\n", + " else:\n", + " dot.node(\n", + " row[\"dependantType\"],\n", + " shape=node_shape,\n", + " style=\"filled\",\n", + " fillcolor=palette.__moderne_color_map[\"blue\"][200],\n", + " )\n", + " added_nodes.add(row[\"dependantType\"])\n", + "\n", + " # Check if dependencyType node already added\n", + " if row[\"dependencyType\"] not in added_nodes:\n", + " if filter_to_relevant != \"\":\n", + " if row[\"dependencyType\"] in relevant_nodes:\n", + " dot.node(\n", + " row[\"dependencyType\"],\n", + " shape=node_shape,\n", + " style=\"filled\",\n", + " fillcolor=palette.__moderne_color_map[\"red\"][200],\n", + " )\n", + " added_nodes.add(row[\"dependantType\"])\n", + " if row[\"dependencyType\"] in descendant_nodes:\n", + " dot.node(\n", + " row[\"dependencyType\"],\n", + " shape=node_shape,\n", + " style=\"filled\",\n", + " fillcolor=palette.__moderne_color_map[\"blue\"][200],\n", + " )\n", + " added_nodes.add(row[\"dependencyType\"])\n", + " else:\n", + " dot.node(\n", + " row[\"dependencyType\"],\n", + " shape=node_shape,\n", + " style=\"filled\",\n", + " fillcolor=palette.__moderne_color_map[\"blue\"][200],\n", + " )\n", + " added_nodes.add(row[\"dependencyType\"])\n", + "\n", + " # Add edge\n", + " if (row[\"dependantType\"], row[\"dependencyType\"]) not in added_edges:\n", + " if filter_to_relevant != \"\":\n", + " if row[\"dependantType\"] in descendant_nodes:\n", + " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", + " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", + " if row[\"dependencyType\"] in ancestor_nodes:\n", + " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", + " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", + " if row[\"dependantType\"] in relevant_nodes:\n", + " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", + " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", + " if row[\"dependencyType\"] in relevant_nodes:\n", + " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", + " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", + " else:\n", + " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", + " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", + "\n", + "\n", + "# Apply mapping to each row\n", + "df.apply(map_relationship, axis=1)\n", + "\n", + "# Display the graph\n", + "dot" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + } }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import graphviz\n", - "from code_data_science import data_table as dt\n", - "import code_data_science.palette as palette\n", - "import html\n", - "\n", - "df = dt.read_csv(\"../samples/spring_component_relationships.csv\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import networkx as nx\n", - "\n", - "relevant_nodes = set()\n", - "ancestor_nodes = set()\n", - "descendant_nodes = set()\n", - "\n", - "if filter_to_relevant:\n", - " G = nx.from_pandas_edgelist(\n", - " df, \"dependantType\", \"dependencyType\", create_using=nx.DiGraph()\n", - " )\n", - "\n", - " for node in G.nodes:\n", - " if filter_to_relevant in node:\n", - " relevant_nodes.add(node) # Include the node itself\n", - " # Add all descendants and ancestors of the node\n", - " descendant_nodes.update(nx.descendants(G, node))\n", - " ancestor_nodes.update(nx.ancestors(G, node))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Continue with your Graphviz setup\n", - "graphviz.set_jupyter_format(\"svg\")\n", - "dot = graphviz.Digraph(\"spring-relationships\", comment=\"Spring component relationships\")\n", - "\n", - "dot.graph_attr = {\n", - " \"overlap\": \"true\",\n", - " \"normalize\": \"true\",\n", - " \"overlap_shrink\": \"true\",\n", - " \"overlap_scaling\": \"60\",\n", - " \"nodesep\": \"1\",\n", - "}\n", - "\n", - "added_nodes = set()\n", - "added_edges = set()\n", - "\n", - "\n", - "def map_relationship(row):\n", - " \"\"\"\n", - " For a row determine which node and relationship should be added to the graph\n", - " If a relevant filter has been applied then we only want to graph nodes that\n", - " are descendants or ancestors of the relevant nodes\n", - " \"\"\"\n", - " # Check if dependantType node already added\n", - " if row[\"dependantType\"] not in added_nodes:\n", - " if filter_to_relevant != \"\":\n", - " if row[\"dependantType\"] in relevant_nodes:\n", - " dot.node(\n", - " row[\"dependantType\"],\n", - " shape=node_shape,\n", - " style=\"filled\",\n", - " fillcolor=palette.__moderneColorMap[\"red\"][200],\n", - " )\n", - " added_nodes.add(row[\"dependantType\"])\n", - " if row[\"dependantType\"] in ancestor_nodes:\n", - " dot.node(\n", - " row[\"dependantType\"],\n", - " shape=node_shape,\n", - " style=\"filled\",\n", - " fillcolor=palette.__moderneColorMap[\"blue\"][200],\n", - " )\n", - " added_nodes.add(row[\"dependantType\"])\n", - " else:\n", - " dot.node(\n", - " row[\"dependantType\"],\n", - " shape=node_shape,\n", - " style=\"filled\",\n", - " fillcolor=palette.__moderneColorMap[\"blue\"][200],\n", - " )\n", - " added_nodes.add(row[\"dependantType\"])\n", - "\n", - " # Check if dependencyType node already added\n", - " if row[\"dependencyType\"] not in added_nodes:\n", - " if filter_to_relevant != \"\":\n", - " if row[\"dependencyType\"] in relevant_nodes:\n", - " dot.node(\n", - " row[\"dependencyType\"],\n", - " shape=node_shape,\n", - " style=\"filled\",\n", - " fillcolor=palette.__moderneColorMap[\"red\"][200],\n", - " )\n", - " added_nodes.add(row[\"dependantType\"])\n", - " if row[\"dependencyType\"] in descendant_nodes:\n", - " dot.node(\n", - " row[\"dependencyType\"],\n", - " shape=node_shape,\n", - " style=\"filled\",\n", - " fillcolor=palette.__moderneColorMap[\"blue\"][200],\n", - " )\n", - " added_nodes.add(row[\"dependencyType\"])\n", - " else:\n", - " dot.node(\n", - " row[\"dependencyType\"],\n", - " shape=node_shape,\n", - " style=\"filled\",\n", - " fillcolor=palette.__moderneColorMap[\"blue\"][200],\n", - " )\n", - " added_nodes.add(row[\"dependencyType\"])\n", - "\n", - " # Add edge\n", - " if (row[\"dependantType\"], row[\"dependencyType\"]) not in added_edges:\n", - " if filter_to_relevant != \"\":\n", - " if row[\"dependantType\"] in descendant_nodes:\n", - " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", - " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", - " if row[\"dependencyType\"] in ancestor_nodes:\n", - " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", - " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", - " if row[\"dependantType\"] in relevant_nodes:\n", - " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", - " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", - " if row[\"dependencyType\"] in relevant_nodes:\n", - " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", - " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", - " else:\n", - " dot.edge(row[\"dependantType\"], row[\"dependencyType\"])\n", - " added_edges.add((row[\"dependantType\"], row[\"dependencyType\"]))\n", - "\n", - "\n", - "# Apply mapping to each row\n", - "df.apply(map_relationship, axis=1)\n", - "\n", - "# Display the graph\n", - "dot" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 + "nbformat": 4, + "nbformat_minor": 2 } diff --git a/pyproject.toml b/pyproject.toml index a9d61d3..ea47ce4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ authors = [ ] license = { text = "Apache-2.0" } dependencies = [ - "code-data-science==1.2.1", + "code-data-science==2.0.0", "graphviz==0.20.1", "ipython==8.13.0", "matplotlib==3.7.1",