You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/10/12 14:13:28 UTC

[GitHub] [beam] riteshghorse commented on a diff in pull request #23582: [Go SDK]: Adds Automated Python Expansion Service

riteshghorse commented on code in PR #23582:
URL: https://github.com/apache/beam/pull/23582#discussion_r993522012


##########
sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go:
##########
@@ -375,3 +380,68 @@ func jarExists(jarPath string) bool {
 	_, err := os.Stat(jarPath)
 	return err == nil
 }
+
+func getPythonVersion() (string, error) {
+	for _, v := range []string{"python", "python3"} {
+		cmd := exec.Command(v, "--version")
+		if err := cmd.Run(); err == nil {
+			return v, nil
+		}
+	}
+	return "", fmt.Errorf("no python installation found")
+}
+
+// SetUpPythonEnvironment sets up the virtual ennvironment required for the
+// Apache Beam Python SDK to run an expansion service module.
+func SetUpPythonEnvironment(extraPackage string) (string, error) {
+	py, err := getPythonVersion()
+	if err != nil {
+		return "", fmt.Errorf("no python installation found: %v", err)
+	}
+	extraPackages := []string{}
+	if len(extraPackage) > 0 {
+		extraPackages = strings.Split(extraPackage, " ")
+	}
+
+	// create python virtual environment
+	sort.Strings(extraPackages)
+	beamPackage := fmt.Sprintf("apache_beam[gcp,aws,asure,dataframe]==%s", core.SdkVersion)

Review Comment:
   surprisingly, there is a an asure package but I think you're right here. The Java one also uses asure https://github.com/apache/beam/blob/1c1ecb2a36dfb256a0e5eb7ff9ac5f84601b51e2/sdks/java/extensions/python/src/main/resources/org/apache/beam/sdk/extensions/python/bootstrap_beam_venv.py#L80. Need to inform them as well. 



-- 
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-unsubscribe@beam.apache.org

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