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

georgia-tech-db / eva / fe18e2d7-2051-40bf-a90c-3280a55f3612

pending completion
fe18e2d7-2051-40bf-a90c-3280a55f3612

Pull #622

circle-ci

jarulraj
checkpoint
Pull Request #622: feat: sqlalchemy tests

10 of 10 new or added lines in 2 files covered. (100.0%)

8846 of 9049 relevant lines covered (97.76%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.29
/eva/executor/executor_utils.py
1
# coding=utf-8
2
# Copyright 2018-2022 EVA
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
import glob
1✔
16
import os
1✔
17
from pathlib import Path
1✔
18
from typing import Generator, List
1✔
19

20
import cv2
1✔
21

22
from eva.catalog.catalog_manager import CatalogManager
1✔
23
from eva.expression.abstract_expression import AbstractExpression
1✔
24
from eva.models.storage.batch import Batch
1✔
25
from eva.parser.table_ref import TableInfo
1✔
26
from eva.parser.types import FileFormatType
1✔
27
from eva.utils.logging_manager import logger
1✔
28

29

30
class ExecutorError(Exception):
1✔
31
    pass
1✔
32

33

34
def apply_project(batch: Batch, project_list: List[AbstractExpression]):
1✔
35
    if not batch.empty() and project_list:
1✔
36
        batches = [expr.evaluate(batch) for expr in project_list]
1✔
37
        batch = Batch.merge_column_wise(batches)
1✔
38
    return batch
1✔
39

40

41
def apply_predicate(batch: Batch, predicate: AbstractExpression) -> Batch:
1✔
42
    if not batch.empty() and predicate is not None:
1✔
43
        outcomes = predicate.evaluate(batch)
1✔
44
        batch.drop_zero(outcomes)
1✔
45
        batch.reset_index()
1✔
46
    return batch
1✔
47

48

49
def handle_if_not_exists(table_info: TableInfo, if_not_exist=False):
1✔
50
    if CatalogManager().check_table_exists(
1✔
51
        table_info.table_name,
52
        table_info.database_name,
53
    ):
54
        err_msg = "Table: {} already exists".format(table_info)
1✔
55
        if if_not_exist:
1✔
56
            logger.warn(err_msg)
1✔
57
            return True
1✔
58
        else:
59
            logger.error(err_msg)
1✔
60
            raise ExecutorError(err_msg)
1✔
61
    else:
62
        return False
1✔
63

64

65
def validate_image(image_path: Path) -> bool:
1✔
66
    try:
1✔
67
        data = cv2.imread(str(image_path))
1✔
68
        return data is not None
1✔
69
    except Exception as e:
×
70
        logger.warning(
×
71
            f"Unexpected Exception {e} occured while reading image file {image_path}"
72
        )
73
        return False
×
74

75

76
def iter_path_regex(path_regex: Path) -> Generator[str, None, None]:
1✔
77
    return glob.iglob(os.path.expanduser(path_regex), recursive=True)
1✔
78

79

80
def validate_video(video_path: Path) -> bool:
1✔
81
    try:
1✔
82
        vid = cv2.VideoCapture(str(video_path))
1✔
83
        if not vid.isOpened():
1✔
84
            return False
1✔
85
        return True
1✔
86
    except Exception as e:
×
87
        logger.warning(
×
88
            f"Unexpected Exception {e} occured while reading video file {video_path}"
89
        )
90

91

92
def validate_media(file_path: Path, media_type: FileFormatType) -> bool:
1✔
93
    if media_type == FileFormatType.VIDEO:
1✔
94
        return validate_video(file_path)
1✔
95
    elif media_type == FileFormatType.IMAGE:
1✔
96
        return validate_image(file_path)
1✔
97
    else:
98
        raise ValueError(f"Unsupported Media type {str(media_type)}")
×
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

© 2026 Coveralls, Inc