zhongjiajie commented on code in PR #11626:
URL: https://github.com/apache/dolphinscheduler/pull/11626#discussion_r956535743
##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/java_gateway.py:
##########
@@ -75,6 +78,21 @@ def __init__(
auto_convert: Optional[bool] = True,
):
self.java_gateway = launch_gateway(address, port, auto_convert)
+ gateway_version = self.get_gateway_version()
+ if gateway_version is not None and gateway_version != __version__:
+ logger.critical(
+ f"Using unmatched version of pydolphinscheduler (version
{__version__}) "
+ f"and Java gateway (version {gateway_version}) may cause
errors. "
+ "We strongly recommend you to find the matched version "
+ "(check: https://pypi.org/project/apache-dolphinscheduler)"
+ )
Review Comment:
BTW, can you add this check to our integration test?
https://github.com/apache/dolphinscheduler/blob/5289b09817396046489b28857ad54a85c5ffddb2/dolphinscheduler-python/pydolphinscheduler/tests/integration/test_java_gateway.py#L53
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java:
##########
@@ -575,6 +575,14 @@ public Resource queryResourcesFileInfo(String userName,
String fullName) {
return resourceService.queryResourcesFileInfo(userName, fullName);
}
+ /**
Review Comment:
Yeah, I think we should remove issue link too, but I personally do not mind
add comment or not
##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/java_gateway.py:
##########
@@ -75,6 +78,21 @@ def __init__(
auto_convert: Optional[bool] = True,
):
self.java_gateway = launch_gateway(address, port, auto_convert)
+ gateway_version = self.get_gateway_version()
+ if gateway_version is not None and gateway_version != __version__:
+ logger.critical(
+ f"Using unmatched version of pydolphinscheduler (version
{__version__}) "
+ f"and Java gateway (version {gateway_version}) may cause
errors. "
+ "We strongly recommend you to find the matched version "
+ "(check: https://pypi.org/project/apache-dolphinscheduler)"
+ )
+
+ def get_gateway_version(self):
+ """Get the java gateway version, expected to be equal with
pydolphinscheduler."""
+ try:
+ return self.java_gateway.entry_point.getGatewayVersion()
+ except Exception:
+ return None
Review Comment:
I do not think return `None` is a god idea, maybe we should raise error
directly, WDTY
```py
def get_gateway_version(self):
"""Get the java gateway version, expected to be equal with
pydolphinscheduler."""
return self.java_gateway.entry_point.getGatewayVersion()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]