Skip to content

Commit

Permalink
GML-1660 use the gerVer() to get dbversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Lu Zhou authored and Lu Zhou committed May 10, 2024
1 parent 5537745 commit b584eb2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyTigerGraph/pyTigerGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, host: str = "http://127.0.0.1", graphname: str = "MyGraph",
apiToken: str = "", useCert: bool = None, certPath: str = None, debug: bool = None,
sslPort: Union[int, str] = "443", gcp: bool = False, jwtToken: str = "", dbVersion: str = ""):
super().__init__(host, graphname, gsqlSecret, username, password, tgCloud, restppPort,
gsPort, gsqlVersion, version, apiToken, useCert, certPath, debug, sslPort, gcp, jwtToken, dbVersion)
gsPort, gsqlVersion, version, apiToken, useCert, certPath, debug, sslPort, gcp, jwtToken)

self.gds = None
self.ai = None
Expand Down
7 changes: 3 additions & 4 deletions pyTigerGraph/pyTigerGraphBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, host: str = "http://127.0.0.1", graphname: str = "MyGraph",
tgCloud: bool = False, restppPort: Union[int, str] = "9000",
gsPort: Union[int, str] = "14240", gsqlVersion: str = "", version: str = "",
apiToken: str = "", useCert: bool = None, certPath: str = None, debug: bool = None,
sslPort: Union[int, str] = "443", gcp: bool = False, jwtToken: str = "", dbVersion: str = ""):
sslPort: Union[int, str] = "443", gcp: bool = False, jwtToken: str = ""):
"""Initiate a connection object.
Args:
Expand Down Expand Up @@ -78,8 +78,6 @@ def __init__(self, host: str = "http://127.0.0.1", graphname: str = "MyGraph",
DEPRECATED. Previously used for connecting to databases provisioned on GCP in TigerGraph Cloud.
jwtToken:
The JWT token generated from customer side for authentication
dbVersion:
The TigerGraph database version being connected to.
Raises:
TigerGraphException: In case on invalid URL scheme.
Expand Down Expand Up @@ -130,7 +128,8 @@ def __init__(self, host: str = "http://127.0.0.1", graphname: str = "MyGraph",

# If JWT token is provided, set authMode to "token", and overwrite authMode = "pwd" for GSQL authentication as well if version is newer than 4.1.0
if jwtToken:
if dbVersion and StrictVersion(dbVersion) >= StrictVersion("4.1.0"):
dbVersion = self.getVer()
if StrictVersion(dbVersion) >= StrictVersion("4.1.0"):
self.authMode = "token"
self.jwtToken = jwtToken
self.authHeader = {"Authorization": "Bearer " + self.jwtToken}
Expand Down
6 changes: 2 additions & 4 deletions tests/pyTigerGraphUnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def make_connection(graphname: str = None):
"sslPort": "443",
"tgCloud": False,
"gcp": False,
"jwtToken": "",
"dbVersion": ""
"jwtToken": ""
}

path = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -44,8 +43,7 @@ def make_connection(graphname: str = None):
certPath=server_config["certPath"],
sslPort=server_config["sslPort"],
gcp=server_config["gcp"],
jwtToken=server_config["jwtToken"],
dbVersion=server_config["dbVersion"]
jwtToken=server_config["jwtToken"]
)
if server_config.get("getToken", False):
conn.getToken(conn.createSecret())
Expand Down

0 comments on commit b584eb2

Please sign in to comment.