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

tableau / TabPy / 11959482446

21 Nov 2024 06:33PM UTC coverage: 57.75% (+0.1%) from 57.612%
11959482446

Pull #652

github

jakeichikawasalesforce
check windows 32 bit
Pull Request #652: Add capability to deploying models remotely

24 of 40 new or added lines in 4 files covered. (60.0%)

5 existing lines in 1 file now uncovered.

1427 of 2471 relevant lines covered (57.75%)

0.58 hits per line

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

59.38
/tabpy/tabpy_tools/custom_query_object.py
1
import inspect
1✔
2
import logging
1✔
3
import platform
1✔
4
import sys
1✔
5
from .query_object import QueryObject as _QueryObject
1✔
6

7

8
logger = logging.getLogger(__name__)
1✔
9

10

11
class CustomQueryObject(_QueryObject):
1✔
12
    def __init__(self, query, description=""):
1✔
13
        """Create a new CustomQueryObject.
14

15
        Parameters
16
        -----------
17

18
        query : function
19
            Function that defines a custom query method. The query can have any
20
            signature, but input and output of the query needs to be JSON
21
            serializable.
22

23
        description : str
24
            The description of the custom query object
25

26
        """
27
        super().__init__(description)
1✔
28

29
        self.custom_query = query
1✔
30

31
    def query(self, *args, **kwargs):
1✔
32
        """Query the custom defined query method using the given input.
33

34
        Parameters
35
        ----------
36
        args : list
37
            positional arguments to the query
38

39
        kwargs : dict
40
            keyword arguments to the query
41

42
        Returns
43
        -------
44
        out: object.
45
            The results depends on the implementation of the query method.
46
            Typically the return value will be whatever that function returns.
47

48
        See Also
49
        --------
50
        QueryObject
51
        """
52
        # include the dependent files in sys path so that the query can run
53
        # correctly
54

55
        try:
×
UNCOV
56
            logger.debug(
×
57
                "Running custom query with arguments " f"({args}, {kwargs})..."
58
            )
59
            ret = self.custom_query(*args, **kwargs)
×
60
        except Exception as e:
×
UNCOV
61
            logger.exception(
×
62
                "Exception hit when running custom query, error: " f"{str(e)}"
63
            )
UNCOV
64
            raise
×
65

66
        logger.debug(f"Received response {ret}")
×
67
        try:
×
68
            return self._make_serializable(ret)
×
69
        except Exception as e:
×
UNCOV
70
            logger.exception(
×
71
                "Cannot properly serialize custom query result, " f"error: {str(e)}"
72
            )
UNCOV
73
            raise
×
74

75
    def get_doc_string(self):
1✔
76
        """Get doc string from customized query"""
77
        default_docstring = "-- no docstring found in query function --"
1✔
78
        if platform.system() == "Windows" and sys.maxsize <= 2**32:
1✔
NEW
79
            return default_docstring
×
80
        else:
81
            return inspect.getdoc(self.custom_query) or default_docstring
1✔
82

83
    def get_methods(self):
1✔
84
        return [self.get_query_method()]
1✔
85

86
    def get_query_method(self):
1✔
87
        return {"method": "query"}
1✔
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

© 2025 Coveralls, Inc