Skip to content

Commit

Permalink
update (notebooks): adjusts in the step by step
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Sep 28, 2024
1 parent c4fb43d commit 05b734e
Show file tree
Hide file tree
Showing 7 changed files with 427 additions and 149 deletions.
3 changes: 3 additions & 0 deletions notebooks/componentization/components.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!procedure $property($name)
portout $name
!endprocedure
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"import pandas as pd\n",
"\n",
"# Read the CSV file\n",
"df = pd.read_csv('intake-person-demo(potato-chips).csv')\n",
"df = pd.read_csv('../../../data/food-intake/analysis/prepared/intake-person-demo(potato-chips).csv')\n",
"\n",
"# Print the first five rows of the file\n",
"print(df.head())"
Expand Down
98 changes: 41 additions & 57 deletions notebooks/componentization/w10-intake-potatos-step01.ipynb

Large diffs are not rendered by default.

62 changes: 30 additions & 32 deletions notebooks/componentization/w10-intake-potatos-step02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
"id": "01518c27-3ca5-4a74-ba5b-62bf9007b386",
"metadata": {},
"source": [
"# Passo a Passo de um Componente"
]
},
{
"cell_type": "markdown",
"id": "feb9af66-7a33-4807-90f8-9aa546091f48",
"metadata": {},
"source": [
"Importando o PlantUML para construir os diagramas"
"# Componentização Passo a Passo\n",
"\n",
"## Passo 2 - Múltiplos Serviços"
]
},
{
Expand All @@ -36,13 +30,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing output for /home/santanche/git/component2learn/notebooks/componentization/76379acc-3550-47cd-aeed-a40c999d3656.uml to 76379acc-3550-47cd-aeed-a40c999d3656.svg\n"
"Writing output for /home/santanche/git/component2learn/notebooks/componentization/d4c8ca03-f618-4c43-b85c-37d7871a91c6.uml to d4c8ca03-f618-4c43-b85c-37d7871a91c6.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=\"68px\" preserveAspectRatio=\"none\" style=\"width:168px;height:68px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 168 68\" width=\"168px\" zoomAndPan=\"magnify\"><defs/><g><!--entity Table--><g id=\"elem_Table\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"78.5205\" x=\"7\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"65.5205\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"38.5205\" x=\"22\" y=\"39.9951\">Table</text></g><!--entity DataFlow--><g id=\"elem_DataFlow\"><ellipse cx=\"129.26\" 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=\"65.3857\" x=\"96.5671\" y=\"60.1451\">DataFlow</text></g><!--link Table to DataFlow--><g id=\"link_Table_DataFlow\"><path d=\"M85.81,30.15 C97.24,30.15 98.67,30.15 110.1,30.15 \" fill=\"none\" id=\"Table-to-DataFlow\" style=\"stroke:#181818;stroke-width:1.0;\"/><path d=\"M117.0218,21.6928 A9,9 0 0 0 117.0218 38.6072\" fill=\"none\" style=\"stroke:#181818;stroke-width:1.5;\"/></g><!--SRC=[Ymv9JCf9ZLNGrL1mIIn9TCl9BmS0]--></g></svg>"
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentStyleType=\"text/css\" height=\"59px\" preserveAspectRatio=\"none\" style=\"width:143px;height:59px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 143 59\" width=\"143px\" zoomAndPan=\"magnify\"><defs/><g><!--entity Table--><g id=\"elem_Table\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"78.5205\" x=\"7\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"65.5205\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"38.5205\" x=\"22\" y=\"39.9951\">Table</text></g><!--entity --><g id=\"elem_ \"><ellipse cx=\"129.26\" cy=\"30.15\" fill=\"#F1F1F1\" rx=\"8\" ry=\"8\" style=\"stroke:#181818;stroke-width:0.5;\"/></g><!--link Table to --><g id=\"link_Table_ \"><path d=\"M85.81,30.15 C97.24,30.15 108.67,30.15 120.1,30.15 \" fill=\"none\" id=\"Table- \" style=\"stroke:#181818;stroke-width:1.0;\"/></g><!--SRC=[Ymv9JCf9ZLNGLL9G0W00]--></g></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
Expand All @@ -57,7 +51,7 @@
"%%plantuml\n",
"\n",
"@startuml\n",
"[Table] -( DataFlow\n",
"[Table] -\" \"\n",
"@enduml"
]
},
Expand All @@ -74,8 +68,8 @@
" def __init__(self, file_path):\n",
" self.file_path = file_path\n",
"\n",
" def connect(self, component):\n",
" component.update(pd.read_csv(self.file_path))"
" def load_data(self):\n",
" return pd.read_csv(self.file_path)"
]
},
{
Expand All @@ -88,13 +82,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing output for /home/santanche/git/component2learn/notebooks/componentization/b847544b-a885-41e7-b277-0d243ea8b8e7.uml to b847544b-a885-41e7-b277-0d243ea8b8e7.svg\n"
"Writing output for /home/santanche/git/component2learn/notebooks/componentization/944070bf-7fb6-4456-bc86-b87e1a47c147.uml to 944070bf-7fb6-4456-bc86-b87e1a47c147.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=\"68px\" preserveAspectRatio=\"none\" style=\"width:205px;height:68px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 205 68\" width=\"205px\" zoomAndPan=\"magnify\"><defs/><g><!--entity DataFlow--><g id=\"elem_DataFlow\"><ellipse cx=\"38.6929\" 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=\"65.3857\" x=\"6\" y=\"60.1451\">DataFlow</text></g><!--entity ScatterPlot--><g id=\"elem_ScatterPlot\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"116.8975\" x=\"82.2429\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"179.1403\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"177.1403\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"177.1403\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"76.8975\" x=\"97.2429\" y=\"39.9951\">ScatterPlot</text></g><!--link DataFlow to ScatterPlot--><g id=\"link_DataFlow_ScatterPlot\"><path d=\"M47.8529,30.15 C59.2229,30.15 70.5829,30.15 81.9429,30.15 \" fill=\"none\" id=\"DataFlow-ScatterPlot\" style=\"stroke:#181818;stroke-width:1.0;\"/></g><!--SRC=[SqaiINJBoIzNq5M83avEB2b9BGh8oI-91G00]--></g></svg>"
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentStyleType=\"text/css\" height=\"59px\" preserveAspectRatio=\"none\" style=\"width:180px;height:59px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 180 59\" width=\"180px\" zoomAndPan=\"magnify\"><defs/><g><!--entity --><g id=\"elem_ \"><ellipse cx=\"14\" cy=\"30.15\" fill=\"#F1F1F1\" rx=\"8\" ry=\"8\" style=\"stroke:#181818;stroke-width:0.5;\"/></g><!--entity ScatterPlot--><g id=\"elem_ScatterPlot\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"116.8975\" x=\"57.55\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"154.4475\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"152.4475\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"152.4475\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"76.8975\" x=\"72.55\" y=\"39.9951\">ScatterPlot</text></g><!--link to ScatterPlot--><g id=\"link_ _ScatterPlot\"><path d=\"M23.16,30.15 C34.53,30.15 45.89,30.15 57.25,30.15 \" fill=\"none\" id=\" -ScatterPlot\" style=\"stroke:#181818;stroke-width:1.0;\"/></g><!--SRC=[Kr9GqbM83avEB2b9BGh8oI-91G00]--></g></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
Expand All @@ -109,7 +103,7 @@
"%%plantuml\n",
"\n",
"@startuml\n",
"DataFlow - [ScatterPlot]\n",
"\" \"- [ScatterPlot]\n",
"@enduml"
]
},
Expand All @@ -123,7 +117,8 @@
"import matplotlib.pyplot as plt\n",
"\n",
"class ScatterPlot:\n",
" def __init__(self, xfield, yfield, title):\n",
" def __init__(self, df, xfield, yfield, title):\n",
" self.df = df\n",
" self.xfield = xfield\n",
" self.yfield = yfield\n",
" self.title = title\n",
Expand All @@ -142,12 +137,7 @@
" plt.colorbar(scatter, label=self.yfield)\n",
"\n",
" # Show the plot\n",
" plt.show()\n",
"\n",
" # Interface DataFlow\n",
" def update(self, new_data):\n",
" self.df = new_data\n",
" self.plot()"
" plt.show()"
]
},
{
Expand All @@ -160,13 +150,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing output for /home/santanche/git/component2learn/notebooks/componentization/06e5c216-b8d4-492b-97fd-892eac801433.uml to 06e5c216-b8d4-492b-97fd-892eac801433.svg\n"
"Writing output for /home/santanche/git/component2learn/notebooks/componentization/02103e03-b259-4c01-aff1-07aee1501de0.uml to 02103e03-b259-4c01-aff1-07aee1501de0.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=\"68px\" preserveAspectRatio=\"none\" style=\"width:295px;height:68px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 295 68\" width=\"295px\" zoomAndPan=\"magnify\"><defs/><g><!--entity Table--><g id=\"elem_Table\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"78.5205\" x=\"7\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"65.5205\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"38.5205\" x=\"22\" y=\"39.9951\">Table</text></g><!--entity DataFlow--><g id=\"elem_DataFlow\"><ellipse cx=\"129.26\" 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=\"65.3857\" x=\"96.5671\" y=\"60.1451\">DataFlow</text></g><!--entity ScatterPlot--><g id=\"elem_ScatterPlot\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"116.8975\" x=\"172.81\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"269.7075\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"267.7075\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"267.7075\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"76.8975\" x=\"187.81\" y=\"39.9951\">ScatterPlot</text></g><!--link Table to DataFlow--><g id=\"link_Table_DataFlow\"><path d=\"M85.81,30.15 C97.24,30.15 98.67,30.15 110.1,30.15 \" fill=\"none\" id=\"Table-to-DataFlow\" style=\"stroke:#181818;stroke-width:1.0;\"/><path d=\"M117.0218,21.6928 A9,9 0 0 0 117.0218 38.6072\" fill=\"none\" style=\"stroke:#181818;stroke-width:1.5;\"/></g><!--link DataFlow to ScatterPlot--><g id=\"link_DataFlow_ScatterPlot\"><path d=\"M138.42,30.15 C149.79,30.15 161.15,30.15 172.51,30.15 \" fill=\"none\" id=\"DataFlow-ScatterPlot\" style=\"stroke:#181818;stroke-width:1.0;\"/></g><!--SRC=[Ymv9JCf9ZLNGrL1mIIn9TCl9BrVWWhDq5QA3anDBIbAB0dBoIs81]--></g></svg>"
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentStyleType=\"text/css\" height=\"59px\" preserveAspectRatio=\"none\" style=\"width:311px;height:59px;background:#FFFFFF;\" version=\"1.1\" viewBox=\"0 0 311 59\" width=\"311px\" zoomAndPan=\"magnify\"><defs/><g><!--entity df--><g id=\"elem_df\"><rect fill=\"#F1F1F1\" height=\"36.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"33.8154\" x=\"120.35\" y=\"12\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"13.8154\" x=\"130.35\" y=\"34.9951\">df</text></g><!--entity Table--><g id=\"elem_Table\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"78.5205\" x=\"7\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"65.5205\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"63.5205\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"38.5205\" x=\"22\" y=\"39.9951\">Table</text></g><!--entity ScatterPlot--><g id=\"elem_ScatterPlot\"><rect fill=\"#F1F1F1\" height=\"46.2969\" rx=\"2.5\" ry=\"2.5\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"116.8975\" x=\"188.81\" y=\"7\"/><rect fill=\"#F1F1F1\" height=\"10\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"15\" x=\"285.7075\" y=\"12\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"283.7075\" y=\"14\"/><rect fill=\"#F1F1F1\" height=\"2\" style=\"stroke:#181818;stroke-width:0.5;\" width=\"4\" x=\"283.7075\" y=\"18\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacing\" textLength=\"76.8975\" x=\"203.81\" y=\"39.9951\">ScatterPlot</text></g><!--link Table to df--><g id=\"link_Table_df\"><path d=\"M85.72,30.15 C97.13,30.15 96.54,30.15 107.95,30.15 \" fill=\"none\" id=\"Table-to-df\" style=\"stroke:#181818;stroke-width:1.0;\"/><ellipse cx=\"113.95\" cy=\"30.15\" fill=\"#FFFFFF\" rx=\"6\" ry=\"6\" style=\"stroke:#181818;stroke-width:1.5;\"/></g><!--reverse link df to ScatterPlot--><g id=\"link_df_ScatterPlot\"><path d=\"M166.45,30.15 C177.81,30.15 177.17,30.15 188.53,30.15 \" fill=\"none\" id=\"df-backto-ScatterPlot\" style=\"stroke:#181818;stroke-width:1.0;\"/><ellipse cx=\"160.45\" cy=\"30.15\" fill=\"#FFFFFF\" rx=\"6\" ry=\"6\" style=\"stroke:#181818;stroke-width:1.5;\"/></g><!--SRC=[AqfDBadCIyz9LKX9uueEIKpAIOrLq3K0yLBI50nq5QA3anDBIbAB0dBoIs81]--></g></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
Expand All @@ -181,8 +171,11 @@
"%%plantuml\n",
"\n",
"@startuml\n",
"[Table] -( DataFlow \n",
"DataFlow - [ScatterPlot]\n",
"\n",
"rectangle df\n",
"[Table] -0 df\n",
"df 0- [ScatterPlot]\n",
"\n",
"@enduml"
]
},
Expand All @@ -204,12 +197,17 @@
}
],
"source": [
"# Create instances\n",
"# Create a DataLoader instance\n",
"table_intake = Table('intake-person-demo(potato-chips).csv')\n",
"scatter_plot = ScatterPlot('age', 'intake_bw', 'Age vs. Intake BW for Potato Chips')\n",
"\n",
"# Connect the ScatterPlot to the DataLoader\n",
"table_intake.connect(scatter_plot)"
"# Load the data\n",
"df = table_intake.load_data()\n",
"\n",
"# Create a ScatterPlot instance\n",
"scatter_plot = ScatterPlot(df, 'age', 'intake_bw', 'Age vs. Intake BW for Potato Chips')\n",
" \n",
"# Generate the plot\n",
"scatter_plot.plot()"
]
}
],
Expand Down
Loading

0 comments on commit 05b734e

Please sign in to comment.