You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/08/27 16:15:44 UTC

[GitHub] [dolphinscheduler] HeZean commented on a diff in pull request #11626: [Improvement][Python API] Validate version of Python API and Java gateway at launch

HeZean commented on code in PR #11626:
URL: https://github.com/apache/dolphinscheduler/pull/11626#discussion_r956598699


##########
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:
   Thanks for the suggestion, the `try` clause is moved to __init__ cuz I think if there's a connection error or so, it could be more reasonable for user to get the error context from the method it intended to call.



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org