Skip to content

Commit

Permalink
Merge pull request #26 from gizatechxyz/abstract-output-dtypes
Browse files Browse the repository at this point in the history
Abstract output dtype
  • Loading branch information
raphaelDkhn authored Mar 19, 2024
2 parents 986322a + 47a30aa commit e846b90
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 78 deletions.
83 changes: 31 additions & 52 deletions examples/verifiable_mnist/verifiable_mnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,6 @@
"# Login to Giza and create a Workspace"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://api-dev.gizatech.xyz\n"
]
}
],
"source": [
"# TODO: remove this cell when it deploys on main branch\n",
"\n",
"import os\n",
"import uuid\n",
"\n",
"os.environ['GIZA_API_HOST'] = 'https://api-dev.gizatech.xyz'\n",
"print(os.environ['GIZA_API_HOST'])\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -1984,22 +1961,22 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/raphaeldoukhan/Library/Caches/pypoetry/virtualenvs/giza-actions-mYf3m_Lk-py3.11/lib/python3.11/site-packages/prefect/tasks.py:337: UserWarning: A task named 'Preprocess Image' and defined at '/Users/raphaeldoukhan/Desktop/Orion-Giza/Tools/actions-sdk/giza_actions/task.py:7' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:\n",
"/Users/raphaeldoukhan/Library/Caches/pypoetry/virtualenvs/giza-actions-mYf3m_Lk-py3.11/lib/python3.11/site-packages/prefect/tasks.py:332: UserWarning: A task named 'Preprocess Image' and defined at '/Users/raphaeldoukhan/Desktop/Orion-Giza/Tools/actions-sdk/giza_actions/task.py:7' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:\n",
"\n",
" `@task(name='my_unique_name', ...)`\n",
" warnings.warn(\n",
"/Users/raphaeldoukhan/Library/Caches/pypoetry/virtualenvs/giza-actions-mYf3m_Lk-py3.11/lib/python3.11/site-packages/prefect/tasks.py:337: UserWarning: A task named 'Prediction with Cairo' and defined at '/Users/raphaeldoukhan/Desktop/Orion-Giza/Tools/actions-sdk/giza_actions/task.py:20' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:\n",
"/Users/raphaeldoukhan/Library/Caches/pypoetry/virtualenvs/giza-actions-mYf3m_Lk-py3.11/lib/python3.11/site-packages/prefect/tasks.py:332: UserWarning: A task named 'Prediction with Cairo' and defined at '/Users/raphaeldoukhan/Desktop/Orion-Giza/Tools/actions-sdk/giza_actions/task.py:20' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:\n",
"\n",
" `@task(name='my_unique_name', ...)`\n",
" warnings.warn(\n",
"/Users/raphaeldoukhan/Library/Caches/pypoetry/virtualenvs/giza-actions-mYf3m_Lk-py3.11/lib/python3.11/site-packages/prefect/flows.py:337: UserWarning: A flow named 'Execution: Prediction with Cairo' and defined at '/Users/raphaeldoukhan/Desktop/Orion-Giza/Tools/actions-sdk/giza_actions/action.py:36' conflicts with another flow. Consider specifying a unique `name` parameter in the flow definition:\n",
"/Users/raphaeldoukhan/Library/Caches/pypoetry/virtualenvs/giza-actions-mYf3m_Lk-py3.11/lib/python3.11/site-packages/prefect/flows.py:336: UserWarning: A flow named 'Execution: Prediction with Cairo' and defined at '/Users/raphaeldoukhan/Desktop/Orion-Giza/Tools/actions-sdk/giza_actions/action.py:36' conflicts with another flow. Consider specifying a unique `name` parameter in the flow definition:\n",
"\n",
" `@flow(name='my_unique_name', ...)`\n",
" warnings.warn(\n"
Expand All @@ -2008,11 +1985,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:42.535 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Created flow run<span style=\"color: #800080; text-decoration-color: #800080\"> 'industrious-wrasse'</span> for flow<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\"> 'Execution: Prediction with Cairo'</span>\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:27.522 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Created flow run<span style=\"color: #800080; text-decoration-color: #800080\"> 'shapeless-snail'</span> for flow<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\"> 'Execution: Prediction with Cairo'</span>\n",
"</pre>\n"
],
"text/plain": [
"11:08:42.535 | \u001b[36mINFO\u001b[0m | Created flow run\u001b[35m 'industrious-wrasse'\u001b[0m for flow\u001b[1;35m 'Execution: Prediction with Cairo'\u001b[0m\n"
"18:29:27.522 | \u001b[36mINFO\u001b[0m | Created flow run\u001b[35m 'shapeless-snail'\u001b[0m for flow\u001b[1;35m 'Execution: Prediction with Cairo'\u001b[0m\n"
]
},
"metadata": {},
Expand All @@ -2021,11 +1998,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:42.537 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - View at <span style=\"color: #0000ff; text-decoration-color: #0000ff\">https://actions-server-raphael-doukhan-dblzzhtf5q-ew.a.run.app/flow-runs/flow-run/40572d39-7a1f-46be-873f-4737742bff89</span>\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:27.523 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - View at <span style=\"color: #0000ff; text-decoration-color: #0000ff\">https://actions-server-raphael-doukhan-dblzzhtf5q-ew.a.run.app/flow-runs/flow-run/5068c561-0a8c-4fcf-9bff-8cb7b2617d19</span>\n",
"</pre>\n"
],
"text/plain": [
"11:08:42.537 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - View at \u001b[94mhttps://actions-server-raphael-doukhan-dblzzhtf5q-ew.a.run.app/flow-runs/flow-run/40572d39-7a1f-46be-873f-4737742bff89\u001b[0m\n"
"18:29:27.523 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - View at \u001b[94mhttps://actions-server-raphael-doukhan-dblzzhtf5q-ew.a.run.app/flow-runs/flow-run/5068c561-0a8c-4fcf-9bff-8cb7b2617d19\u001b[0m\n"
]
},
"metadata": {},
Expand All @@ -2034,11 +2011,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:43.118 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - Created task run 'Preprocess Image-0' for task 'Preprocess Image'\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:27.740 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - Created task run 'Preprocess Image-0' for task 'Preprocess Image'\n",
"</pre>\n"
],
"text/plain": [
"11:08:43.118 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - Created task run 'Preprocess Image-0' for task 'Preprocess Image'\n"
"18:29:27.740 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - Created task run 'Preprocess Image-0' for task 'Preprocess Image'\n"
]
},
"metadata": {},
Expand All @@ -2047,11 +2024,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:43.121 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - Executing 'Preprocess Image-0' immediately...\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:27.742 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - Executing 'Preprocess Image-0' immediately...\n",
"</pre>\n"
],
"text/plain": [
"11:08:43.121 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - Executing 'Preprocess Image-0' immediately...\n"
"18:29:27.742 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - Executing 'Preprocess Image-0' immediately...\n"
]
},
"metadata": {},
Expand All @@ -2060,11 +2037,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:43.632 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Task run 'Preprocess Image-0' - Finished in state <span style=\"color: #008000; text-decoration-color: #008000\">Completed</span>()\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:28.006 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Task run 'Preprocess Image-0' - Finished in state <span style=\"color: #008000; text-decoration-color: #008000\">Completed</span>()\n",
"</pre>\n"
],
"text/plain": [
"11:08:43.632 | \u001b[36mINFO\u001b[0m | Task run 'Preprocess Image-0' - Finished in state \u001b[32mCompleted\u001b[0m()\n"
"18:29:28.006 | \u001b[36mINFO\u001b[0m | Task run 'Preprocess Image-0' - Finished in state \u001b[32mCompleted\u001b[0m()\n"
]
},
"metadata": {},
Expand All @@ -2073,11 +2050,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:43.749 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - Created task run 'Prediction with Cairo-0' for task 'Prediction with Cairo'\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:28.112 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - Created task run 'Prediction with Cairo-0' for task 'Prediction with Cairo'\n",
"</pre>\n"
],
"text/plain": [
"11:08:43.749 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - Created task run 'Prediction with Cairo-0' for task 'Prediction with Cairo'\n"
"18:29:28.112 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - Created task run 'Prediction with Cairo-0' for task 'Prediction with Cairo'\n"
]
},
"metadata": {},
Expand All @@ -2086,11 +2063,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:43.751 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - Executing 'Prediction with Cairo-0' immediately...\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:28.115 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - Executing 'Prediction with Cairo-0' immediately...\n",
"</pre>\n"
],
"text/plain": [
"11:08:43.751 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - Executing 'Prediction with Cairo-0' immediately...\n"
"18:29:28.115 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - Executing 'Prediction with Cairo-0' immediately...\n"
]
},
"metadata": {},
Expand All @@ -2107,11 +2084,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:47.958 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Task run 'Prediction with Cairo-0' - Finished in state <span style=\"color: #008000; text-decoration-color: #008000\">Completed</span>()\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:32.420 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Task run 'Prediction with Cairo-0' - Finished in state <span style=\"color: #008000; text-decoration-color: #008000\">Completed</span>()\n",
"</pre>\n"
],
"text/plain": [
"11:08:47.958 | \u001b[36mINFO\u001b[0m | Task run 'Prediction with Cairo-0' - Finished in state \u001b[32mCompleted\u001b[0m()\n"
"18:29:32.420 | \u001b[36mINFO\u001b[0m | Task run 'Prediction with Cairo-0' - Finished in state \u001b[32mCompleted\u001b[0m()\n"
]
},
"metadata": {},
Expand All @@ -2120,11 +2097,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:47.961 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - Result: tensor([0])\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:32.421 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - Result: tensor([0])\n",
"</pre>\n"
],
"text/plain": [
"11:08:47.961 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - Result: tensor([0])\n"
"18:29:32.421 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - Result: tensor([0])\n"
]
},
"metadata": {},
Expand All @@ -2133,11 +2110,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:47.962 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - Request id: \"cd38a8593d2c429cb8c45f5e37939409\"\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:32.422 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - Request id: \"b2484bba4b5644df80ab7eed20f1c87b\"\n",
"</pre>\n"
],
"text/plain": [
"11:08:47.962 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - Request id: \"cd38a8593d2c429cb8c45f5e37939409\"\n"
"18:29:32.422 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - Request id: \"b2484bba4b5644df80ab7eed20f1c87b\"\n"
]
},
"metadata": {},
Expand All @@ -2146,11 +2123,11 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">11:08:48.087 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'industrious-wrasse' - Finished in state <span style=\"color: #008000; text-decoration-color: #008000\">Completed</span>()\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">18:29:32.508 | <span style=\"color: #008080; text-decoration-color: #008080\">INFO</span> | Action run 'shapeless-snail' - Finished in state <span style=\"color: #008000; text-decoration-color: #008000\">Completed</span>()\n",
"</pre>\n"
],
"text/plain": [
"11:08:48.087 | \u001b[36mINFO\u001b[0m | Action run 'industrious-wrasse' - Finished in state \u001b[32mCompleted\u001b[0m()\n"
"18:29:32.508 | \u001b[36mINFO\u001b[0m | Action run 'shapeless-snail' - Finished in state \u001b[32mCompleted\u001b[0m()\n"
]
},
"metadata": {},
Expand All @@ -2159,10 +2136,10 @@
{
"data": {
"text/plain": [
"(tensor([0]), '\"cd38a8593d2c429cb8c45f5e37939409\"')"
"(tensor([0]), '\"b2484bba4b5644df80ab7eed20f1c87b\"')"
]
},
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -2174,6 +2151,7 @@
"MODEL_ID = 296 # Update with your model ID\n",
"VERSION_ID = 1 # Update with your version ID\n",
"\n",
"\n",
"@task(name=f'Preprocess Image')\n",
"def preprocess_image(image_path):\n",
" from PIL import Image\n",
Expand All @@ -2187,12 +2165,13 @@
" image = image.reshape(1, 196) # Reshape to (1, 196) for model input\n",
" return image\n",
"\n",
"\n",
"@task(name=f'Prediction with Cairo')\n",
"def prediction(image, model_id, version_id):\n",
" model = GizaModel(id=model_id, version=version_id)\n",
"\n",
" (result, request_id) = model.predict(\n",
" input_feed={\"image\": image}, verifiable=True, output_dtype=\"Tensor<FP16x16>\"\n",
" input_feed={\"image\": image}, verifiable=True\n",
" )\n",
"\n",
" # Convert result to a PyTorch tensor\n",
Expand Down
Loading

0 comments on commit e846b90

Please sign in to comment.