notebooks/process_analysis.ipynb (137 lines of code) (raw):
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": ""
},
"outputs": [],
"source": [
"# Licensed under the Apache License, Version 2.0 (the \"License\"); { display-mode: \"form\" }\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "raw",
"metadata": {
"collapsed": false
},
"source": [
"# Status Transitions graph\n",
"\n",
"Display a directed graph of status transitions of the issues data from an issue tracker.\n",
"\n",
"This graph can give an overview like a value stream map and highlights potential waste like delays and rework.\n",
"\n",
"> **_NOTE:_** Requires [graphviz](https://graphviz.org/download/) to be installed locally.\n",
"\n",
"## How to interpret the graph:\n",
"- Each node represents a status of an issue.\n",
"- The color of the node represents the category of the status (e.g., To Do, In Progress, Done).\n",
"- Each edge represents a transition from one status to another.\n",
"- The number of times that transition has occurred is shown on the edge, and the thickness of the edge is proportional to the number of transitions.\n",
"\n",
"Issue tracker tested: JIRA.\n",
"Other DevLake plugins might not provide the necessary data to generate the graph. An error will be shown if the data is not available."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display\n",
"from datetime import datetime\n",
"import pandas as pd\n",
"\n",
"from playground.db_engine import create_db_engine\n",
"from playground.process_analysis.issue_filter import IssueFilter\n",
"from playground.process_analysis.status_transition_graph import StatusTransitionGraph\n",
"from playground.process_analysis.status_transition_graph_vistualizer import StatusTransitionGraphVisualizer, StatisticLabelConfig\n",
"from playground.process_analysis.utils.status_transition_data_generator import generate_random_status_changes\n",
"\n",
"# Connection to the devlake database\n",
"DB_URL = \"mysql://merico:merico@127.0.0.1:3306/lake\"\n",
"# Specify the filter for the issues to be included in the graph\n",
"ISSUE_FILTER = IssueFilter(\n",
" # Example usage:\n",
" # issue_type = \"Story\",\n",
" # from_date = pd.Timestamp(datetime.strptime(\"2020-01-01\", \"%Y-%m-%d\"))\n",
")\n",
"# For demo purposes, the following flag can be set to true to generate some random data\n",
"USE_DEMO_DATA = False\n",
"\n",
"\n",
"if not StatusTransitionGraphVisualizer.is_dot_executable_available():\n",
" print(\"dot executable not found, please install graphviz\")\n",
"\n",
"if not USE_DEMO_DATA:\n",
" process_graph = StatusTransitionGraph.from_database(create_db_engine(DB_URL), issue_filter=ISSUE_FILTER)\n",
"else:\n",
" data_frame = generate_random_status_changes(5000)\n",
" process_graph = StatusTransitionGraph.from_data_frame(data_frame, issue_filter=ISSUE_FILTER)\n",
"\n",
"svg = StatusTransitionGraphVisualizer().visualize(process_graph, threshold=0.99, label_statistic = StatisticLabelConfig.MEDIAN)\n",
"display(svg)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Statistics box plot\n",
"\n",
"Plot statistics of the duration statistics for the most common edges in the process graph."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from playground.process_analysis.status_transition_graph_stats_plot import StatusTransitionGraphStatsPlot\n",
"\n",
"stats_plot = StatusTransitionGraphStatsPlot().boxplot(process_graph, max_edges=10)\n",
"stats_plot.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}