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

georgia-tech-db / eva / #850

08 Nov 2023 08:36PM UTC coverage: 0.0% (-77.0%) from 76.982%
#850

push

circleci

americast
fix metrics logic

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

9789 existing lines in 252 files now uncovered.

0 of 12428 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/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.
UNCOV
15
import os
×
UNCOV
16
import random
×
UNCOV
17
from typing import List
×
18

UNCOV
19
from evadb.constants import NO_GPU
×
UNCOV
20
from evadb.utils.generic_utils import get_gpu_count, is_gpu_available
×
21

22

UNCOV
23
class Context:
×
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

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

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

UNCOV
38
    def _populate_gpu_from_config(self) -> List:
×
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

UNCOV
42
    def _populate_gpu_from_env(self) -> List:
×
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

UNCOV
53
    def _populate_gpu_ids(self) -> List:
×
54
        # Populate available GPU IDs from Torch library. Then, select subset of GPUs
55
        # from available GPUs based on user configuration.
UNCOV
56
        if not is_gpu_available():
×
UNCOV
57
            return []
×
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

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

UNCOV
71
    def gpu_device(self) -> str:
×
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