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

georgia-tech-db / eva / #844

31 Oct 2023 05:42AM UTC coverage: 0.0%. Remained the same
#844

push

circle-ci

Andy Xu
Fix typo

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

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

22

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

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

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

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

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

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.
56
        if not is_gpu_available():
×
57
            return []
×
58
        gpus = self._populate_gpu_from_config()
×
59
        if len(gpus) == 0:
×
60
            gpus = self._populate_gpu_from_env()
×
61
        return gpus
×
62

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

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
        """
77
        if self.gpus:
×
78
            # TODO: Should allow choosing GPU based on Spark and Horovod
79
            return self._select_random_gpu()
×
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