diff --git a/evadb/constants.py b/evadb/constants.py index 80777c5ab4..06e3973ea3 100644 --- a/evadb/constants.py +++ b/evadb/constants.py @@ -21,3 +21,5 @@ IFRAMES = "IFRAMES" AUDIORATE = "AUDIORATE" DEFAULT_FUNCTION_EXPRESSION_COST = 100 +DBFUNCTIONS = __file__[0: -13] + "/functions/" +ENVFUNCTIONS = "./Lib/site-packages/evadb/functions/" \ No newline at end of file diff --git a/evadb/functions/function_bootstrap_queries.py b/evadb/functions/function_bootstrap_queries.py index f8186d4dd3..eeceb00f5b 100644 --- a/evadb/functions/function_bootstrap_queries.py +++ b/evadb/functions/function_bootstrap_queries.py @@ -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" @@ -221,7 +224,6 @@ """.format( EvaDB_INSTALLATION_DIR ) - Lower_function_query = """CREATE FUNCTION IF NOT EXISTS LOWER INPUT (input ANYTYPE) OUTPUT (output NDARRAY STR(ANYDIM)) @@ -229,7 +231,6 @@ """.format( EvaDB_INSTALLATION_DIR ) - Concat_function_query = """CREATE FUNCTION IF NOT EXISTS CONCAT INPUT (input ANYTYPE) OUTPUT (output NDARRAY STR(ANYDIM)) @@ -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. @@ -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 ) diff --git a/evadb/functions/trackers/nor_fair.py b/evadb/functions/trackers/nor_fair.py index 0468a3c997..8cc3bf1561 100644 --- a/evadb/functions/trackers/nor_fair.py +++ b/evadb/functions/trackers/nor_fair.py @@ -14,6 +14,8 @@ # limitations under the License. import numpy as np +#import sys + from evadb.functions.abstract.tracker_abstract_function import ( EvaDBTrackerAbstractFunction, ) @@ -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( diff --git a/evadb/parser/create_function_statement.py b/evadb/parser/create_function_statement.py index eb35fcffaa..e8ada39984 100644 --- a/evadb/parser/create_function_statement.py +++ b/evadb/parser/create_function_statement.py @@ -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 @@ -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