Abacn commented on code in PR #35803:
URL: https://github.com/apache/beam/pull/35803#discussion_r2270743205


##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -384,22 +384,15 @@ def __init__(
     self._classpath = classpath
 
   def available(self):
-    # pylint: disable=subprocess-run-check
-    trial = subprocess.run(['which', subprocess_server.JavaHelper.get_java()],
-                           capture_output=True)
-    if trial.returncode == 0:
+    # Directly use shutil.which to find the Java executable cross-platform
+    java_path = shutil.which(subprocess_server.JavaHelper.get_java())
+    if java_path:
       return True
-    else:
+    # Return error message when not found
+    return NotAvailableWithReason(
+        'Unable to locate java executable: java not found in PATH or 
JAVA_HOME')
 

Review Comment:
   ```suggestion
   ```



##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -384,22 +384,15 @@ def __init__(
     self._classpath = classpath
 
   def available(self):
-    # pylint: disable=subprocess-run-check
-    trial = subprocess.run(['which', subprocess_server.JavaHelper.get_java()],
-                           capture_output=True)
-    if trial.returncode == 0:
+    # Directly use shutil.which to find the Java executable cross-platform
+    java_path = shutil.which(subprocess_server.JavaHelper.get_java())
+    if java_path:
       return True
-    else:
+    # Return error message when not found
+    return NotAvailableWithReason(
+        'Unable to locate java executable: java not found in PATH or 
JAVA_HOME')
 
-      def try_decode(bs):
-        try:
-          return bs.decode()
-        except UnicodeError:
-          return bs
 

Review Comment:
   ```suggestion
   ```



-- 
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: github-unsubscr...@beam.apache.org

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

Reply via email to