Skip to content

Commit 9d5081a

Browse files
author
Bob Strahan
committed
Create new modular notebook examples
1 parent 10d47e9 commit 9d5081a

35 files changed

+3212
-222
lines changed
File renamed without changes.
File renamed without changes.

notebooks/bedrock_client_cachepoint_test.ipynb renamed to notebooks/misc/bedrock_client_cachepoint_test.ipynb

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,21 @@
3232
},
3333
{
3434
"cell_type": "code",
35-
"execution_count": 15,
35+
"execution_count": null,
3636
"metadata": {},
3737
"outputs": [
3838
{
3939
"name": "stdout",
4040
"output_type": "stream",
4141
"text": [
42+
"Found existing installation: idp_common 0.3.4\n",
43+
"Uninstalling idp_common-0.3.4:\n",
44+
" Successfully uninstalled idp_common-0.3.4\n",
4245
"Note: you may need to restart the kernel to use updated packages.\n",
43-
"Version: 0.2.21\n",
44-
"Location: /home/ec2-user/.local/lib/python3.11/site-packages\n",
46+
"\u001b[33mWARNING: There was an error checking the latest version of pip.\u001b[0m\u001b[33m\n",
47+
"\u001b[0mNote: you may need to restart the kernel to use updated packages.\n",
48+
"Version: 0.3.4\n",
49+
"Location: /home/ec2-user/.local/lib/python3.12/site-packages\n",
4550
"Note: you may need to restart the kernel to use updated packages.\n"
4651
]
4752
}
@@ -51,14 +56,15 @@
5156
"%load_ext autoreload\n",
5257
"%autoreload 2\n",
5358
"\n",
59+
"ROOTDIR=\"../..\"\n",
5460
"# First uninstall existing package (to ensure we get the latest version)\n",
5561
"%pip uninstall -y idp_common\n",
5662
"\n",
5763
"# Install the IDP common package with all components in development mode\n",
58-
"%pip install -q -e \"../lib/idp_common_pkg[dev, all]\"\n",
64+
"%pip install -q -e \"{ROOTDIR}/lib/idp_common_pkg[dev, all]\"\n",
5965
"\n",
6066
"# Note: We can also install specific components like:\n",
61-
"# %pip install -q -e \"../lib/idp_common_pkg[ocr,classification,extraction,evaluation]\"\n",
67+
"# %pip install -q -e \"{ROOTDIR}/lib/idp_common_pkg[ocr,classification,extraction,evaluation]\"\n",
6268
"\n",
6369
"# Check installed version\n",
6470
"%pip show idp_common | grep -E \"Version|Location\"\n",
@@ -73,7 +79,7 @@
7379
},
7480
{
7581
"cell_type": "code",
76-
"execution_count": 16,
82+
"execution_count": 2,
7783
"metadata": {},
7884
"outputs": [],
7985
"source": [
@@ -99,7 +105,7 @@
99105
},
100106
{
101107
"cell_type": "code",
102-
"execution_count": 17,
108+
"execution_count": 3,
103109
"metadata": {},
104110
"outputs": [],
105111
"source": [
@@ -542,7 +548,7 @@
542548
"name": "python",
543549
"nbconvert_exporter": "python",
544550
"pygments_lexer": "ipython3",
545-
"version": "3.11.12"
551+
"version": "3.12.10"
546552
}
547553
},
548554
"nbformat": 4,
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
"execution_count": 1,
29+
"execution_count": null,
3030
"metadata": {},
3131
"outputs": [
3232
{
@@ -49,14 +49,15 @@
4949
"%load_ext autoreload\n",
5050
"%autoreload 2\n",
5151
"\n",
52+
"ROOTDIR=\"../..\"\n",
5253
"# First uninstall existing package (to ensure we get the latest version)\n",
5354
"%pip uninstall -y idp_common\n",
5455
"\n",
5556
"# Install the IDP common package with all components in development mode\n",
56-
"%pip install -q -e \"../lib/idp_common_pkg[dev, all]\"\n",
57+
"%pip install -q -e \"{ROOTDIR}/lib/idp_common_pkg[dev, all]\"\n",
5758
"\n",
5859
"# Note: We can also install specific components like:\n",
59-
"# %pip install -q -e \"../lib/idp_common_pkg[ocr,classification,extraction,evaluation]\"\n",
60+
"# %pip install -q -e \"{ROOTDIR}/lib/idp_common_pkg[ocr,classification,extraction,evaluation]\"\n",
6061
"\n",
6162
"# Check installed version\n",
6263
"%pip show idp_common | grep -E \"Version|Location\"\n",

notebooks/e2e-example-with-assessment.ipynb renamed to notebooks/misc/e2e-example-with-assessment.ipynb

Lines changed: 88 additions & 81 deletions
Large diffs are not rendered by default.

notebooks/e2e-example-with-multimodal-page-classification-few-shot-prompting.ipynb renamed to notebooks/misc/e2e-example-with-multimodal-page-classification-few-shot-prompting.ipynb

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@
4242
"name": "stdout",
4343
"output_type": "stream",
4444
"text": [
45-
"\u001b[33mWARNING: There was an error checking the latest version of pip.\u001b[0m\u001b[33m\n",
46-
"\u001b[0mNote: you may need to restart the kernel to use updated packages.\n",
47-
"Version: 0.2.21\n",
48-
"Location: /home/ec2-user/.local/lib/python3.12/site-packages\n",
45+
"Found existing installation: idp_common 0.3.4\n",
46+
"Uninstalling idp_common-0.3.4:\n",
47+
" Successfully uninstalled idp_common-0.3.4\n",
48+
"Note: you may need to restart the kernel to use updated packages.\n",
49+
"Note: you may need to restart the kernel to use updated packages.\n",
50+
"Version: 0.3.4\n",
51+
"Location: /home/ec2-user/.local/lib/python3.11/site-packages\n",
4952
"Note: you may need to restart the kernel to use updated packages.\n"
5053
]
5154
}
@@ -55,14 +58,15 @@
5558
"%load_ext autoreload\n",
5659
"%autoreload 2\n",
5760
"\n",
61+
"ROOTDIR=\"../..\"\n",
5862
"# First uninstall existing package (to ensure we get the latest version)\n",
5963
"%pip uninstall -y idp_common\n",
6064
"\n",
6165
"# Install the IDP common package with all components in development mode\n",
62-
"%pip install -q -e \"../lib/idp_common_pkg[dev, all]\"\n",
66+
"%pip install -q -e \"{ROOTDIR}/lib/idp_common_pkg[dev, all]\"\n",
6367
"\n",
6468
"# Note: We can also install specific components like:\n",
65-
"# %pip install -q -e \"../lib/idp_common_pkg[ocr,classification,extraction,evaluation]\"\n",
69+
"# %pip install -q -e \"{ROOTDIR}/lib/idp_common_pkg[ocr,classification,extraction,evaluation]\"\n",
6670
"\n",
6771
"# Check installed version\n",
6872
"%pip show idp_common | grep -E \"Version|Location\"\n",
@@ -84,7 +88,7 @@
8488
},
8589
{
8690
"cell_type": "code",
87-
"execution_count": 2,
91+
"execution_count": null,
8892
"metadata": {},
8993
"outputs": [
9094
{
@@ -133,7 +137,7 @@
133137
"region = os.environ['AWS_REGION']\n",
134138
"\n",
135139
"# Define sample PDF path \n",
136-
"SAMPLE_PDF_PATH = \"../samples/rvl_cdip_package.pdf\"\n",
140+
"SAMPLE_PDF_PATH = f\"{ROOTDIR}/samples/rvl_cdip_package.pdf\"\n",
137141
"\n",
138142
"# Create unique bucket names based on account ID and region\n",
139143
"input_bucket_name = os.getenv(\"IDP_INPUT_BUCKET_NAME\", f\"idp-notebook-input-{account_id}-{region}\")\n",
@@ -155,7 +159,7 @@
155159
"\n",
156160
"# Set ROOT_DIR - used to locate example images from local directory\n",
157161
"# OR set CONFIGURATION_BUCKET to S3 Configration bucket name (contains config_library)\n",
158-
"os.environ['ROOT_DIR'] = '../'\n",
162+
"os.environ['ROOT_DIR'] = ROOTDIR\n",
159163
"\n",
160164
"print(\"Environment setup:\")\n",
161165
"print(f\"METRIC_NAMESPACE: {os.environ.get('METRIC_NAMESPACE')}\")\n",
@@ -182,8 +186,19 @@
182186
"output_type": "stream",
183187
"text": [
184188
"Bucket idp-notebook-input-912625584728-us-west-2 already exists\n",
185-
"Bucket idp-notebook-output-912625584728-us-west-2 already exists\n",
186-
"Uploaded sample file to: s3://idp-notebook-input-912625584728-us-west-2/sample-2025-05-27_14-24-41.pdf\n"
189+
"Bucket idp-notebook-output-912625584728-us-west-2 already exists\n"
190+
]
191+
},
192+
{
193+
"ename": "FileNotFoundError",
194+
"evalue": "[Errno 2] No such file or directory: '../samples/rvl_cdip_package.pdf'",
195+
"output_type": "error",
196+
"traceback": [
197+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
198+
"\u001b[31mFileNotFoundError\u001b[39m Traceback (most recent call last)",
199+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 33\u001b[39m\n\u001b[32m 31\u001b[39m \u001b[38;5;66;03m# Upload the sample file to S3\u001b[39;00m\n\u001b[32m 32\u001b[39m sample_file_key = \u001b[33m\"\u001b[39m\u001b[33msample-\u001b[39m\u001b[33m\"\u001b[39m + datetime.datetime.now().strftime(\u001b[33m\"\u001b[39m\u001b[33m%\u001b[39m\u001b[33mY-\u001b[39m\u001b[33m%\u001b[39m\u001b[33mm-\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[33m_\u001b[39m\u001b[33m%\u001b[39m\u001b[33mH-\u001b[39m\u001b[33m%\u001b[39m\u001b[33mM-\u001b[39m\u001b[33m%\u001b[39m\u001b[33mS\u001b[39m\u001b[33m\"\u001b[39m) + \u001b[33m\"\u001b[39m\u001b[33m.pdf\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m---> \u001b[39m\u001b[32m33\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mSAMPLE_PDF_PATH\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mrb\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m file_data:\n\u001b[32m 34\u001b[39m s3_client.upload_fileobj(file_data, input_bucket_name, sample_file_key)\n\u001b[32m 36\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mUploaded sample file to: s3://\u001b[39m\u001b[38;5;132;01m{\u001b[39;00minput_bucket_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00msample_file_key\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n",
200+
"\u001b[36mFile \u001b[39m\u001b[32m~/.local/lib/python3.11/site-packages/IPython/core/interactiveshell.py:326\u001b[39m, in \u001b[36m_modified_open\u001b[39m\u001b[34m(file, *args, **kwargs)\u001b[39m\n\u001b[32m 319\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m file \u001b[38;5;129;01min\u001b[39;00m {\u001b[32m0\u001b[39m, \u001b[32m1\u001b[39m, \u001b[32m2\u001b[39m}:\n\u001b[32m 320\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 321\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mIPython won\u001b[39m\u001b[33m'\u001b[39m\u001b[33mt let you open fd=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfile\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m by default \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 322\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mas it is likely to crash IPython. If you know what you are doing, \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 323\u001b[39m \u001b[33m\"\u001b[39m\u001b[33myou can use builtins\u001b[39m\u001b[33m'\u001b[39m\u001b[33m open.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 324\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m326\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mio_open\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
201+
"\u001b[31mFileNotFoundError\u001b[39m: [Errno 2] No such file or directory: '../samples/rvl_cdip_package.pdf'"
187202
]
188203
}
189204
],
@@ -235,7 +250,7 @@
235250
},
236251
{
237252
"cell_type": "code",
238-
"execution_count": 4,
253+
"execution_count": null,
239254
"metadata": {},
240255
"outputs": [
241256
{
@@ -249,7 +264,7 @@
249264
"source": [
250265
"# Few shot configuration from config_library\n",
251266
"import yaml\n",
252-
"with open(\"../config_library/pattern-2/few_shot_example/config.yaml\", 'r') as file:\n",
267+
"with open(\"{ROOTDIR}/config_library/pattern-2/few_shot_example_with_multimodal_page_classification/config.yaml\", 'r') as file:\n",
253268
" CONFIG = yaml.safe_load(file)\n",
254269
"\n",
255270
"print(\"Test configuration created\")"
@@ -264,7 +279,7 @@
264279
},
265280
{
266281
"cell_type": "code",
267-
"execution_count": 5,
282+
"execution_count": null,
268283
"metadata": {},
269284
"outputs": [
270285
{
@@ -409,7 +424,7 @@
409424
},
410425
{
411426
"cell_type": "code",
412-
"execution_count": 6,
427+
"execution_count": null,
413428
"metadata": {},
414429
"outputs": [
415430
{
@@ -961,7 +976,7 @@
961976
},
962977
{
963978
"cell_type": "code",
964-
"execution_count": 7,
979+
"execution_count": null,
965980
"metadata": {},
966981
"outputs": [
967982
{
@@ -1028,7 +1043,7 @@
10281043
},
10291044
{
10301045
"cell_type": "code",
1031-
"execution_count": 8,
1046+
"execution_count": null,
10321047
"metadata": {},
10331048
"outputs": [
10341049
{
@@ -1206,7 +1221,7 @@
12061221
},
12071222
{
12081223
"cell_type": "code",
1209-
"execution_count": 9,
1224+
"execution_count": null,
12101225
"metadata": {},
12111226
"outputs": [
12121227
{
@@ -1265,7 +1280,7 @@
12651280
},
12661281
{
12671282
"cell_type": "code",
1268-
"execution_count": 10,
1283+
"execution_count": null,
12691284
"metadata": {},
12701285
"outputs": [
12711286
{
@@ -1538,7 +1553,7 @@
15381553
},
15391554
{
15401555
"cell_type": "code",
1541-
"execution_count": 11,
1556+
"execution_count": null,
15421557
"metadata": {},
15431558
"outputs": [],
15441559
"source": [
@@ -1625,7 +1640,7 @@
16251640
},
16261641
{
16271642
"cell_type": "code",
1628-
"execution_count": 12,
1643+
"execution_count": null,
16291644
"metadata": {},
16301645
"outputs": [
16311646
{
@@ -1675,7 +1690,7 @@
16751690
},
16761691
{
16771692
"cell_type": "code",
1678-
"execution_count": 13,
1693+
"execution_count": null,
16791694
"metadata": {},
16801695
"outputs": [
16811696
{
@@ -1817,7 +1832,7 @@
18171832
},
18181833
{
18191834
"cell_type": "code",
1820-
"execution_count": 14,
1835+
"execution_count": null,
18211836
"metadata": {},
18221837
"outputs": [
18231838
{
@@ -1993,7 +2008,7 @@
19932008
},
19942009
{
19952010
"cell_type": "code",
1996-
"execution_count": 15,
2011+
"execution_count": null,
19972012
"metadata": {},
19982013
"outputs": [],
19992014
"source": [
@@ -2079,7 +2094,7 @@
20792094
"name": "python",
20802095
"nbconvert_exporter": "python",
20812096
"pygments_lexer": "ipython3",
2082-
"version": "3.12.10"
2097+
"version": "3.11.12"
20832098
}
20842099
},
20852100
"nbformat": 4,

0 commit comments

Comments
 (0)