• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #844

31 Oct 2023 05:42AM UTC coverage: 0.0%. Remained the same
#844

push

circle-ci

Andy Xu
Fix typo

0 of 12389 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/functions/function_bootstrap_queries.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
from evadb.configuration.constants import EvaDB_INSTALLATION_DIR
×
17
from evadb.database import EvaDBDatabase
×
18
from evadb.server.command_handler import execute_query_fetch_all
×
19

20
NDARRAY_DIR = "ndarray"
×
21
TUTORIALS_DIR = "tutorials"
×
22

23
DummyObjectDetector_function_query = """CREATE FUNCTION IF NOT EXISTS DummyObjectDetector
×
24
                  INPUT  (Frame_Array NDARRAY INT8(3, ANYDIM, ANYDIM))
25
                  OUTPUT (label NDARRAY STR(1))
26
                  TYPE  Classification
27
                  IMPL  '{}/../test/util.py';
28
        """.format(
29
    EvaDB_INSTALLATION_DIR
30
)
31

32
DummyMultiObjectDetector_function_query = """CREATE FUNCTION
×
33
                  IF NOT EXISTS  DummyMultiObjectDetector
34
                  INPUT  (Frame_Array NDARRAY INT8(3, ANYDIM, ANYDIM))
35
                  OUTPUT (labels NDARRAY STR(2))
36
                  TYPE  Classification
37
                  IMPL  '{}/../test/util.py';
38
        """.format(
39
    EvaDB_INSTALLATION_DIR
40
)
41

42
DummyFeatureExtractor_function_query = """CREATE FUNCTION
×
43
                  IF NOT EXISTS DummyFeatureExtractor
44
                  INPUT (Frame_Array NDARRAY UINT8(3, ANYDIM, ANYDIM))
45
                  OUTPUT (features NDARRAY FLOAT32(1, ANYDIM))
46
                  TYPE Classification
47
                  IMPL '{}/../test/util.py';
48
        """.format(
49
    EvaDB_INSTALLATION_DIR
50
)
51

52
DummyNoInputFunction_function_query = """CREATE FUNCTION
×
53
                  IF NOT EXISTS DummyNoInputFunction
54
                  IMPL '{}/../test/util.py';
55
        """.format(
56
    EvaDB_INSTALLATION_DIR
57
)
58

59
DummyLLM_function_query = """CREATE FUNCTION
×
60
                  IF NOT EXISTS DummyLLM
61
                  IMPL '{}/../test/util.py';
62
        """.format(
63
    EvaDB_INSTALLATION_DIR
64
)
65

66
fuzzy_function_query = """CREATE FUNCTION IF NOT EXISTS FuzzDistance
×
67
                    INPUT (Input_Array1 NDARRAY ANYTYPE, Input_Array2 NDARRAY ANYTYPE)
68
                    OUTPUT (distance FLOAT(32, 7))
69
                    TYPE NdarrayFunction
70
                    IMPL "{}/functions/{}/fuzzy_join.py";
71
        """.format(
72
    EvaDB_INSTALLATION_DIR, NDARRAY_DIR
73
)
74

75
ArrayCount_function_query = """CREATE FUNCTION
×
76
            IF NOT EXISTS  ArrayCount
77
            INPUT (Input_Array NDARRAY ANYTYPE, Search_Key ANYTYPE)
78
            OUTPUT (key_count INTEGER)
79
            TYPE NdarrayFunction
80
            IMPL "{}/functions/{}/array_count.py";
81
        """.format(
82
    EvaDB_INSTALLATION_DIR, NDARRAY_DIR
83
)
84

85
Crop_function_query = """CREATE FUNCTION IF NOT EXISTS Crop
×
86
                INPUT  (Frame_Array NDARRAY UINT8(3, ANYDIM, ANYDIM),
87
                        bboxes NDARRAY FLOAT32(ANYDIM, 4))
88
                OUTPUT (Cropped_Frame_Array NDARRAY UINT8(3, ANYDIM, ANYDIM))
89
                TYPE  NdarrayFunction
90
                IMPL  "{}/functions/{}/crop.py";
91
        """.format(
92
    EvaDB_INSTALLATION_DIR, NDARRAY_DIR
93
)
94

95
Open_function_query = """CREATE FUNCTION IF NOT EXISTS Open
×
96
                INPUT (img_path TEXT(1000))
97
                OUTPUT (data NDARRAY UINT8(3, ANYDIM, ANYDIM))
98
                TYPE NdarrayFunction
99
                IMPL "{}/functions/{}/open.py";
100
        """.format(
101
    EvaDB_INSTALLATION_DIR, NDARRAY_DIR
102
)
103

104
Similarity_function_query = """CREATE FUNCTION IF NOT EXISTS Similarity
×
105
                    INPUT (Frame_Array_Open NDARRAY UINT8(3, ANYDIM, ANYDIM),
106
                           Frame_Array_Base NDARRAY UINT8(3, ANYDIM, ANYDIM),
107
                           Feature_Extractor_Name TEXT(100))
108
                    OUTPUT (distance FLOAT(32, 7))
109
                    TYPE NdarrayFunction
110
                    IMPL "{}/functions/{}/similarity.py";
111
        """.format(
112
    EvaDB_INSTALLATION_DIR, NDARRAY_DIR
113
)
114

115
Unnest_function_query = """CREATE FUNCTION IF NOT EXISTS Unnest
×
116
                INPUT  (inp NDARRAY ANYTYPE)
117
                OUTPUT (out ANYTYPE)
118
                TYPE  NdarrayFunction
119
                IMPL  "{}/functions/{}/unnest.py";
120
        """.format(
121
    EvaDB_INSTALLATION_DIR, NDARRAY_DIR
122
)
123

124
Fastrcnn_function_query = """CREATE FUNCTION IF NOT EXISTS FastRCNNObjectDetector
×
125
      INPUT  (Frame_Array NDARRAY UINT8(3, ANYDIM, ANYDIM))
126
      OUTPUT (labels NDARRAY STR(ANYDIM), bboxes NDARRAY FLOAT32(ANYDIM, 4),
127
                scores NDARRAY FLOAT32(ANYDIM))
128
      TYPE  Classification
129
      IMPL  '{}/functions/fastrcnn_object_detector.py';
130
      """.format(
131
    EvaDB_INSTALLATION_DIR
132
)
133

134
Yolo_function_query = """CREATE FUNCTION IF NOT EXISTS Yolo
×
135
      TYPE  ultralytics
136
      MODEL 'yolov8m.pt';
137
      """
138

139
face_detection_function_query = """CREATE FUNCTION IF NOT EXISTS FaceDetector
×
140
                  INPUT  (frame NDARRAY UINT8(3, ANYDIM, ANYDIM))
141
                  OUTPUT (bboxes NDARRAY FLOAT32(ANYDIM, 4),
142
                          scores NDARRAY FLOAT32(ANYDIM))
143
                  TYPE  FaceDetection
144
                  IMPL  '{}/functions/face_detector.py';
145
        """.format(
146
    EvaDB_INSTALLATION_DIR
147
)
148

149
Mvit_function_query = """CREATE FUNCTION IF NOT EXISTS MVITActionRecognition
×
150
        INPUT  (Frame_Array NDARRAY UINT8(3, 16, 224, 224))
151
        OUTPUT (labels NDARRAY STR(ANYDIM))
152
        TYPE  Classification
153
        IMPL  '{}/functions/mvit_action_recognition.py';
154
        """.format(
155
    EvaDB_INSTALLATION_DIR
156
)
157

158
Asl_function_query = """CREATE FUNCTION IF NOT EXISTS ASLActionRecognition
×
159
        INPUT  (Frame_Array NDARRAY UINT8(3, 16, 224, 224))
160
        OUTPUT (labels NDARRAY STR(ANYDIM))
161
        TYPE  Classification
162
        IMPL  '{}/functions/asl_action_recognition.py';
163
        """.format(
164
    EvaDB_INSTALLATION_DIR
165
)
166

167
norfair_obj_tracker_query = """CREATE FUNCTION IF NOT EXISTS NorFairTracker
×
168
                  IMPL  '{}/functions/trackers/nor_fair.py';
169
        """.format(
170
    EvaDB_INSTALLATION_DIR
171
)
172

173
Sift_function_query = """CREATE FUNCTION IF NOT EXISTS SiftFeatureExtractor
×
174
        IMPL  '{}/functions/sift_feature_extractor.py';
175
        """.format(
176
    EvaDB_INSTALLATION_DIR
177
)
178

179
Text_feat_function_query = """CREATE FUNCTION IF NOT EXISTS SentenceFeatureExtractor
×
180
        IMPL  '{}/functions/sentence_feature_extractor.py';
181
        """.format(
182
    EvaDB_INSTALLATION_DIR
183
)
184

185
mnistcnn_function_query = """CREATE FUNCTION IF NOT EXISTS MnistImageClassifier
×
186
        INPUT  (data NDARRAY (3, 28, 28))
187
        OUTPUT (label TEXT(2))
188
        TYPE  Classification
189
        IMPL  '{}/functions/mnist_image_classifier.py';
190
        """.format(
191
    EvaDB_INSTALLATION_DIR
192
)
193

194
chatgpt_function_query = """CREATE FUNCTION IF NOT EXISTS ChatGPT
×
195
        IMPL '{}/functions/chatgpt.py';
196
        """.format(
197
    EvaDB_INSTALLATION_DIR
198
)
199

200
yolo8n_query = """CREATE FUNCTION IF NOT EXISTS Yolo
×
201
            TYPE  ultralytics
202
            MODEL 'yolov8n.pt';
203
        """
204

205
stablediffusion_function_query = """CREATE FUNCTION IF NOT EXISTS StableDiffusion
×
206
        IMPL '{}/functions/stable_diffusion.py';
207
        """.format(
208
    EvaDB_INSTALLATION_DIR
209
)
210

211
dalle_function_query = """CREATE FUNCTION IF NOT EXISTS DallE
×
212
        IMPL '{}/functions/dalle.py';
213
        """.format(
214
    EvaDB_INSTALLATION_DIR
215
)
216

217
Upper_function_query = """CREATE FUNCTION IF NOT EXISTS UPPER
×
218
        INPUT  (input ANYTYPE)
219
        OUTPUT (output NDARRAY STR(ANYDIM))
220
        IMPL '{}/functions/helpers/upper.py';
221
        """.format(
222
    EvaDB_INSTALLATION_DIR
223
)
224

225
Lower_function_query = """CREATE FUNCTION IF NOT EXISTS LOWER
×
226
        INPUT  (input ANYTYPE)
227
        OUTPUT (output NDARRAY STR(ANYDIM))
228
        IMPL '{}/functions/helpers/lower.py';
229
        """.format(
230
    EvaDB_INSTALLATION_DIR
231
)
232

233
Concat_function_query = """CREATE FUNCTION IF NOT EXISTS CONCAT
×
234
        INPUT  (input ANYTYPE)
235
        OUTPUT (output NDARRAY STR(ANYDIM))
236
        IMPL '{}/functions/helpers/concat.py';
237
        """.format(
238
    EvaDB_INSTALLATION_DIR
239
)
240

241

242
def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
×
243
    """Load the built-in functions into the system during system bootstrapping.
244

245
    The function loads a set of pre-defined function queries based on the `mode` argument.
246
    In 'debug' mode, the function loads debug functions along with release functions.
247
    In 'release' mode, only release functions are loaded. In addition, in 'debug' mode,
248
    the function loads a smaller model to accelerate the test suite time.
249

250
    Args:G
251
        mode (str, optional): The mode for loading functions, either 'debug' or 'release'.
252
        Defaults to 'debug'.
253

254
    """
255

256
    # Attempting to import torch module
257
    # It is necessary to import torch before to avoid encountering a
258
    # "RuntimeError: random_device could not be read"
259
    # The suspicion is that importing torch prior to decord resolves this issue
260
    try:
×
261
        import torch  # noqa: F401
×
262
    except ImportError:
263
        pass
264

265
    # Enable environment variables
266
    # Relevant for transformer-based models
267
    import os
×
268

269
    os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
×
270
    os.environ["TOKENIZERS_PARALLELISM"] = "false"
×
271

272
    # list of function queries to load
273
    queries = [
×
274
        mnistcnn_function_query,
275
        Fastrcnn_function_query,
276
        ArrayCount_function_query,
277
        Crop_function_query,
278
        Open_function_query,
279
        Similarity_function_query,
280
        norfair_obj_tracker_query,
281
        chatgpt_function_query,
282
        face_detection_function_query,
283
        # Mvit_function_query,
284
        Sift_function_query,
285
        Yolo_function_query,
286
        stablediffusion_function_query,
287
        dalle_function_query,
288
        Upper_function_query,
289
        Lower_function_query,
290
        Concat_function_query,
291
    ]
292

293
    # if mode is 'debug', add debug functions
294
    if mode == "debug":
×
295
        queries.extend(
×
296
            [
297
                DummyObjectDetector_function_query,
298
                DummyMultiObjectDetector_function_query,
299
                DummyFeatureExtractor_function_query,
300
                DummyNoInputFunction_function_query,
301
                DummyLLM_function_query,
302
            ]
303
        )
304

305
    # execute each query in the list of function queries
306
    # ignore exceptions during the bootstrapping phase due to missing packages
307
    for query in queries:
×
308
        try:
×
309
            execute_query_fetch_all(
310
                db, query, do_not_print_exceptions=False, do_not_raise_exceptions=True
311
            )
312
        except Exception:
313
            pass
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc