dianfu commented on a change in pull request #11714: [FLINK-17114][python] Set 
the default value of 'python.executable' to the path of the python interpreter 
which launches the job when the job is executed by LocalExecutor.
URL: https://github.com/apache/flink/pull/11714#discussion_r407458530
 
 

 ##########
 File path: flink-python/pyflink/util/utils.py
 ##########
 @@ -57,3 +59,48 @@ def load_java_class(class_name):
     gateway = get_gateway()
     context_classloader = 
gateway.jvm.Thread.currentThread().getContextClassLoader()
     return context_classloader.loadClass(class_name)
+
+
+def is_instance_of(java_object, java_class):
+    gateway = get_gateway()
+    if isinstance(java_class, str):
+        param = java_class
+    elif isinstance(java_class, JavaClass):
+        param = get_java_class(java_class)
+    elif isinstance(java_class, JavaObject):
+        if not is_instance_of(java_class, gateway.jvm.Class):
+            param = java_class.getClass()
+        else:
+            param = java_class
+    else:
+        raise TypeError(
+            "java_class must be a string, a JavaClass, or a JavaObject")
+
+    return 
gateway.jvm.org.apache.flink.api.python.shaded.py4j.reflection.TypeUtil.isInstanceOf(
+        param, java_object)
+
+
+def get_j_env_configuration(t_env):
+    if is_instance_of(t_env._get_j_env(), 
"org.apache.flink.api.java.ExecutionEnvironment"):
+        j_configuration = t_env._get_j_env().getConfiguration()
+    else:
+        env_clazz = load_java_class(
+            
"org.apache.flink.streaming.api.environment.StreamExecutionEnvironment")
+        method = env_clazz.getDeclaredMethod(
+            "getConfiguration", to_jarray(get_gateway().jvm.Class, []))
+        method.setAccessible(True)
+        j_configuration = method.invoke(t_env._get_j_env(), 
to_jarray(get_gateway().jvm.Object, []))
+    return j_configuration
+
+
+def is_local_executor(j_env, j_configuration):
 
 Review comment:
   Does it work to check if j_configuration.get(DeploymentOptions.TARGET) 
equals to "local"?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to