Skip to content

Commit

Permalink
Function Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsteng committed Nov 22, 2023
1 parent f6f3dda commit d517c57
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions evadb/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
IFRAMES = "IFRAMES"
AUDIORATE = "AUDIORATE"
DEFAULT_FUNCTION_EXPRESSION_COST = 100
DBFUNCTIONS = __file__[0: -13] + "/functions/"
ENVFUNCTIONS = "./Lib/site-packages/evadb/functions/"
11 changes: 8 additions & 3 deletions evadb/functions/function_bootstrap_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
from evadb.database import EvaDBDatabase
from evadb.server.command_handler import execute_query_fetch_all

import sys
import subprocess

NDARRAY_DIR = "ndarray"
TUTORIALS_DIR = "tutorials"

Expand Down Expand Up @@ -221,15 +224,13 @@
""".format(
EvaDB_INSTALLATION_DIR
)

Lower_function_query = """CREATE FUNCTION IF NOT EXISTS LOWER
INPUT (input ANYTYPE)
OUTPUT (output NDARRAY STR(ANYDIM))
IMPL '{}/functions/helpers/lower.py';
""".format(
EvaDB_INSTALLATION_DIR
)

Concat_function_query = """CREATE FUNCTION IF NOT EXISTS CONCAT
INPUT (input ANYTYPE)
OUTPUT (output NDARRAY STR(ANYDIM))
Expand All @@ -238,7 +239,6 @@
EvaDB_INSTALLATION_DIR
)


def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
"""Load the built-in functions into the system during system bootstrapping.
Expand Down Expand Up @@ -306,6 +306,11 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
# ignore exceptions during the bootstrapping phase due to missing packages
for query in queries:
try:
#Uncomment to force pip installs onto local device
#subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'norfair'])
#subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'ultralytics'])
#subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'facenet-pytorch'])
#cursor.query("DROP FUNCTION IF EXISTS NorFairTracker;").df()
execute_query_fetch_all(
db, query, do_not_print_exceptions=False, do_not_raise_exceptions=True
)
Expand Down
4 changes: 4 additions & 0 deletions evadb/functions/trackers/nor_fair.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.
import numpy as np

#import sys

from evadb.functions.abstract.tracker_abstract_function import (
EvaDBTrackerAbstractFunction,
)
Expand All @@ -31,6 +33,8 @@ def name(self) -> str:
def setup(self, distance_threshold=DISTANCE_THRESHOLD_CENTROID) -> None:
# https://github.com/tryolabs/norfair/blob/74b11edde83941dd6e32bcccd5fa849e16bf8564/norfair/tracker.py#L18
try_to_import_norfair()
#sys.path.append('../norfair')
#from norfair.tracker import Tracker
from norfair import Tracker

self.tracker = Tracker(
Expand Down
12 changes: 10 additions & 2 deletions evadb/parser/create_function_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from pathlib import Path
from typing import List, Tuple

from evadb.configuration.constants import EvaDB_INSTALLATION_DIR
from evadb.parser.create_statement import ColumnDefinition
from evadb.parser.select_statement import SelectStatement
from evadb.parser.statement import AbstractStatement
from evadb.parser.types import StatementType


class CreateFunctionStatement(AbstractStatement):
"""CreateFunctionStatement constructed after parsing the input query
Expand Down Expand Up @@ -64,7 +64,15 @@ def __init__(
self._if_not_exists = if_not_exists
self._inputs = inputs
self._outputs = outputs
self._impl_path = Path(impl_path) if impl_path else None
if impl_path:
if "DBFUNCTIONS" == impl_path[0:11] and (impl_path[11:12] == "." or impl_path[11:12] == "\\" or impl_path[11:12] == "/"):
self._impl_path = Path(str(EvaDB_INSTALLATION_DIR) + "\\functions\\" + impl_path[12:])
elif "ENVFUNCTIONS" == impl_path[0:12] and (impl_path[12:13] == "." or impl_path[12:13] == "\\" or impl_path[12:13] == "/"):
self._impl_path = Path( "..\\functions\\" + impl_path[13:])
else:
self._impl_path = Path(impl_path)
else:
self._impl_path = None
self._function_type = function_type
self._query = query
self._metadata = metadata
Expand Down

0 comments on commit d517c57

Please sign in to comment.