Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 30836ab

Browse files
gaurav274jarulraj
andauthored
fix: Notebooks fix (#887)
1. Fixed tricky notebook bug by forcefully importing `torch` ahead of all other packages. --------- Co-authored-by: jarulraj <arulraj@gatech.edu>
1 parent 90b6350 commit 30836ab

File tree

10 files changed

+220
-231
lines changed

10 files changed

+220
-231
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ workflows:
4747
# name: "Notebook | v3.11 | Linux"
4848
# v: "3.11"
4949
# mode: "NOTEBOOK"
50-
### LINTER
50+
## LINTER
5151
- Linux:
5252
name: "Linter | Linux"
5353
v: "3.10"

evadb/udfs/tutorials/__init__.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

evadb/udfs/udf_bootstrap_queries.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,25 @@ def init_builtin_udfs(db: EvaDBDatabase, mode: str = "debug") -> None:
212212
Defaults to 'debug'.
213213
214214
"""
215+
216+
# Attempting to import torch module
217+
# It is necessary to import torch before to avoid encountering a
218+
# "RuntimeError: random_device could not be read"
219+
# The suspicion is that importing torch prior to decord resolves this issue
220+
try:
221+
import torch # noqa
222+
except ImportError:
223+
pass
224+
215225
# list of UDF queries to load
216226
queries = [
227+
mnistcnn_udf_query,
217228
Fastrcnn_udf_query,
218229
ArrayCount_udf_query,
219230
Crop_udf_query,
220231
Open_udf_query,
221232
Similarity_udf_query,
222233
norfair_obj_tracker_query,
223-
mnistcnn_udf_query,
224234
chatgpt_udf_query,
225235
face_detection_udf_query,
226236
# ocr_udf_query,

script/test/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fi
111111

112112
if [[ ( "$OSTYPE" != "msys" ) && ( "$MODE" = "NOTEBOOK" || "$MODE" = "ALL" ) ]];
113113
then
114-
PYTHONPATH=./ python -m pytest --durations=5 --nbmake --overwrite "./tutorials" --capture=sys --tb=short -v --log-level=WARNING --nbmake-timeout=3000
114+
PYTHONPATH=./ python -m pytest --durations=5 --nbmake --overwrite "./tutorials" --capture=sys --tb=short -v --log-level=WARNING --nbmake-timeout=3000 --ignore="tutorials/09-license-plate-fuzzy-join.ipynb" --ignore="tutorials/10-toxicity-classifier-huggingface.ipynb"
115115
notebook_test_code=$?
116116
if [ "$notebook_test_code" != "0" ];
117117
then

test/integration_tests/test_create_index_executor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def tearDownClass(cls):
9797
query = "DROP TABLE testCreateIndexInputTable;"
9898
execute_query_fetch_all(cls.evadb, query)
9999

100+
@macos_skip_marker
100101
def test_should_create_index_faiss(self):
101102
query = "CREATE INDEX testCreateIndexName ON testCreateIndexFeatTable (feat) USING FAISS;"
102103
execute_query_fetch_all(self.evadb, query)

tutorials/01-mnist.ipynb

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
{
4141
"cell_type": "code",
42-
"execution_count": 1,
42+
"execution_count": 2,
4343
"id": "b6b7f61d",
4444
"metadata": {
4545
"execution": {
@@ -250,6 +250,68 @@
250250
"\n",
251251
"plt.show()"
252252
]
253+
},
254+
{
255+
"attachments": {},
256+
"cell_type": "markdown",
257+
"id": "405b1730",
258+
"metadata": {},
259+
"source": [
260+
"### Drop the function if needed"
261+
]
262+
},
263+
{
264+
"cell_type": "code",
265+
"execution_count": 3,
266+
"id": "829ed2da",
267+
"metadata": {},
268+
"outputs": [
269+
{
270+
"data": {
271+
"text/html": [
272+
"<div>\n",
273+
"<style scoped>\n",
274+
" .dataframe tbody tr th:only-of-type {\n",
275+
" vertical-align: middle;\n",
276+
" }\n",
277+
"\n",
278+
" .dataframe tbody tr th {\n",
279+
" vertical-align: top;\n",
280+
" }\n",
281+
"\n",
282+
" .dataframe thead th {\n",
283+
" text-align: right;\n",
284+
" }\n",
285+
"</style>\n",
286+
"<table border=\"1\" class=\"dataframe\">\n",
287+
" <thead>\n",
288+
" <tr style=\"text-align: right;\">\n",
289+
" <th></th>\n",
290+
" <th>0</th>\n",
291+
" </tr>\n",
292+
" </thead>\n",
293+
" <tbody>\n",
294+
" <tr>\n",
295+
" <th>0</th>\n",
296+
" <td>UDF MnistImageClassifier successfully dropped</td>\n",
297+
" </tr>\n",
298+
" </tbody>\n",
299+
"</table>\n",
300+
"</div>"
301+
],
302+
"text/plain": [
303+
" 0\n",
304+
"0 UDF MnistImageClassifier successfully dropped"
305+
]
306+
},
307+
"execution_count": 3,
308+
"metadata": {},
309+
"output_type": "execute_result"
310+
}
311+
],
312+
"source": [
313+
"cursor.drop_udf(\"MnistImageClassifier\").df()"
314+
]
253315
}
254316
],
255317
"metadata": {

tutorials/03-emotion-analysis.ipynb

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@
5050
"name": "stdout",
5151
"output_type": "stream",
5252
"text": [
53-
"Note: you may need to restart the kernel to use updated packages.\n"
54-
]
55-
},
56-
{
57-
"name": "stdout",
58-
"output_type": "stream",
59-
"text": [
53+
"Note: you may need to restart the kernel to use updated packages.\n",
6054
"Note: you may need to restart the kernel to use updated packages.\n"
6155
]
6256
},
@@ -85,7 +79,7 @@
8579
},
8680
{
8781
"cell_type": "code",
88-
"execution_count": 2,
82+
"execution_count": 4,
8983
"metadata": {
9084
"execution": {
9185
"iopub.execute_input": "2023-06-17T04:34:30.929427Z",
@@ -99,23 +93,29 @@
9993
"name": "stdout",
10094
"output_type": "stream",
10195
"text": [
102-
"File ‘defhappy.mp4’ already there; not retrieving.\r\n"
103-
]
104-
},
105-
{
106-
"name": "stdout",
107-
"output_type": "stream",
108-
"text": [
109-
"File ‘emotion_detector.py’ already there; not retrieving.\r\n",
110-
"\r\n"
111-
]
112-
},
113-
{
114-
"name": "stdout",
115-
"output_type": "stream",
116-
"text": [
117-
"File ‘face_detector.py’ already there; not retrieving.\r\n",
118-
"\r\n"
96+
"File 'defhappy.mp4' already there; not retrieving.\n",
97+
"--2023-06-23 01:50:16-- https://raw.githubusercontent.com/georgia-tech-db/eva/master/evadb/udfs/emotion_detector.py\n",
98+
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.108.133, 185.199.111.133, ...\n",
99+
"Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.\n",
100+
"HTTP request sent, awaiting response... 200 OK\n",
101+
"Length: 6056 (5.9K) [text/plain]\n",
102+
"Saving to: 'emotion_detector.py'\n",
103+
"\n",
104+
"emotion_detector.py 100%[===================>] 5.91K --.-KB/s in 0s \n",
105+
"\n",
106+
"2023-06-23 01:50:16 (31.8 MB/s) - 'emotion_detector.py' saved [6056/6056]\n",
107+
"\n",
108+
"--2023-06-23 01:50:16-- https://raw.githubusercontent.com/georgia-tech-db/eva/master/evadb/udfs/face_detector.py\n",
109+
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...\n",
110+
"Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.\n",
111+
"HTTP request sent, awaiting response... 200 OK\n",
112+
"Length: 2886 (2.8K) [text/plain]\n",
113+
"Saving to: 'face_detector.py'\n",
114+
"\n",
115+
"face_detector.py 100%[===================>] 2.82K --.-KB/s in 0s \n",
116+
"\n",
117+
"2023-06-23 01:50:17 (21.1 MB/s) - 'face_detector.py' saved [2886/2886]\n",
118+
"\n"
119119
]
120120
}
121121
],
@@ -217,7 +217,7 @@
217217
},
218218
{
219219
"cell_type": "code",
220-
"execution_count": 4,
220+
"execution_count": 5,
221221
"metadata": {
222222
"execution": {
223223
"iopub.execute_input": "2023-06-17T04:34:33.328551Z",
@@ -254,18 +254,18 @@
254254
" <tbody>\n",
255255
" <tr>\n",
256256
" <th>0</th>\n",
257-
" <td>UDF FaceDetector already exists, nothing added.</td>\n",
257+
" <td>UDF FaceDetector successfully added to the dat...</td>\n",
258258
" </tr>\n",
259259
" </tbody>\n",
260260
"</table>\n",
261261
"</div>"
262262
],
263263
"text/plain": [
264-
" 0\n",
265-
"0 UDF FaceDetector already exists, nothing added."
264+
" 0\n",
265+
"0 UDF FaceDetector successfully added to the dat..."
266266
]
267267
},
268-
"execution_count": 4,
268+
"execution_count": 5,
269269
"metadata": {},
270270
"output_type": "execute_result"
271271
}
@@ -608,7 +608,7 @@
608608
},
609609
{
610610
"cell_type": "code",
611-
"execution_count": 9,
611+
"execution_count": 6,
612612
"metadata": {
613613
"execution": {
614614
"iopub.execute_input": "2023-06-17T04:34:53.779959Z",
@@ -617,10 +617,53 @@
617617
"shell.execute_reply": "2023-06-17T04:34:53.783057Z"
618618
}
619619
},
620-
"outputs": [],
620+
"outputs": [
621+
{
622+
"data": {
623+
"text/html": [
624+
"<div>\n",
625+
"<style scoped>\n",
626+
" .dataframe tbody tr th:only-of-type {\n",
627+
" vertical-align: middle;\n",
628+
" }\n",
629+
"\n",
630+
" .dataframe tbody tr th {\n",
631+
" vertical-align: top;\n",
632+
" }\n",
633+
"\n",
634+
" .dataframe thead th {\n",
635+
" text-align: right;\n",
636+
" }\n",
637+
"</style>\n",
638+
"<table border=\"1\" class=\"dataframe\">\n",
639+
" <thead>\n",
640+
" <tr style=\"text-align: right;\">\n",
641+
" <th></th>\n",
642+
" <th>0</th>\n",
643+
" </tr>\n",
644+
" </thead>\n",
645+
" <tbody>\n",
646+
" <tr>\n",
647+
" <th>0</th>\n",
648+
" <td>UDF FaceDetector successfully dropped</td>\n",
649+
" </tr>\n",
650+
" </tbody>\n",
651+
"</table>\n",
652+
"</div>"
653+
],
654+
"text/plain": [
655+
" 0\n",
656+
"0 UDF FaceDetector successfully dropped"
657+
]
658+
},
659+
"execution_count": 6,
660+
"metadata": {},
661+
"output_type": "execute_result"
662+
}
663+
],
621664
"source": [
622-
"#cursor.drop(item_name=\"EmotionDetector\", item_type=\"UDF\").df()\n",
623-
"#cursor.drop(item_name=\"FaceDetector\", item_type=\"UDF\").df()"
665+
"cursor.drop_udf(\"EmotionDetector\").df()\n",
666+
"cursor.drop_udf(\"FaceDetector\").df()"
624667
]
625668
}
626669
],

tutorials/05-asl-action-recognition.ipynb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,23 @@
448448
"\n",
449449
"annotate_video(response, input_path, output_path)"
450450
]
451+
},
452+
{
453+
"attachments": {},
454+
"cell_type": "markdown",
455+
"metadata": {},
456+
"source": [
457+
"### Dropping User-Defined Function (UDF)"
458+
]
459+
},
460+
{
461+
"cell_type": "code",
462+
"execution_count": null,
463+
"metadata": {},
464+
"outputs": [],
465+
"source": [
466+
"cursor.drop_udf(\"ASLActionRecognition\").df()"
467+
]
451468
}
452469
],
453470
"metadata": {

0 commit comments

Comments
 (0)