Skip to content

Commit

Permalink
update case
Browse files Browse the repository at this point in the history
  • Loading branch information
jiashenC committed Sep 4, 2023
1 parent 1c1794e commit 1589f9b
Show file tree
Hide file tree
Showing 27 changed files with 67 additions and 67 deletions.
4 changes: 2 additions & 2 deletions docs/source/reference/ai/custom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ A sample forward function is given below
----------

Part 2: Registering and using the function in EvaDB Queries
------------------------------------------------------
-----------------------------------------------------------

Now that you have implemented your function, we need to register it as a function in EvaDB. You can then use the function in any query.

Expand Down Expand Up @@ -146,4 +146,4 @@ Now that you have implemented your function, we need to register it as a functio

.. code-block:: sql
DROP Function IF EXISTS YoloDecorators;
DROP FUNCTION IF EXISTS YoloDecorators;
2 changes: 1 addition & 1 deletion docs/source/reference/ai/hf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This section provides an overview of how you can use out-of-the-box HuggingFace


Creating Function from HuggingFace
------------------------------
----------------------------------

EvaDB supports functions similar to `Pipelines <https://huggingface.co/docs/transformers/main_classes/pipelines>`_ in HuggingFace.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/ai/openai.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This section provides an overview of how you can use OpenAI models in EvaDB.


Chat Completion Functions
--------------------
-------------------------

To create a chat completion function in EvaDB, use the following SQL command:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/ai/yolo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The following models are currently supported by Ultralytics in EvaDB:
Please refer to the `Ultralytics documentation <https://docs.ultralytics.com/tasks/detect/#models>`_ for more information about these models and their capabilities.

Using Ultralytics Models with Other Functions
----------------------------------------
---------------------------------------------
This code block demonstrates how the YOLO model can be combined with other models such as Color and DogBreedClassifier to perform more specific and targeted object detection tasks. In this case, the goal is to find images of black-colored Great Danes.

The first query uses YOLO to detect all images of dogs with black color. The ``UNNEST`` function is used to split the output of the ``Yolo`` function into individual rows, one for each object detected in the image. The ``Color`` function is then applied to the cropped portion of the image to identify the color of each detected dog object. The ``WHERE`` clause filters the results to only include objects labeled as "dog" and with a color of "black".
Expand Down
16 changes: 8 additions & 8 deletions evadb/binder/statement_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _bind_create_function_statement(self, node: CreateFunctionStatement):
arg_map = {key: value for key, value in node.metadata}
assert (
"predict" in arg_map
), f"Creating {node.function_type} FUNCTIONs expects 'predict' metadata."
), f"Creating {node.function_type} functions expects 'predict' metadata."
# We only support a single predict column for now
predict_columns = set([arg_map["predict"]])
inputs, outputs = [], []
Expand All @@ -98,7 +98,7 @@ def _bind_create_function_statement(self, node: CreateFunctionStatement):
inputs.append(column)
assert (
len(node.inputs) == 0 and len(node.outputs) == 0
), f"{node.function_type} FUNCTIONs' input and output are auto assigned"
), f"{node.function_type} functions' input and output are auto assigned"
node.inputs, node.outputs = inputs, outputs

@bind.register(CreateIndexStatement)
Expand Down Expand Up @@ -133,7 +133,7 @@ def _bind_create_index_statement(self, node: CreateIndexStatement):
), "Index input needs to be float32."
assert len(col.array_dimensions) == 2
else:
# Output of the FUNCTION should be 2 dimension and float32 type.
# Output of the function should be 2 dimension and float32 type.
function_obj = self._catalog().get_function_catalog_entry_by_name(
node.function.name
)
Expand Down Expand Up @@ -322,12 +322,12 @@ def _bind_func_expr(self, node: FunctionExpression):
.as_posix()
)

# Verify the consistency of the FUNCTION. If the checksum of the FUNCTION does not
# Verify the consistency of the function. If the checksum of the function does not
# match the one stored in the catalog, an error will be thrown and the user
# will be asked to register the FUNCTION again.
# will be asked to register the function again.
# assert (
# get_file_checksum(function_obj.impl_file_path) == function_obj.checksum
# ), f"""FUNCTION file {function_obj.impl_file_path} has been modified from the
# ), f"""Function file {function_obj.impl_file_path} has been modified from the
# registration. Please use DROP FUNCTION to drop it and re-create it # using CREATE FUNCTION."""

try:
Expand All @@ -342,8 +342,8 @@ def _bind_func_expr(self, node: FunctionExpression):
)
except Exception as e:
err_msg = (
f"{str(e)}. Please verify that the Function class name in the "
"implementation file matches the Function name."
f"{str(e)}. Please verify that the function class name in the "
"implementation file matches the function name."
)
logger.error(err_msg)
raise BinderError(err_msg)
Expand Down
4 changes: 2 additions & 2 deletions evadb/catalog/models/function_cache_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class FunctionCacheCatalog(BaseModel):
It maintains the following information for each cache entry:
`_row_id:` An autogenerated identifier for the cache entry.
`_name:` The name of the cache, also referred to as the unique Function signature.
`_function_id:` `_row_id` of the Function in the `FunctionCatalog` for which the cache is built.
`_name:` The name of the cache, also referred to as the unique function signature.
`_function_id:` `_row_id` of the function in the `FunctionCatalog` for which the cache is built.
`_args:` A serialized list of `ColumnCatalog` `_row_id`s for each argument of the
Function. If the argument is a function expression, it stores the string representation
of the expression tree.
Expand Down
2 changes: 1 addition & 1 deletion evadb/catalog/models/function_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FunctionCatalog(BaseModel):
"""The `FunctionCatalog` catalog stores information about the user-defined functions (Functions) in the system. It maintains the following information for each Function
`_row_id:` an autogenerated identifier
`_impl_file_path: ` the path to the implementation script for the Function
`_type:` an optional tag associated with the Function (useful for grouping similar Functions, such as multiple object detection Functions)
`_type:` an optional tag associated with the function (useful for grouping similar Functions, such as multiple object detection Functions)
"""

__tablename__ = "function_catalog"
Expand Down
6 changes: 3 additions & 3 deletions evadb/catalog/services/function_cache_catalog_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def insert_entry(
"""Insert a new function cache entry into function cache catalog.
Arguments:
`name` (str): name of the cache table
`function_id` (int): `row_id` of the Function on which the cache is built
`function_id` (int): `row_id` of the function on which the cache is built
`cache_path` (str): path of the cache table
`args` (List[Any]): arguments of the Function whose output is being cached
`function_depends` (List[FunctionCatalogEntry]): dependent Function entries
`args` (List[Any]): arguments of the function whose output is being cached
`function_depends` (List[FunctionCatalogEntry]): dependent function entries
`col_depends` (List[ColumnCatalogEntry]): dependent column entries
Returns:
`FunctionCacheCatalogEntry`
Expand Down
4 changes: 2 additions & 2 deletions evadb/catalog/services/function_io_catalog_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_input_entries_by_function_id(
)
return [obj.as_dataclass() for obj in result]
except Exception as e:
error = f"Getting inputs for Function id {function_id} raised {e}"
error = f"Getting inputs for function id {function_id} raised {e}"
logger.error(error)
raise RuntimeError(error)

Expand All @@ -65,7 +65,7 @@ def get_output_entries_by_function_id(
)
return [obj.as_dataclass() for obj in result]
except Exception as e:
error = f"Getting outputs for Function id {function_id} raised {e}"
error = f"Getting outputs for function id {function_id} raised {e}"
logger.error(error)
raise RuntimeError(error)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def get_entries_by_function_id(
)
return [obj.as_dataclass() for obj in result]
except Exception as e:
error = f"Getting metadata entries for Function id {function_id} raised {e}"
error = f"Getting metadata entries for function id {function_id} raised {e}"
logger.error(error)
raise CatalogError(error)
10 changes: 5 additions & 5 deletions evadb/executor/create_function_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def handle_ludwig_function(self):

assert (
len(self.children) == 1
), "Create ludwig Function expects 1 child, finds {}.".format(
), "Create ludwig function expects 1 child, finds {}.".format(
len(self.children)
)

Expand Down Expand Up @@ -211,10 +211,10 @@ def exec(self, *args, **kwargs):
def _try_initializing_function(
self, impl_path: str, function_args: Dict = {}
) -> FunctionCatalogEntry:
"""Attempts to initialize Function given the implementation file path and arguments.
"""Attempts to initialize function given the implementation file path and arguments.
Args:
impl_path (str): The file path of the Function implementation file.
impl_path (str): The file path of the function implementation file.
function_args (Dict, optional): Dictionary of arguments to pass to the Function. Defaults to {}.
Returns:
Expand Down Expand Up @@ -244,14 +244,14 @@ def _resolve_function_io(
It first searches for the input/outputs in the CREATE statement. If not found, it resolves them using decorators. If not found there as well, it raises an error.
Args:
function (FunctionCatalogEntry): The Function for which to resolve input and output definitions.
function (FunctionCatalogEntry): The function for which to resolve input and output definitions.
Returns:
A List of FunctionIOCatalogEntry objects that represent the resolved input and
output definitions for the Function.
Raises:
RuntimeError: If an error occurs while resolving the Function input/output
RuntimeError: If an error occurs while resolving the function input/output
definitions.
"""
io_list = []
Expand Down
2 changes: 1 addition & 1 deletion evadb/executor/create_index_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _create_index(self):
storage_engine = StorageEngine.factory(self.db, feat_catalog_entry)
for input_batch in storage_engine.read(feat_catalog_entry):
if self.node.function:
# Create index through Function expression.
# Create index through function expression.
# Function(input column) -> 2 dimension feature vector.
input_batch.modify_column_alias(feat_catalog_entry.name.lower())
feat_batch = self.node.function.evaluate(input_batch)
Expand Down
2 changes: 1 addition & 1 deletion evadb/expression/function_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def evaluate(self, batch: Batch, **kwargs) -> Batch:
self.consolidate_stats()
except Exception as e:
logger.warn(
f"Persisting Function Expression {str(self)} stats failed with {str(e)}"
f"Persisting FunctionExpression {str(self)} stats failed with {str(e)}"
)

return outcomes
Expand Down
2 changes: 1 addition & 1 deletion evadb/expression/tuple_value_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def signature(self):
"""It constructs the signature of the tuple value expression.
It assumes the col_object attribute is populated by the binder with the catalog
entries. For a standard column in the table, it returns `table_name.col_name`,
and for Function output columns it returns `function_name.col_name`
and for function output columns it returns `function_name.col_name`
Raises:
ValueError: If the col_object is not a `Union[ColumnCatalogEntry, FunctionIOCatalogEntry]`. This can occur if the expression has not been bound using the binder.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion evadb/functions/abstract/abstract_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def setup(self, *args, **kwargs) -> None:
@abstractmethod
def forward(self, frames: InputType) -> InputType:
"""
Implement Function function call by overriding this function.
Implement function function call by overriding this function.
Gets called automatically by __call__.
"""
pass
Expand Down
4 changes: 2 additions & 2 deletions evadb/functions/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class ChatGPT(AbstractFunction):
Example Usage:
Assume we have the transcripts for a few videos stored in a table 'video_transcripts' in a column named 'text'.
If the user wants to retrieve the summary of each video, the ChatGPT Function can be used as:
If the user wants to retrieve the summary of each video, the ChatGPT function can be used as:
query = "Generate the summary of the video"
cursor.table("video_transcripts").select(f"ChatGPT({query}, text)")
In the above Function invocation, the 'query' passed would be the user task to generate video summaries, and the
In the above function invocation, the 'query' passed would be the user task to generate video summaries, and the
'content' passed would be the video transcripts that need to be used in order to generate the summary. Since
no prompt is passed, the default system prompt will be used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class IOArgument(ABC):
"""
Base class for representing inputs/outputs (IO) of a Function using decorators. This class defines methods
Base class for representing inputs/outputs (IO) of a function using decorators. This class defines methods
that are common for all the IO arguments.
"""

Expand Down
28 changes: 14 additions & 14 deletions evadb/functions/function_bootstrap_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
fuzzy_function_query = """CREATE FUNCTION IF NOT EXISTS FuzzDistance
INPUT (Input_Array1 NDARRAY ANYTYPE, Input_Array2 NDARRAY ANYTYPE)
OUTPUT (distance FLOAT(32, 7))
TYPE NdarrayFUNCTION
TYPE NdarrayFunction
IMPL "{}/functions/{}/fuzzy_join.py";
""".format(
EvaDB_INSTALLATION_DIR, NDARRAY_DIR
Expand All @@ -62,7 +62,7 @@
IF NOT EXISTS ArrayCount
INPUT (Input_Array NDARRAY ANYTYPE, Search_Key ANYTYPE)
OUTPUT (key_count INTEGER)
TYPE NdarrayFUNCTION
TYPE NdarrayFunction
IMPL "{}/functions/{}/array_count.py";
""".format(
EvaDB_INSTALLATION_DIR, NDARRAY_DIR
Expand All @@ -72,7 +72,7 @@
INPUT (Frame_Array NDARRAY UINT8(3, ANYDIM, ANYDIM),
bboxes NDARRAY FLOAT32(ANYDIM, 4))
OUTPUT (Cropped_Frame_Array NDARRAY UINT8(3, ANYDIM, ANYDIM))
TYPE NdarrayFUNCTION
TYPE NdarrayFunction
IMPL "{}/functions/{}/crop.py";
""".format(
EvaDB_INSTALLATION_DIR, NDARRAY_DIR
Expand All @@ -81,7 +81,7 @@
Open_function_query = """CREATE FUNCTION IF NOT EXISTS Open
INPUT (img_path TEXT(1000))
OUTPUT (data NDARRAY UINT8(3, ANYDIM, ANYDIM))
TYPE NdarrayFUNCTION
TYPE NdarrayFunction
IMPL "{}/functions/{}/open.py";
""".format(
EvaDB_INSTALLATION_DIR, NDARRAY_DIR
Expand All @@ -92,7 +92,7 @@
Frame_Array_Base NDARRAY UINT8(3, ANYDIM, ANYDIM),
Feature_Extractor_Name TEXT(100))
OUTPUT (distance FLOAT(32, 7))
TYPE NdarrayFUNCTION
TYPE NdarrayFunction
IMPL "{}/functions/{}/similarity.py";
""".format(
EvaDB_INSTALLATION_DIR, NDARRAY_DIR
Expand All @@ -101,7 +101,7 @@
Unnest_function_query = """CREATE FUNCTION IF NOT EXISTS Unnest
INPUT (inp NDARRAY ANYTYPE)
OUTPUT (out ANYTYPE)
TYPE NdarrayFUNCTION
TYPE NdarrayFunction
IMPL "{}/functions/{}/unnest.py";
""".format(
EvaDB_INSTALLATION_DIR, NDARRAY_DIR
Expand Down Expand Up @@ -190,15 +190,15 @@


def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
"""Load the built-in FUNCTIONs into the system during system bootstrapping.
"""Load the built-in functions into the system during system bootstrapping.
The function loads a set of pre-defined FUNCTION queries based on the `mode` argument.
In 'debug' mode, the function loads debug FUNCTIONs along with release FUNCTIONs.
In 'release' mode, only release FUNCTIONs are loaded. In addition, in 'debug' mode,
The function loads a set of pre-defined function queries based on the `mode` argument.
In 'debug' mode, the function loads debug functions along with release functions.
In 'release' mode, only release functions are loaded. In addition, in 'debug' mode,
the function loads a smaller model to accelerate the test suite time.
Args:
mode (str, optional): The mode for loading FUNCTIONs, either 'debug' or 'release'.
mode (str, optional): The mode for loading functions, either 'debug' or 'release'.
Defaults to 'debug'.
"""
Expand All @@ -219,7 +219,7 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
os.environ["TOKENIZERS_PARALLELISM"] = "false"

# list of FUNCTION queries to load
# list of function queries to load
queries = [
mnistcnn_function_query,
Fastrcnn_function_query,
Expand All @@ -235,7 +235,7 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
Yolo_function_query,
]

# if mode is 'debug', add debug FUNCTIONs
# if mode is 'debug', add debug functions
if mode == "debug":
queries.extend(
[
Expand All @@ -245,7 +245,7 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
]
)

# execute each query in the list of FUNCTION queries
# execute each query in the list of function queries
# ignore exceptions during the bootstrapping phase due to missing packages
for query in queries:
try:
Expand Down
Loading

0 comments on commit 1589f9b

Please sign in to comment.