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

georgia-tech-db / eva / #837

19 Oct 2023 09:02AM UTC coverage: 0.0% (-78.6%) from 78.632%
#837

push

circle-ci

Andy Xu
Add CostEntry

0 of 12416 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/functions/ndarray/open.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
import numpy as np
×
16
import pandas as pd
×
17

18
from evadb.functions.abstract.abstract_function import AbstractFunction
×
19
from evadb.utils.generic_utils import try_to_import_cv2
×
20

21

22
class Open(AbstractFunction):
×
23
    def setup(self):
×
24
        # cache data to avoid expensive open files on disk
25
        self._data_cache = dict()
×
26
        try_to_import_cv2()
×
27

28
    @property
×
29
    def name(self):
×
30
        return "Open"
×
31

32
    def forward(self, df: pd.DataFrame) -> pd.DataFrame:
×
33
        """
34
        Open image from server-side path.
35

36
        Returns:
37
            (pd.DataFrame): The opened image.
38
        """
39

40
        def _open(row: pd.Series) -> np.ndarray:
×
41
            path_str = row[0]
×
42
            if path_str in self._data_cache:
×
43
                data = self._data_cache[path_str]
×
44
            else:
45
                import cv2
×
46

47
                data = cv2.imread(path_str)
×
48
                assert data is not None, f"Failed to open file {path_str}"
×
49
            self._data_cache[path_str] = data
×
50

51
            return data
×
52

53
        ret = pd.DataFrame()
×
54
        ret["data"] = df.apply(_open, axis=1)
×
55
        return ret
×
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