Skip to content

Commit

Permalink
update (component-service): documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Oct 5, 2024
1 parent 98451da commit 2bf0ed2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Todos os exemplos no diretório `notebook` são preparados para o ambiente Jupyt
# Acionando os Notebooks via Binder

* Última versão testada e estável:
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/v1.1.7)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/v1.1.8)

* Última versão disponível:
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/master)
Expand Down
88 changes: 49 additions & 39 deletions notebooks/ai/food-prediction.ipynb
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Componente como Serviço\n",
"\n",
"## Passo 2 - Componente a partir do Workflow"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -11,9 +20,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing output for /home/santanche/git/component2learn/notebooks/ai/8e4ff04a-654c-4c8a-a64a-604e6c4caf81.uml to 8e4ff04a-654c-4c8a-a64a-604e6c4caf81.svg\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentStyleType=\"text/css\" height=\"101px\" preserveAspectRatio=\"none\" style=\"width:393px;height:101px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 393 101\" width=\"393px\" zoomAndPan=\"magnify\"><defs/><g><!--class Predictor--><g id=\"elem_Predictor\"><rect codeLine=\"1\" fill=\"#F1F1F1\" height=\"80.5938\" id=\"Predictor\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"372.3633\" x=\"7\" y=\"7\"/><ellipse cx=\"157.3838\" cy=\"23\" fill=\"#B4A7E5\" rx=\"11\" ry=\"11\" style=\"stroke:#181818;stroke-width:1.0;\"/><path d=\"M153.3057,18.7656 L153.3057,16.6094 L160.6963,16.6094 L160.6963,18.7656 L158.2275,18.7656 L158.2275,26.8438 L160.6963,26.8438 L160.6963,29 L153.3057,29 L153.3057,26.8438 L155.7744,26.8438 L155.7744,18.7656 L153.3057,18.7656 Z \" fill=\"#000000\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" font-style=\"italic\" lengthAdjust=\"spacing\" textLength=\"63.0957\" x=\"177.8838\" y=\"27.8467\">Predictor</text><line style=\"stroke:#181818;stroke-width:0.5;\" x1=\"8\" x2=\"378.3633\" y1=\"39\" y2=\"39\"/><line style=\"stroke:#181818;stroke-width:0.5;\" x1=\"8\" x2=\"378.3633\" y1=\"47\" y2=\"47\"/><ellipse cx=\"18\" cy=\"60.6484\" fill=\"#84BE84\" rx=\"3\" ry=\"3\" style=\"stroke:#038048;stroke-width:1.0;\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"183.292\" x=\"27\" y=\"63.9951\">train(csv_file_path: string)</text><ellipse cx=\"18\" cy=\"76.9453\" fill=\"#84BE84\" rx=\"3\" ry=\"3\" style=\"stroke:#038048;stroke-width:1.0;\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"346.3633\" x=\"27\" y=\"80.292\">predict(age: int, gender: int, ethnicity: int): string</text></g><!--SRC=[DSlD2S0W343XkrFagBGJE4Kt4D6eWP9A38LIkdkXFySFtYDMb18JmYAOAUacS1g02LGYiKrZ3uLM33rgyp1KYAjxWluEDbRqGAmpLEICyW6rCINIux7xNtFT]--></g></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%plantuml\n",
"\n",
Expand All @@ -29,48 +59,28 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Traceback (most recent call last):\n",
" File \"/home/santanche/.local/bin/plantweb\", line 8, in <module>\n",
" sys.exit(run())\n",
" File \"/home/santanche/.local/lib/python3.10/site-packages/plantweb/__main__.py\", line 36, in run\n",
" exit(main(args))\n",
" File \"/home/santanche/.local/lib/python3.10/site-packages/plantweb/main.py\", line 45, in main\n",
" destination = render_file(\n",
" File \"/home/santanche/.local/lib/python3.10/site-packages/plantweb/render.py\", line 228, in render_file\n",
" output, format, engine, sha = render(\n",
" File \"/home/santanche/.local/lib/python3.10/site-packages/plantweb/render.py\", line 199, in render\n",
" output, sha = render_cached(server, format, content, **cacheopts)\n",
" File \"/home/santanche/.local/lib/python3.10/site-packages/plantweb/render.py\", line 122, in render_cached\n",
" output = plantuml(server, format, content)\n",
" File \"/home/santanche/.local/lib/python3.10/site-packages/plantweb/plantuml.py\", line 124, in plantuml\n",
" response.raise_for_status()\n",
" File \"/home/santanche/.local/lib/python3.10/site-packages/requests/models.py\", line 1021, in raise_for_status\n",
" raise HTTPError(http_error_msg, response=self)\n",
"requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://www.plantuml.com/plantuml/svg/SoWkIImgAStDuUAATilFJmaeIat9J2x9BufLq5M0SxYuClDAKelI4fDJ4O8ArLmA2jeA9KM9cNaQcc1s0KGEoAlbSaZDIm6Q2m00\n"
"Writing output for /home/santanche/git/component2learn/notebooks/ai/74041eb9-e92c-43c1-8767-230c8af8b87e.uml to 74041eb9-e92c-43c1-8767-230c8af8b87e.svg\n"
]
},
{
"ename": "CalledProcessError",
"evalue": "Command '['plantweb', '--format', 'auto', '4deeed39-4713-42d5-9b6e-15342c69cb85.uml']' returned non-zero exit status 1.",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mCalledProcessError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[13], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mget_ipython\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_cell_magic\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mplantuml\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m@startuml\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m[FoodPredictor] - Predictor\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43minterface Predictor \u001b[39;49m\u001b[38;5;124;43m{\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m + train()\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m + predict()\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m}\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m@enduml\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2478\u001b[0m, in \u001b[0;36mInteractiveShell.run_cell_magic\u001b[0;34m(self, magic_name, line, cell)\u001b[0m\n\u001b[1;32m 2476\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbuiltin_trap:\n\u001b[1;32m 2477\u001b[0m args \u001b[38;5;241m=\u001b[39m (magic_arg_s, cell)\n\u001b[0;32m-> 2478\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2480\u001b[0m \u001b[38;5;66;03m# The code below prevents the output from being displayed\u001b[39;00m\n\u001b[1;32m 2481\u001b[0m \u001b[38;5;66;03m# when using magics with decodator @output_can_be_silenced\u001b[39;00m\n\u001b[1;32m 2482\u001b[0m \u001b[38;5;66;03m# when the last Python token in the expression is a ';'.\u001b[39;00m\n\u001b[1;32m 2483\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mgetattr\u001b[39m(fn, magic\u001b[38;5;241m.\u001b[39mMAGIC_OUTPUT_CAN_BE_SILENCED, \u001b[38;5;28;01mFalse\u001b[39;00m):\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/iplantuml/__init__.py:101\u001b[0m, in \u001b[0;36mplantuml\u001b[0;34m(line, cell)\u001b[0m\n\u001b[1;32m 99\u001b[0m output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 100\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m use_web:\n\u001b[0;32m--> 101\u001b[0m output \u001b[38;5;241m=\u001b[39m \u001b[43mplantuml_web\u001b[49m\u001b[43m(\u001b[49m\u001b[43muml_path\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 102\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 103\u001b[0m plantuml_path \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mabspath(args\u001b[38;5;241m.\u001b[39mplantuml_path \u001b[38;5;129;01mor\u001b[39;00m PLANTUMLPATH)\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/iplantuml/__init__.py:68\u001b[0m, in \u001b[0;36mplantuml_web\u001b[0;34m(*file_names, **kwargs)\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 58\u001b[0m \u001b[38;5;124;03mGiven a list of UML documents, generate corresponding SVG diagrams, using\u001b[39;00m\n\u001b[1;32m 59\u001b[0m \u001b[38;5;124;03mPlantUML's web service via the plantweb module.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;124;03m:return: the path to the generated SVG UML diagram.\u001b[39;00m\n\u001b[1;32m 63\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 64\u001b[0m cmd \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mplantweb\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 65\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m--format\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 66\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mauto\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m+\u001b[39m \u001b[38;5;28mlist\u001b[39m(file_names)\n\u001b[0;32m---> 68\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_exec_and_get_paths\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcmd\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfile_names\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/iplantuml/__init__.py:32\u001b[0m, in \u001b[0;36m_exec_and_get_paths\u001b[0;34m(cmd, file_names)\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_exec_and_get_paths\u001b[39m(cmd, file_names):\n\u001b[0;32m---> 32\u001b[0m \u001b[43msubprocess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcheck_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcmd\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mshell\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstderr\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msubprocess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mSTDOUT\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 34\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m [os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39msplitext(f)[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.svg\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m file_names]\n",
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:369\u001b[0m, in \u001b[0;36mcheck_call\u001b[0;34m(*popenargs, **kwargs)\u001b[0m\n\u001b[1;32m 367\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cmd \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 368\u001b[0m cmd \u001b[38;5;241m=\u001b[39m popenargs[\u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m--> 369\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CalledProcessError(retcode, cmd)\n\u001b[1;32m 370\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;241m0\u001b[39m\n",
"\u001b[0;31mCalledProcessError\u001b[0m: Command '['plantweb', '--format', 'auto', '4deeed39-4713-42d5-9b6e-15342c69cb85.uml']' returned non-zero exit status 1."
]
"data": {
"image/svg+xml": [
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentStyleType=\"text/css\" height=\"68px\" preserveAspectRatio=\"none\" style=\"width:227px;height:68px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 227 68\" width=\"227px\" zoomAndPan=\"magnify\"><defs/><g><!--entity FoodPredictor--><g id=\"elem_FoodPredictor\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"137.166\" x=\"7\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"124.166\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"122.166\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"122.166\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"97.166\" x=\"22\" y=\"39.9951\">FoodPredictor</text></g><!--entity Predictor--><g id=\"elem_Predictor\"><ellipse cx=\"188.58\" cy=\"30.15\" fill=\"#F1F1F1\" rx=\"8\" ry=\"8\" style=\"stroke:#181818;stroke-width:0.5;\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"63.0957\" x=\"157.0321\" y=\"60.1451\">Predictor</text></g><!--link FoodPredictor to Predictor--><g id=\"link_FoodPredictor_Predictor\"><path d=\"M144.44,30.15 C156.05,30.15 167.66,30.15 179.27,30.15 \" fill=\"none\" id=\"FoodPredictor-Predictor\" style=\"stroke:#181818;stroke-width:1.0;\"/></g><!--SRC=[YtRBpqy9A4fDoKmkoI-ALT1LW7C0]--></g></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -142,7 +152,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -195,7 +205,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -213,5 +223,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit 2bf0ed2

Please sign in to comment.