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

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 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/catalog/services/udf_cache_catalog_service.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
from sqlalchemy.orm import Session
×
16
from sqlalchemy.orm.exc import NoResultFound
×
17
from sqlalchemy.sql.expression import select
×
18

19
from evadb.catalog.models.udf_cache_catalog import UdfCacheCatalog
×
20
from evadb.catalog.models.utils import UdfCacheCatalogEntry
×
21
from evadb.catalog.services.base_service import BaseService
×
22
from evadb.catalog.services.column_catalog_service import ColumnCatalogService
×
23
from evadb.catalog.services.udf_catalog_service import UdfCatalogService
×
24
from evadb.utils.errors import CatalogError
×
25
from evadb.utils.logging_manager import logger
×
26

27

28
class UdfCacheCatalogService(BaseService):
×
29
    def __init__(self, db_session: Session):
×
30
        super().__init__(UdfCacheCatalog, db_session)
×
31
        self._column_service: ColumnCatalogService = ColumnCatalogService(db_session)
×
32
        self._udf_service: UdfCatalogService = UdfCatalogService(db_session)
×
33

34
    def insert_entry(self, entry: UdfCacheCatalogEntry) -> UdfCacheCatalogEntry:
×
35
        """Insert a new udf cache entry into udf cache catalog.
36
        Arguments:
37
            `name` (str): name of the cache table
38
            `udf_id` (int): `row_id` of the UDF on which the cache is built
39
            `cache_path` (str): path of the cache table
40
            `args` (List[Any]): arguments of the UDF whose output is being cached
41
            `udf_depends` (List[UdfCatalogEntry]): dependent UDF  entries
42
            `col_depends` (List[ColumnCatalogEntry]): dependent column entries
43
        Returns:
44
            `UdfCacheCatalogEntry`
45
        """
46
        try:
×
47
            cache_obj = self.model(
×
48
                name=entry.name,
49
                udf_id=entry.udf_id,
50
                cache_path=entry.cache_path,
51
                args=entry.args,
52
            )
53

54
            cache_obj._udf_depends = [
×
55
                self._udf_service.get_entry_by_id(udf_id, return_alchemy=True)
56
                for udf_id in entry.udf_depends
57
            ]
58
            cache_obj._col_depends = [
×
59
                self._column_service.get_entry_by_id(col_id, return_alchemy=True)
60
                for col_id in entry.col_depends
61
            ]
62
            cache_obj = cache_obj.save(self.session)
×
63

64
        except Exception as e:
65
            err_msg = (
66
                f"Failed to insert entry into udf cache catalog with exception {str(e)}"
67
            )
68
            logger.exception(err_msg)
69
            raise CatalogError(err_msg)
70
        else:
71
            return cache_obj.as_dataclass()
×
72

73
    def get_entry_by_name(self, name: str) -> UdfCacheCatalogEntry:
×
74
        try:
×
75
            entry = self.session.execute(
×
76
                select(self.model).filter(self.model._name == name)
77
            ).scalar_one()
78
            return entry.as_dataclass()
×
79
        except NoResultFound:
80
            return None
81

82
    def delete_entry(self, cache: UdfCacheCatalogEntry):
×
83
        """Delete cache table from the db
84
        Arguments:
85
            cache  (UdfCacheCatalogEntry): cache to delete
86
        Returns:
87
            True if successfully removed else false
88
        """
89
        try:
×
90
            obj = self.session.execute(
×
91
                select(self.model).filter(self.model._row_id == cache.row_id)
92
            ).scalar_one()
93
            obj.delete(self.session)
×
94
            return True
×
95
        except Exception as e:
96
            err_msg = f"Delete cache failed for {cache} with error {str(e)}."
97
            logger.exception(err_msg)
98
            raise CatalogError(err_msg)
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

© 2025 Coveralls, Inc