|
42 | 42 | "name": "stdout", |
43 | 43 | "output_type": "stream", |
44 | 44 | "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", |
49 | 52 | "Note: you may need to restart the kernel to use updated packages.\n" |
50 | 53 | ] |
51 | 54 | } |
|
55 | 58 | "%load_ext autoreload\n", |
56 | 59 | "%autoreload 2\n", |
57 | 60 | "\n", |
| 61 | + "ROOTDIR=\"../..\"\n", |
58 | 62 | "# First uninstall existing package (to ensure we get the latest version)\n", |
59 | 63 | "%pip uninstall -y idp_common\n", |
60 | 64 | "\n", |
61 | 65 | "# 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", |
63 | 67 | "\n", |
64 | 68 | "# 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", |
66 | 70 | "\n", |
67 | 71 | "# Check installed version\n", |
68 | 72 | "%pip show idp_common | grep -E \"Version|Location\"\n", |
|
84 | 88 | }, |
85 | 89 | { |
86 | 90 | "cell_type": "code", |
87 | | - "execution_count": 2, |
| 91 | + "execution_count": null, |
88 | 92 | "metadata": {}, |
89 | 93 | "outputs": [ |
90 | 94 | { |
|
133 | 137 | "region = os.environ['AWS_REGION']\n", |
134 | 138 | "\n", |
135 | 139 | "# 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", |
137 | 141 | "\n", |
138 | 142 | "# Create unique bucket names based on account ID and region\n", |
139 | 143 | "input_bucket_name = os.getenv(\"IDP_INPUT_BUCKET_NAME\", f\"idp-notebook-input-{account_id}-{region}\")\n", |
|
155 | 159 | "\n", |
156 | 160 | "# Set ROOT_DIR - used to locate example images from local directory\n", |
157 | 161 | "# 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", |
159 | 163 | "\n", |
160 | 164 | "print(\"Environment setup:\")\n", |
161 | 165 | "print(f\"METRIC_NAMESPACE: {os.environ.get('METRIC_NAMESPACE')}\")\n", |
|
182 | 186 | "output_type": "stream", |
183 | 187 | "text": [ |
184 | 188 | "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'" |
187 | 202 | ] |
188 | 203 | } |
189 | 204 | ], |
|
235 | 250 | }, |
236 | 251 | { |
237 | 252 | "cell_type": "code", |
238 | | - "execution_count": 4, |
| 253 | + "execution_count": null, |
239 | 254 | "metadata": {}, |
240 | 255 | "outputs": [ |
241 | 256 | { |
|
249 | 264 | "source": [ |
250 | 265 | "# Few shot configuration from config_library\n", |
251 | 266 | "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", |
253 | 268 | " CONFIG = yaml.safe_load(file)\n", |
254 | 269 | "\n", |
255 | 270 | "print(\"Test configuration created\")" |
|
264 | 279 | }, |
265 | 280 | { |
266 | 281 | "cell_type": "code", |
267 | | - "execution_count": 5, |
| 282 | + "execution_count": null, |
268 | 283 | "metadata": {}, |
269 | 284 | "outputs": [ |
270 | 285 | { |
|
409 | 424 | }, |
410 | 425 | { |
411 | 426 | "cell_type": "code", |
412 | | - "execution_count": 6, |
| 427 | + "execution_count": null, |
413 | 428 | "metadata": {}, |
414 | 429 | "outputs": [ |
415 | 430 | { |
|
961 | 976 | }, |
962 | 977 | { |
963 | 978 | "cell_type": "code", |
964 | | - "execution_count": 7, |
| 979 | + "execution_count": null, |
965 | 980 | "metadata": {}, |
966 | 981 | "outputs": [ |
967 | 982 | { |
|
1028 | 1043 | }, |
1029 | 1044 | { |
1030 | 1045 | "cell_type": "code", |
1031 | | - "execution_count": 8, |
| 1046 | + "execution_count": null, |
1032 | 1047 | "metadata": {}, |
1033 | 1048 | "outputs": [ |
1034 | 1049 | { |
|
1206 | 1221 | }, |
1207 | 1222 | { |
1208 | 1223 | "cell_type": "code", |
1209 | | - "execution_count": 9, |
| 1224 | + "execution_count": null, |
1210 | 1225 | "metadata": {}, |
1211 | 1226 | "outputs": [ |
1212 | 1227 | { |
|
1265 | 1280 | }, |
1266 | 1281 | { |
1267 | 1282 | "cell_type": "code", |
1268 | | - "execution_count": 10, |
| 1283 | + "execution_count": null, |
1269 | 1284 | "metadata": {}, |
1270 | 1285 | "outputs": [ |
1271 | 1286 | { |
|
1538 | 1553 | }, |
1539 | 1554 | { |
1540 | 1555 | "cell_type": "code", |
1541 | | - "execution_count": 11, |
| 1556 | + "execution_count": null, |
1542 | 1557 | "metadata": {}, |
1543 | 1558 | "outputs": [], |
1544 | 1559 | "source": [ |
|
1625 | 1640 | }, |
1626 | 1641 | { |
1627 | 1642 | "cell_type": "code", |
1628 | | - "execution_count": 12, |
| 1643 | + "execution_count": null, |
1629 | 1644 | "metadata": {}, |
1630 | 1645 | "outputs": [ |
1631 | 1646 | { |
|
1675 | 1690 | }, |
1676 | 1691 | { |
1677 | 1692 | "cell_type": "code", |
1678 | | - "execution_count": 13, |
| 1693 | + "execution_count": null, |
1679 | 1694 | "metadata": {}, |
1680 | 1695 | "outputs": [ |
1681 | 1696 | { |
|
1817 | 1832 | }, |
1818 | 1833 | { |
1819 | 1834 | "cell_type": "code", |
1820 | | - "execution_count": 14, |
| 1835 | + "execution_count": null, |
1821 | 1836 | "metadata": {}, |
1822 | 1837 | "outputs": [ |
1823 | 1838 | { |
|
1993 | 2008 | }, |
1994 | 2009 | { |
1995 | 2010 | "cell_type": "code", |
1996 | | - "execution_count": 15, |
| 2011 | + "execution_count": null, |
1997 | 2012 | "metadata": {}, |
1998 | 2013 | "outputs": [], |
1999 | 2014 | "source": [ |
|
2079 | 2094 | "name": "python", |
2080 | 2095 | "nbconvert_exporter": "python", |
2081 | 2096 | "pygments_lexer": "ipython3", |
2082 | | - "version": "3.12.10" |
| 2097 | + "version": "3.11.12" |
2083 | 2098 | } |
2084 | 2099 | }, |
2085 | 2100 | "nbformat": 4, |
|
0 commit comments