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

tableau / TabPy / 7389403568

02 Jan 2024 06:49PM UTC coverage: 57.586%. Remained the same
7389403568

Pull #628

github

web-flow
Update server-install.md

Add 3.10 to list of supported python versions
Pull Request #628: Update server-install.md

1355 of 2353 relevant lines covered (57.59%)

0.58 hits per line

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

46.43
/tabpy/tabpy_tools/custom_query_object.py
1
import logging
1✔
2
from .query_object import QueryObject as _QueryObject
1✔
3

4

5
logger = logging.getLogger(__name__)
1✔
6

7

8
class CustomQueryObject(_QueryObject):
1✔
9
    def __init__(self, query, description=""):
1✔
10
        """Create a new CustomQueryObject.
11

12
        Parameters
13
        -----------
14

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

20
        description : str
21
            The description of the custom query object
22

23
        """
24
        super().__init__(description)
1✔
25

26
        self.custom_query = query
1✔
27

28
    def query(self, *args, **kwargs):
1✔
29
        """Query the custom defined query method using the given input.
30

31
        Parameters
32
        ----------
33
        args : list
34
            positional arguments to the query
35

36
        kwargs : dict
37
            keyword arguments to the query
38

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

45
        See Also
46
        --------
47
        QueryObject
48
        """
49
        # include the dependent files in sys path so that the query can run
50
        # correctly
51

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

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

72
    def get_doc_string(self):
1✔
73
        """Get doc string from customized query"""
74
        if self.custom_query.__doc__ is not None:
×
75
            return self.custom_query.__doc__
×
76
        else:
77
            return "-- no docstring found in query function --"
×
78

79
    def get_methods(self):
1✔
80
        return [self.get_query_method()]
1✔
81

82
    def get_query_method(self):
1✔
83
        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