-
-
Save bollwyvl/49908a428b4fee21bcf591bc86aa81a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ipynb_checkpoints | |
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import ipyelk" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"/bin/bash: gh: command not found\n" | |
] | |
} | |
], | |
"source": [ | |
"with __import__(\"importnb\").Notebook():\n", | |
" from requirements_df import df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>requirement</th>\n", | |
" <th>url</th>\n", | |
" <th>extras</th>\n", | |
" <th>specifier</th>\n", | |
" <th>marker</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>name</th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>jedi</th>\n", | |
" <td>parso</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=0.8.0, <0.9.0)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>nbclient</th>\n", | |
" <td>traitlets</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=4.2)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>nbclient</th>\n", | |
" <td>jupyter-client</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=6.1.5)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>nbclient</th>\n", | |
" <td>nbformat</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=5.0)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>nbclient</th>\n", | |
" <td>async-generator</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>()</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>...</th>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>ipywidgets</th>\n", | |
" <td>nbformat</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=4.2.0)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>ipywidgets</th>\n", | |
" <td>widgetsnbextension</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(~=3.5.0)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>pandas</th>\n", | |
" <td>python-dateutil</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=2.7.3)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>pandas</th>\n", | |
" <td>pytz</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=2017.2)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>pandas</th>\n", | |
" <td>numpy</td>\n", | |
" <td>None</td>\n", | |
" <td>{}</td>\n", | |
" <td>(>=1.15.4)</td>\n", | |
" <td>None</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>104 rows × 5 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" requirement url extras specifier marker\n", | |
"name \n", | |
"jedi parso None {} (>=0.8.0, <0.9.0) None\n", | |
"nbclient traitlets None {} (>=4.2) None\n", | |
"nbclient jupyter-client None {} (>=6.1.5) None\n", | |
"nbclient nbformat None {} (>=5.0) None\n", | |
"nbclient async-generator None {} () None\n", | |
"... ... ... ... ... ...\n", | |
"ipywidgets nbformat None {} (>=4.2.0) None\n", | |
"ipywidgets widgetsnbextension None {} (~=3.5.0) None\n", | |
"pandas python-dateutil None {} (>=2.7.3) None\n", | |
"pandas pytz None {} (>=2017.2) None\n", | |
"pandas numpy None {} (>=1.15.4) None\n", | |
"\n", | |
"[104 rows x 5 columns]" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"({'height': 25,\n", | |
" 'id': 'model',\n", | |
" 'width': 50,\n", | |
" 'labels': [{'text': 'model', 'id': 'model_label', 'x': 5, 'y': 5}]},)" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"\n", | |
" {\n", | |
" \"height\": 25,\n", | |
" \"id\": \"model\",\n", | |
" \"width\": 50,\n", | |
" \"labels\": [{ \"text\": \"model\", \"id\": \"model_label\", \"x\": 5, \"y\": 5 }]\n", | |
" }," | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 75, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def make_node(name):\n", | |
" return dict(\n", | |
" id=name,\n", | |
" width=len(name) * 7,\n", | |
" height=18,\n", | |
" labels=[dict(id=f\"\"\"_l_{name}\"\"\", text=name, x=5, y=5)]\n", | |
" )" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 81, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"nodes = {}\n", | |
"edges = []\n", | |
"for rec in df.reset_index().to_dict(orient=\"records\"):\n", | |
" if rec[\"name\"] not in nodes:\n", | |
" nodes[rec[\"name\"]] = make_node(rec[\"name\"])\n", | |
" if rec[\"requirement\"] not in nodes:\n", | |
" nodes[rec[\"requirement\"]] = make_node(rec[\"requirement\"])\n", | |
" edges += [\n", | |
" dict(\n", | |
" id=f\"_e_{len(edges)}\", \n", | |
" sources=[rec[\"name\"]], \n", | |
" targets=[rec[\"requirement\"]],\n", | |
" labels=[dict(\n", | |
" id=f\"\"\"_e_l_{rec[\"name\"]}_{rec[\"requirement\"]}\"\"\",\n", | |
" text=str(rec[\"specifier\"])\n", | |
" )]\n", | |
" ),\n", | |
" ]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 82, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'name': 'pandas',\n", | |
" 'requirement': 'numpy',\n", | |
" 'url': None,\n", | |
" 'extras': set(),\n", | |
" 'specifier': <SpecifierSet('>=1.15.4')>,\n", | |
" 'marker': None}" | |
] | |
}, | |
"execution_count": 82, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"rec" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 83, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"elk_json = {\n", | |
" \"children\": [*nodes.values()],\n", | |
" \"edges\": edges,\n", | |
" \"id\": \"root\"\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 84, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "02c83e39c830483da52204482cb2fca5", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"text/plain": [ | |
"ElkDiagram(layout=Layout(min_height='600px'), value={'children': [{'id': 'jedi', 'width': 28, 'height': 18, 'l…" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"ipyelk.ElkDiagram(elk_json, layout=dict(min_height=\"600px\"))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"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.9.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: reqs | |
channels: | |
- conda-forge | |
- nodefaults | |
dependencies: | |
- importlib_metadata | |
- importnb | |
- ipyelk | |
- ipywidgets | |
- jupyterlab =1 | |
- nodejs >=14,<15 | |
- nomkl | |
- packaging | |
- pandas | |
- python >=3.8,<3.9 | |
- toolz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jupyrdf/jupyter-elk | |
@jupyter-widgets/jupyterlab-manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eux | |
jupyter labextension install --debug --no-build $(cat labex.txt) | |
jupyter labextension list | |
jupyter lab build --debug --dev-build=False --minimize=False | |
jupyter labextension list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment