Skip to content

Commit 6f28cca

Browse files
fix import
1 parent 597c560 commit 6f28cca

File tree

1 file changed

+193
-16
lines changed

1 file changed

+193
-16
lines changed

notebooks/field_extraction.ipynb

Lines changed: 193 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,48 @@
2525
},
2626
{
2727
"cell_type": "code",
28-
"execution_count": null,
29-
"metadata": {},
30-
"outputs": [],
28+
"execution_count": 1,
29+
"metadata": {},
30+
"outputs": [
31+
{
32+
"name": "stdout",
33+
"output_type": "stream",
34+
"text": [
35+
"Defaulting to user installation because normal site-packages is not writeable\n",
36+
"Requirement already satisfied: aiohttp in /home/vscode/.local/lib/python3.11/site-packages (from -r ../requirements.txt (line 1)) (3.12.14)\n",
37+
"Requirement already satisfied: azure-identity in /home/vscode/.local/lib/python3.11/site-packages (from -r ../requirements.txt (line 2)) (1.23.0)\n",
38+
"Requirement already satisfied: azure-storage-blob in /home/vscode/.local/lib/python3.11/site-packages (from -r ../requirements.txt (line 3)) (12.25.1)\n",
39+
"Requirement already satisfied: python-dotenv in /home/vscode/.local/lib/python3.11/site-packages (from -r ../requirements.txt (line 4)) (1.1.1)\n",
40+
"Requirement already satisfied: requests in /home/vscode/.local/lib/python3.11/site-packages (from -r ../requirements.txt (line 5)) (2.32.4)\n",
41+
"Requirement already satisfied: Pillow in /home/vscode/.local/lib/python3.11/site-packages (from -r ../requirements.txt (line 6)) (11.3.0)\n",
42+
"Requirement already satisfied: aiohappyeyeballs>=2.5.0 in /home/vscode/.local/lib/python3.11/site-packages (from aiohttp->-r ../requirements.txt (line 1)) (2.6.1)\n",
43+
"Requirement already satisfied: aiosignal>=1.4.0 in /home/vscode/.local/lib/python3.11/site-packages (from aiohttp->-r ../requirements.txt (line 1)) (1.4.0)\n",
44+
"Requirement already satisfied: attrs>=17.3.0 in /home/vscode/.local/lib/python3.11/site-packages (from aiohttp->-r ../requirements.txt (line 1)) (25.3.0)\n",
45+
"Requirement already satisfied: frozenlist>=1.1.1 in /home/vscode/.local/lib/python3.11/site-packages (from aiohttp->-r ../requirements.txt (line 1)) (1.7.0)\n",
46+
"Requirement already satisfied: multidict<7.0,>=4.5 in /home/vscode/.local/lib/python3.11/site-packages (from aiohttp->-r ../requirements.txt (line 1)) (6.6.3)\n",
47+
"Requirement already satisfied: propcache>=0.2.0 in /home/vscode/.local/lib/python3.11/site-packages (from aiohttp->-r ../requirements.txt (line 1)) (0.3.2)\n",
48+
"Requirement already satisfied: yarl<2.0,>=1.17.0 in /home/vscode/.local/lib/python3.11/site-packages (from aiohttp->-r ../requirements.txt (line 1)) (1.20.1)\n",
49+
"Requirement already satisfied: idna>=2.0 in /home/vscode/.local/lib/python3.11/site-packages (from yarl<2.0,>=1.17.0->aiohttp->-r ../requirements.txt (line 1)) (3.10)\n",
50+
"Requirement already satisfied: azure-core>=1.31.0 in /home/vscode/.local/lib/python3.11/site-packages (from azure-identity->-r ../requirements.txt (line 2)) (1.34.0)\n",
51+
"Requirement already satisfied: cryptography>=2.5 in /home/vscode/.local/lib/python3.11/site-packages (from azure-identity->-r ../requirements.txt (line 2)) (45.0.4)\n",
52+
"Requirement already satisfied: msal>=1.30.0 in /home/vscode/.local/lib/python3.11/site-packages (from azure-identity->-r ../requirements.txt (line 2)) (1.32.3)\n",
53+
"Requirement already satisfied: msal-extensions>=1.2.0 in /home/vscode/.local/lib/python3.11/site-packages (from azure-identity->-r ../requirements.txt (line 2)) (1.3.1)\n",
54+
"Requirement already satisfied: typing-extensions>=4.0.0 in /home/vscode/.local/lib/python3.11/site-packages (from azure-identity->-r ../requirements.txt (line 2)) (4.14.0)\n",
55+
"Requirement already satisfied: isodate>=0.6.1 in /home/vscode/.local/lib/python3.11/site-packages (from azure-storage-blob->-r ../requirements.txt (line 3)) (0.7.2)\n",
56+
"Requirement already satisfied: charset_normalizer<4,>=2 in /home/vscode/.local/lib/python3.11/site-packages (from requests->-r ../requirements.txt (line 5)) (3.4.2)\n",
57+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /home/vscode/.local/lib/python3.11/site-packages (from requests->-r ../requirements.txt (line 5)) (2.5.0)\n",
58+
"Requirement already satisfied: certifi>=2017.4.17 in /home/vscode/.local/lib/python3.11/site-packages (from requests->-r ../requirements.txt (line 5)) (2025.6.15)\n",
59+
"Requirement already satisfied: six>=1.11.0 in /home/vscode/.local/lib/python3.11/site-packages (from azure-core>=1.31.0->azure-identity->-r ../requirements.txt (line 2)) (1.17.0)\n",
60+
"Requirement already satisfied: cffi>=1.14 in /home/vscode/.local/lib/python3.11/site-packages (from cryptography>=2.5->azure-identity->-r ../requirements.txt (line 2)) (1.17.1)\n",
61+
"Requirement already satisfied: pycparser in /home/vscode/.local/lib/python3.11/site-packages (from cffi>=1.14->cryptography>=2.5->azure-identity->-r ../requirements.txt (line 2)) (2.22)\n",
62+
"Requirement already satisfied: PyJWT<3,>=1.0.0 in /home/vscode/.local/lib/python3.11/site-packages (from PyJWT[crypto]<3,>=1.0.0->msal>=1.30.0->azure-identity->-r ../requirements.txt (line 2)) (2.10.1)\n",
63+
"\n",
64+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.1.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.2\u001b[0m\n",
65+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
66+
"Note: you may need to restart the kernel to use updated packages.\n"
67+
]
68+
}
69+
],
3170
"source": [
3271
"%pip install -r ../requirements.txt"
3372
]
@@ -52,10 +91,24 @@
5291
"cell_type": "code",
5392
"execution_count": null,
5493
"metadata": {},
55-
"outputs": [],
94+
"outputs": [
95+
{
96+
"name": "stderr",
97+
"output_type": "stream",
98+
"text": [
99+
"INFO:azure.identity._credentials.environment:No environment configuration found.\n",
100+
"INFO:azure.identity._credentials.managed_identity:ManagedIdentityCredential will use IMDS\n",
101+
"INFO:azure.core.pipeline.policies.http_logging_policy:Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'\n",
102+
"Request method: 'GET'\n",
103+
"Request headers:\n",
104+
" 'User-Agent': 'azsdk-python-identity/1.23.0 Python/3.11.12 (Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.36)'\n",
105+
"No body was attached to the request\n",
106+
"INFO:azure.identity._credentials.chained:DefaultAzureCredential acquired a token from AzureCliCredential\n"
107+
]
108+
}
109+
],
56110
"source": [
57111
"import logging\n",
58-
"import json\n",
59112
"import os\n",
60113
"import sys\n",
61114
"from pathlib import Path\n",
@@ -144,9 +197,48 @@
144197
},
145198
{
146199
"cell_type": "code",
147-
"execution_count": null,
148-
"metadata": {},
149-
"outputs": [],
200+
"execution_count": 3,
201+
"metadata": {},
202+
"outputs": [
203+
{
204+
"name": "stdout",
205+
"output_type": "stream",
206+
"text": [
207+
"{\n",
208+
" \"description\": \"Sample invoice analyzer\",\n",
209+
" \"baseAnalyzerId\": \"prebuilt-documentAnalyzer\",\n",
210+
" \"fieldSchema\": {\n",
211+
" \"fields\": {\n",
212+
" \"VendorName\": {\n",
213+
" \"type\": \"string\",\n",
214+
" \"method\": \"extract\",\n",
215+
" \"description\": \"Vendor issuing the invoice\"\n",
216+
" },\n",
217+
" \"Items\": {\n",
218+
" \"type\": \"array\",\n",
219+
" \"method\": \"extract\",\n",
220+
" \"items\": {\n",
221+
" \"type\": \"object\",\n",
222+
" \"properties\": {\n",
223+
" \"Description\": {\n",
224+
" \"type\": \"string\",\n",
225+
" \"method\": \"extract\",\n",
226+
" \"description\": \"Description of the item\"\n",
227+
" },\n",
228+
" \"Amount\": {\n",
229+
" \"type\": \"number\",\n",
230+
" \"method\": \"extract\",\n",
231+
" \"description\": \"Amount of the item\"\n",
232+
" }\n",
233+
" }\n",
234+
" }\n",
235+
" }\n",
236+
" }\n",
237+
" }\n",
238+
"}\n"
239+
]
240+
}
241+
],
150242
"source": [
151243
"import json\n",
152244
"\n",
@@ -165,9 +257,41 @@
165257
},
166258
{
167259
"cell_type": "code",
168-
"execution_count": null,
169-
"metadata": {},
170-
"outputs": [],
260+
"execution_count": 4,
261+
"metadata": {},
262+
"outputs": [
263+
{
264+
"name": "stdout",
265+
"output_type": "stream",
266+
"text": [
267+
"{\n",
268+
" \"description\": \"Sample marketing video analyzer\",\n",
269+
" \"baseAnalyzerId\": \"prebuilt-videoAnalyzer\",\n",
270+
" \"config\": {\n",
271+
" \"returnDetails\": true,\n",
272+
" \"segmentationMode\": \"noSegmentation\"\n",
273+
" },\n",
274+
" \"fieldSchema\": {\n",
275+
" \"fields\": {\n",
276+
" \"Description\": {\n",
277+
" \"type\": \"string\",\n",
278+
" \"description\": \"Detailed summary of the video segment, focusing on product characteristics, lighting, and color palette.\"\n",
279+
" },\n",
280+
" \"Sentiment\": {\n",
281+
" \"type\": \"string\",\n",
282+
" \"method\": \"classify\",\n",
283+
" \"enum\": [\n",
284+
" \"Positive\",\n",
285+
" \"Neutral\",\n",
286+
" \"Negative\"\n",
287+
" ]\n",
288+
" }\n",
289+
" }\n",
290+
" }\n",
291+
"}\n"
292+
]
293+
}
294+
],
171295
"source": [
172296
"analyzer_template_path = '../analyzer_templates/marketing_video.json'\n",
173297
"with open(analyzer_template_path, 'r') as f:\n",
@@ -195,9 +319,48 @@
195319
},
196320
{
197321
"cell_type": "code",
198-
"execution_count": null,
199-
"metadata": {},
200-
"outputs": [],
322+
"execution_count": 5,
323+
"metadata": {},
324+
"outputs": [
325+
{
326+
"name": "stdout",
327+
"output_type": "stream",
328+
"text": [
329+
"{\n",
330+
" \"description\": \"Sample invoice analyzer\",\n",
331+
" \"baseAnalyzerId\": \"prebuilt-documentAnalyzer\",\n",
332+
" \"fieldSchema\": {\n",
333+
" \"fields\": {\n",
334+
" \"VendorName\": {\n",
335+
" \"type\": \"string\",\n",
336+
" \"method\": \"extract\",\n",
337+
" \"description\": \"Vendor issuing the invoice\"\n",
338+
" },\n",
339+
" \"Items\": {\n",
340+
" \"type\": \"array\",\n",
341+
" \"method\": \"extract\",\n",
342+
" \"items\": {\n",
343+
" \"type\": \"object\",\n",
344+
" \"properties\": {\n",
345+
" \"Description\": {\n",
346+
" \"type\": \"string\",\n",
347+
" \"method\": \"extract\",\n",
348+
" \"description\": \"Description of the item\"\n",
349+
" },\n",
350+
" \"Amount\": {\n",
351+
" \"type\": \"number\",\n",
352+
" \"method\": \"extract\",\n",
353+
" \"description\": \"Amount of the item\"\n",
354+
" }\n",
355+
" }\n",
356+
" }\n",
357+
" }\n",
358+
" }\n",
359+
" }\n",
360+
"}\n"
361+
]
362+
}
363+
],
201364
"source": [
202365
"analyzer_template_path = '../analyzer_templates/invoice.json'\n",
203366
"with open(analyzer_template_path, 'r') as f:\n",
@@ -218,8 +381,22 @@
218381
"cell_type": "code",
219382
"execution_count": null,
220383
"metadata": {},
221-
"outputs": [],
384+
"outputs": [
385+
{
386+
"ename": "NameError",
387+
"evalue": "name 'uuid' is not defined",
388+
"output_type": "error",
389+
"traceback": [
390+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
391+
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
392+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[6]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m sample_file_path = \u001b[33m'\u001b[39m\u001b[33m../data/invoice.pdf\u001b[39m\u001b[33m'\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m invoice_analyzer_id = \u001b[33m\"\u001b[39m\u001b[33minvoice-extraction-\u001b[39m\u001b[33m\"\u001b[39m + \u001b[38;5;28mstr\u001b[39m(\u001b[43muuid\u001b[49m.uuid4())\n\u001b[32m 4\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mCreating invoice analyzer: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00minvoice_analyzer_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m 5\u001b[39m response = client.begin_create_analyzer(invoice_analyzer_id, analyzer_template_path=analyzer_template_path)\n",
393+
"\u001b[31mNameError\u001b[39m: name 'uuid' is not defined"
394+
]
395+
}
396+
],
222397
"source": [
398+
"import uuid\n",
399+
"\n",
223400
"sample_file_path = '../data/invoice.pdf'\n",
224401
"invoice_analyzer_id = \"invoice-extraction-\" + str(uuid.uuid4())\n",
225402
"\n",
@@ -831,7 +1008,7 @@
8311008
"name": "python",
8321009
"nbconvert_exporter": "python",
8331010
"pygments_lexer": "ipython3",
834-
"version": "3.11.13"
1011+
"version": "3.11.12"
8351012
}
8361013
},
8371014
"nbformat": 4,

0 commit comments

Comments
 (0)