From ecbdb1aa8d3b40eebd8d4fc85bb4f5f7075c5460 Mon Sep 17 00:00:00 2001 From: Parker Erickson Date: Sun, 21 Apr 2024 10:45:31 -0500 Subject: [PATCH] fix(query description): add version check --- pyTigerGraph/pyTigerGraphQuery.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/pyTigerGraph/pyTigerGraphQuery.py b/pyTigerGraph/pyTigerGraphQuery.py index 2b05e693..9759cb1d 100644 --- a/pyTigerGraph/pyTigerGraphQuery.py +++ b/pyTigerGraph/pyTigerGraphQuery.py @@ -593,7 +593,7 @@ def getStatistics(self, seconds: int = 10, segments: int = 10) -> dict: return ret def describeQuery(self, queryName: str, queryDescription: str, parameterDescriptions: dict = {}): - """Add a query description and parameter descriptions. + """Add a query description and parameter descriptions. Only supported on versions of TigerGraph >= 4.0.0. Args: queryName: @@ -607,6 +607,11 @@ def describeQuery(self, queryName: str, queryDescription: str, parameterDescript The response from the database. """ logger.info("entry: describeQuery") + self.ver =self.conn.getVer() + major_ver, minor_ver, patch_ver = self.ver.split(".") + if int(major_ver) < 4: + logger.info("exit: describeQuery") + raise TigerGraphException("This function is only supported on versions of TigerGraph >= 4.0.0.", 0) if parameterDescriptions: params = {"queries": [ @@ -630,7 +635,7 @@ def describeQuery(self, queryName: str, queryDescription: str, parameterDescript return res def getQueryDescription(self, queryName: Optional[Union[str, list]] = "all"): - """Get the description of a query. + """Get the description of a query. Only supported on versions of TigerGraph >= 4.0.0. Args: queryName: @@ -642,6 +647,12 @@ def getQueryDescription(self, queryName: Optional[Union[str, list]] = "all"): The description of the query(ies). """ logger.info("entry: getQueryDescription") + self.ver =self.conn.getVer() + major_ver, minor_ver, patch_ver = self.ver.split(".") + if int(major_ver) < 4: + logger.info("exit: getQueryDescription") + raise TigerGraphException("This function is only supported on versions of TigerGraph >= 4.0.0.", 0) + if logger.level == logging.DEBUG: logger.debug("params: " + self._locals(locals())) @@ -657,7 +668,7 @@ def getQueryDescription(self, queryName: Optional[Union[str, list]] = "all"): raise TigerGraphException(res["message"], res["code"]) def dropQueryDescription(self, queryName: str, dropParamDescriptions: bool = True): - """Drop the description of a query. + """Drop the description of a query. Only supported on versions of TigerGraph >= 4.0.0. Args: queryName: @@ -670,6 +681,12 @@ def dropQueryDescription(self, queryName: str, dropParamDescriptions: bool = Tru The response from the database. """ logger.info("entry: dropQueryDescription") + self.ver =self.conn.getVer() + major_ver, minor_ver, patch_ver = self.ver.split(".") + if int(major_ver) < 4: + logger.info("exit: describeQuery") + raise TigerGraphException("This function is only supported on versions of TigerGraph >= 4.0.0.", 0) + if logger.level == logging.DEBUG: logger.debug("params: " + self._locals(locals())) if dropParamDescriptions: