diff --git a/README.md b/README.md index 80cb9bb0..a340d6dd 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/notebooks/ai/food-prediction.ipynb b/notebooks/ai/food-prediction.ipynb index 18e6c072..83c0920b 100644 --- a/notebooks/ai/food-prediction.ipynb +++ b/notebooks/ai/food-prediction.ipynb @@ -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": [ @@ -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": [ + "Predictortrain(csv_file_path: string)predict(age: int, gender: int, ethnicity: int): string" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "%%plantuml\n", "\n", @@ -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 \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": [ + "FoodPredictorPredictor" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -142,7 +152,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -195,7 +205,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -213,5 +223,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }