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


##########
sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/PythonExternalTransform.java:
##########
@@ -447,30 +450,63 @@ public OutputT expand(InputT input) {
             15000);
         return apply(input, expansionService, payload);
       } else {
+        OutputT output = null;
         int port = PythonService.findAvailablePort();
-        ImmutableList.Builder<String> args = ImmutableList.builder();
-        args.add("--port=" + port, "--fully_qualified_name_glob=*", 
"--pickle_library=cloudpickle");
-        if (!extraPackages.isEmpty()) {
-          File requirementsFile = File.createTempFile("requirements", ".txt");
-          requirementsFile.deleteOnExit();
-          try (Writer fout =
-              new OutputStreamWriter(
-                  new FileOutputStream(requirementsFile.getAbsolutePath()), 
Charsets.UTF_8)) {
-            for (String pkg : extraPackages) {
-              fout.write(pkg);
-              fout.write('\n');
+        PipelineOptionsFactory.register(PythonExternalTransformOptions.class);
+        if (input
+            .getPipeline()
+            .getOptions()
+            .as(PythonExternalTransformOptions.class)
+            .getUseTransformService()) {
+          // A unique project name ensures that this expansion gets a 
dedicated instance of the
+          // transform service.
+          String projectName = UUID.randomUUID().toString();
+          TransformServiceLauncher service = 
TransformServiceLauncher.forProject(projectName, port);
+          service.setBeamVersion(ReleaseInfo.getReleaseInfo().getSdkVersion());
+          // TODO: add support for installing extra packages.

Review Comment:
   Thanks!



-- 
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]

Reply via email to