[ 
https://issues.apache.org/jira/browse/BEAM-12792?focusedWorklogId=737058&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-737058
 ]

ASF GitHub Bot logged work on BEAM-12792:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Mar/22 10:12
            Start Date: 05/Mar/22 10:12
    Worklog Time Spent: 10m 
      Work Description: phoerious commented on a change in pull request #16658:
URL: https://github.com/apache/beam/pull/16658#discussion_r820078447



##########
File path: sdks/python/container/boot.go
##########
@@ -210,15 +224,37 @@ func main() {
        wg.Add(len(workerIds))
        for _, workerId := range workerIds {
                go func(workerId string) {
-                       log.Printf("Executing: python %v", strings.Join(args, " 
"))
-                       log.Fatalf("Python exited: %v", 
execx.ExecuteEnv(map[string]string{"WORKER_ID": workerId}, "python", args...))
-                       wg.Done()
+                       defer wg.Done()
+                       log.Printf("Executing Python (worker %v): python %v", 
workerId, strings.Join(args, " "))
+                       log.Printf("Python (worker %v) exited with code: %v", 
workerId, execx.ExecuteEnv(map[string]string{"WORKER_ID": workerId}, "python", 
args...))
                }(workerId)
        }
        wg.Wait()
+
+       return nil
+}
+
+// setupVenv initialize a local Python venv and set the corresponding env 
variables
+func setupVenv(baseDir, workerId string) (string, error) {
+       log.Printf("Initializing temporary Python venv ...")
+
+       if err := os.MkdirAll(baseDir, 0750); err != nil {
+           return "", fmt.Errorf("Failed to create venv base directory: %s", 
err)
+       }
+       dir, err := ioutil.TempDir(baseDir, fmt.Sprintf("beam-venv-%s-", 
workerId))
+       if err != nil {
+           return "", fmt.Errorf("Failed Python venv directory: %s", err)
+       }
+       args := []string{"-m", "venv", "--system-site-packages", dir}
+       if err := execx.Execute("python", args...); err != nil {
+           return "", err
+       }
+       os.Setenv("VIRTUAL_ENV", dir)

Review comment:
       Because we are not running a shell and `source` is a shell/bash builtin. 
Also executing a shell in a subprocess won't affect the parent process.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 737058)
    Time Spent: 12.5h  (was: 12h 20m)

> Multiple jobs running on Flink session cluster reuse the persistent Python 
> environment.
> ---------------------------------------------------------------------------------------
>
>                 Key: BEAM-12792
>                 URL: https://issues.apache.org/jira/browse/BEAM-12792
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-harness
>    Affects Versions: 2.27.0, 2.28.0, 2.29.0, 2.30.0, 2.31.0
>         Environment: Kubernetes 1.20 on Ubuntu 18.04.
>            Reporter: Jens Wiren
>            Priority: P1
>              Labels: FlinkRunner, beam
>          Time Spent: 12.5h
>  Remaining Estimate: 0h
>
> I'm running TFX pipelines on a Flink cluster using Beam in k8s. However, 
> extra python packages passed to the Flink runner (or rather beam worker 
> side-car) are only installed once per deployment cycle. Example:
>  # Flink is deployed and is up and running
>  # A TFX pipeline starts, submits a job to Flink along with a python whl of 
> custom code and beam ops.
>  # The beam worker installs the package and the pipeline finishes succesfully.
>  # A new TFX pipeline is build where a new beam fn is introduced, the pipline 
> is started and the new whl is submitted as in step 2).
>  # This time, the new package is not being installed in the beam worker 
> causing the job to fail due to a reference which does not exist in the beam 
> worker, since it didn't install the new package.
>  
> I started using Flink from beam version 2.27 and it has been an issue all the 
> time.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to