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

georgia-tech-db / eva / 20a9a0f9-edcc-437c-815d-bcc1a2d22b17

10 Nov 2023 04:50AM UTC coverage: 66.644% (-10.2%) from 76.812%
20a9a0f9-edcc-437c-815d-bcc1a2d22b17

push

circleci

americast
update docs

0 of 1 new or added line in 1 file covered. (0.0%)

1354 existing lines in 113 files now uncovered.

8767 of 13155 relevant lines covered (66.64%)

0.67 hits per line

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

52.94
/evadb/executor/execution_context.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 os
1✔
16
import random
1✔
17
from typing import List
1✔
18

19
from evadb.constants import NO_GPU
1✔
20
from evadb.utils.generic_utils import get_gpu_count, is_gpu_available
1✔
21

22

23
class Context:
1✔
24
    """
25
    Stores the context information of the executor, i.e.,
26
    if using spark, name of the application, current spark executors,
27
    if using horovod: current rank etc.
28
    """
29

30
    def __init__(self, user_provided_gpu_conf=[]):
1✔
31
        self._user_provided_gpu_conf = user_provided_gpu_conf
1✔
32
        self._gpus = self._populate_gpu_ids()
1✔
33

34
    @property
1✔
35
    def gpus(self):
1✔
UNCOV
36
        return self._gpus
×
37

38
    def _populate_gpu_from_config(self) -> List:
1✔
UNCOV
39
        available_gpus = [i for i in range(get_gpu_count())]
×
UNCOV
40
        return list(set(available_gpus) & set(self._user_provided_gpu_conf))
×
41

42
    def _populate_gpu_from_env(self) -> List:
1✔
43
        # Populate GPU IDs from env variable.
UNCOV
44
        gpu_conf = map(
×
45
            lambda x: x.strip(),
46
            os.environ.get("CUDA_VISIBLE_DEVICES", "").strip().split(","),
47
        )
UNCOV
48
        gpu_conf = list(filter(lambda x: x, gpu_conf))
×
UNCOV
49
        gpu_conf = [int(gpu_id) for gpu_id in gpu_conf]
×
UNCOV
50
        available_gpus = [i for i in range(get_gpu_count())]
×
UNCOV
51
        return list(set(available_gpus) & set(gpu_conf))
×
52

53
    def _populate_gpu_ids(self) -> List:
1✔
54
        # Populate available GPU IDs from Torch library. Then, select subset of GPUs
55
        # from available GPUs based on user configuration.
56
        if not is_gpu_available():
1✔
57
            return []
1✔
UNCOV
58
        gpus = self._populate_gpu_from_config()
×
UNCOV
59
        if len(gpus) == 0:
×
UNCOV
60
            gpus = self._populate_gpu_from_env()
×
UNCOV
61
        return gpus
×
62

63
    def _select_random_gpu(self) -> str:
1✔
64
        """
65
        A random GPU selection strategy
66
        Returns:
67
            (str): GPU device ID
68
        """
UNCOV
69
        return random.choice(self.gpus)
×
70

71
    def gpu_device(self) -> str:
1✔
72
        """
73
        Selects a GPU on which the task can be executed
74
        Returns:
75
             (str): GPU device ID
76
        """
UNCOV
77
        if self.gpus:
×
78
            # TODO: Should allow choosing GPU based on Spark and Horovod
UNCOV
79
            return self._select_random_gpu()
×
UNCOV
80
        return NO_GPU
×
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