Abacn commented on code in PR #35803:
URL: https://github.com/apache/beam/pull/35803#discussion_r2270670977
##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -384,22 +384,14 @@ 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:
- return True
- else:
+ # 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
+ # Return error message when not found (or handle according to business
logic)
+ return NotAvailableWithReason('Unable to locate java executable: java
not found in PATH')
Review Comment:
```suggestion
# 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
# Return error message when not found (or handle according to business
logic)
return NotAvailableWithReason('Unable to locate java executable: java
not found in PATH')
```
```suggestion
# 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
# Return error message when not found
return NotAvailableWithReason(
'Unable to locate java executable: java not found in PATH or
JAVA_HOME')
```
--
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]