From 8ad7d9fc8e282e4315cd5f9f4403ad3d581514e0 Mon Sep 17 00:00:00 2001 From: Aayush Acharya Date: Thu, 25 Jan 2024 08:06:08 +0545 Subject: [PATCH] feat: function catalog service to fetch function entries by type --- evadb/catalog/catalog_manager.py | 14 ++++++++++++++ .../services/function_catalog_service.py | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/evadb/catalog/catalog_manager.py b/evadb/catalog/catalog_manager.py index 70d3e0acff..a788c30400 100644 --- a/evadb/catalog/catalog_manager.py +++ b/evadb/catalog/catalog_manager.py @@ -515,6 +515,20 @@ def get_function_catalog_entry_by_name(self, name: str) -> FunctionCatalogEntry: """ return self._function_service.get_entry_by_name(name) + def get_function_catalog_entries_by_type( + self, type: str + ) -> List[FunctionCatalogEntry]: + """ + Get function information based on type. + + Arguments: + type (str): type of the function + + Returns: + List of FunctionCatalogEntry object + """ + return self._function_service.get_entries_by_type(type) + def delete_function_catalog_entry_by_name(self, function_name: str) -> bool: return self._function_service.delete_entry_by_name(function_name) diff --git a/evadb/catalog/services/function_catalog_service.py b/evadb/catalog/services/function_catalog_service.py index 0c6c272d3c..c1244da1ba 100644 --- a/evadb/catalog/services/function_catalog_service.py +++ b/evadb/catalog/services/function_catalog_service.py @@ -100,6 +100,24 @@ def get_entry_by_name(self, name: str) -> FunctionCatalogEntry: return function_obj.as_dataclass() return None + def get_entries_by_type(self, function_type: str) -> List[FunctionCatalogEntry]: + """returns the function entries that matches the type provided. + Empty list if no such entry found. + + Arguments: + type (str): name to be searched + """ + + entries = ( + self.session.execute( + select(self.model).filter(self.model._type == function_type) + ) + .scalars() + .all() + ) + + return [entry.as_dataclass() for entry in entries] + def get_entry_by_id(self, id: int, return_alchemy=False) -> FunctionCatalogEntry: """return the function entry that matches the id provided. None if no such entry found.