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

georgia-tech-db / eva / 5620399e-164a-4d84-881f-2811dab7715c

18 Aug 2023 06:49AM UTC coverage: 94.865% (-0.4%) from 95.277%
5620399e-164a-4d84-881f-2811dab7715c

Pull #935

circle-ci

xzdandy
pydantic conflict with ray
Pull Request #935: Ludwig-based model train and tune support.

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

10308 of 10866 relevant lines covered (94.86%)

2.83 hits per line

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

98.39
/evadb/parser/create_udf_statement.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
from pathlib import Path
3✔
16
from typing import List, Tuple
3✔
17

18
from evadb.parser.create_statement import ColumnDefinition
3✔
19
from evadb.parser.select_statement import SelectStatement
3✔
20
from evadb.parser.statement import AbstractStatement
3✔
21
from evadb.parser.types import StatementType
3✔
22

23

24
class CreateUDFStatement(AbstractStatement):
3✔
25
    """Create UDF Statement constructed after parsing the input query
26

27
    Attributes:
28
        name: str
29
            udf_name provided by the user required
30
        if_not_exists: bool
31
            if true should throw an error if udf with same name exists
32
            else will replace the existing
33
        inputs: List[ColumnDefinition]
34
            udf inputs, represented similar to a table column definition
35
        outputs: List[ColumnDefinition]
36
            udf outputs, represented similar to a table column definition
37
        impl_file_path: str
38
            file path which holds the implementation of the udf.
39
            This file should be placed in the UDF directory and
40
            the path provided should be relative to the UDF dir.
41
        query: SelectStatement
42
            data source for the model train or fine tune.
43
        udf_type: str
44
            udf type. it can be object detection, classification etc.
45
        metadata: List[Tuple[str, str]]
46
            metadata, list of key value pairs used for storing metadata of udfs, mostly used for advanced udf types
47
    """
48

49
    def __init__(
3✔
50
        self,
51
        name: str,
52
        if_not_exists: bool,
53
        impl_path: str,
54
        inputs: List[ColumnDefinition] = [],
55
        outputs: List[ColumnDefinition] = [],
56
        udf_type: str = None,
57
        query: SelectStatement = None,
58
        metadata: List[Tuple[str, str]] = None,
59
    ):
60
        super().__init__(StatementType.CREATE_UDF)
3✔
61
        self._name = name
3✔
62
        self._if_not_exists = if_not_exists
3✔
63
        self._inputs = inputs
3✔
64
        self._outputs = outputs
3✔
65
        self._impl_path = Path(impl_path) if impl_path else None
3✔
66
        self._udf_type = udf_type
3✔
67
        self._query = query
3✔
68
        self._metadata = metadata
3✔
69

70
    def __str__(self) -> str:
3✔
71
        s = "CREATE UDF"
3✔
72

73
        if self._if_not_exists:
3✔
74
            s += " IF NOT EXISTS"
3✔
75

76
        s += " " + self._name
3✔
77

78
        if self._query is not None:
3✔
79
            s += f" FROM ({self._query})"
×
80

81
        if self._udf_type is not None:
3✔
82
            s += " TYPE " + str(self._udf_type)
3✔
83

84
        if self._impl_path:
3✔
85
            s += f" IMPL {self._impl_path.name}"
3✔
86

87
        if self._metadata is not None:
3✔
88
            for key, value in self._metadata:
3✔
89
                s += f" '{key}' '{value}'"
3✔
90
        return s
3✔
91

92
    @property
3✔
93
    def name(self):
3✔
94
        return self._name
3✔
95

96
    @property
3✔
97
    def if_not_exists(self):
3✔
98
        return self._if_not_exists
3✔
99

100
    @property
3✔
101
    def inputs(self):
3✔
102
        return self._inputs
3✔
103

104
    @property
3✔
105
    def outputs(self):
3✔
106
        return self._outputs
3✔
107

108
    @property
3✔
109
    def impl_path(self):
3✔
110
        return self._impl_path
3✔
111

112
    @property
3✔
113
    def udf_type(self):
3✔
114
        return self._udf_type
3✔
115

116
    @property
3✔
117
    def query(self):
3✔
118
        return self._query
3✔
119

120
    @property
3✔
121
    def metadata(self):
3✔
122
        return self._metadata
3✔
123

124
    def __eq__(self, other):
3✔
125
        if not isinstance(other, CreateUDFStatement):
3✔
126
            return False
3✔
127
        return (
3✔
128
            self.name == other.name
129
            and self.if_not_exists == other.if_not_exists
130
            and self.inputs == other.inputs
131
            and self.outputs == other.outputs
132
            and self.impl_path == other.impl_path
133
            and self.udf_type == other.udf_type
134
            and self.query == other.query
135
            and self.metadata == other.metadata
136
        )
137

138
    def __hash__(self) -> int:
3✔
139
        return hash(
3✔
140
            (
141
                super().__hash__(),
142
                self.name,
143
                self.if_not_exists,
144
                tuple(self.inputs),
145
                tuple(self.outputs),
146
                self.impl_path,
147
                self.udf_type,
148
                self.query,
149
                tuple(self.metadata),
150
            )
151
        )
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