[
https://issues.apache.org/jira/browse/BEAM-13560?focusedWorklogId=708184&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-708184
]
ASF GitHub Bot logged work on BEAM-13560:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 13/Jan/22 10:22
Start Date: 13/Jan/22 10:22
Worklog Time Spent: 10m
Work Description: KhaninArtur commented on a change in pull request
#16477:
URL: https://github.com/apache/beam/pull/16477#discussion_r783816072
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
Review comment:
Why do you pass here the pointer? I think we don't want to change
anything in `paths`, let's remove `*`, what do you think?
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
Review comment:
ditto
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
prep, err := utils.GetPreparators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
- executorConfig := sdkEnv.ExecutorConfig
builder := executors.NewExecutorBuilder().
- WithExecutableFileName(paths.AbsoluteExecutableFilePath).
- WithWorkingDir(paths.AbsoluteBaseFolderPath).
- WithValidator().
- WithSdkValidators(val).
WithPreparator().
WithSdkPreparators(prep).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Compiler return executor with set args for compiler
+func Compiler(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
*executors.ExecutorBuilder {
+ sdk := sdkEnv.ApacheBeamSdk
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithCompiler().
WithCommand(executorConfig.CompileCmd).
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithArgs(executorConfig.CompileArgs).
WithFileName(paths.AbsoluteSourceFilePath).
+ ExecutorBuilder
+
+ switch sdk {
+ case pb.Sdk_SDK_JAVA:
+ builder.
+ WithCompiler().
+
WithFileName(GetFirstFileFromFolder(paths.AbsoluteSourceFileFolderPath))
+ }
+ return &builder
+}
+
+// Runner return executor with set args for runner
+func Runner(paths *fs_tool.LifeCyclePaths, pipelineOptions string, sdkEnv
*environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
+
+ if sdk == pb.Sdk_SDK_JAVA {
+ pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
+ }
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithRunner().
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithCommand(executorConfig.RunCmd).
WithArgs(executorConfig.RunArgs).
WithPipelineOptions(strings.Split(pipelineOptions, " ")).
- WithTestRunner().
- WithCommand(executorConfig.TestCmd).
- WithArgs(executorConfig.TestArgs).
- WithWorkingDir(paths.AbsoluteSourceFileFolderPath).
ExecutorBuilder
switch sdk {
- case pb.Sdk_SDK_JAVA: // Executable name for java class will be known
after compilation
- args := make([]string, 0)
- for _, arg := range executorConfig.RunArgs {
- if strings.Contains(arg, javaLogConfigFilePlaceholder) {
- logConfigFilePath :=
filepath.Join(paths.AbsoluteBaseFolderPath, javaLogConfigFileName)
- arg = strings.Replace(arg,
javaLogConfigFilePlaceholder, logConfigFilePath, 1)
- }
- args = append(args, arg)
+ case pb.Sdk_SDK_JAVA: // Executable name for java class is known after
compilation
+ args := replaceLogPlaceholder(paths, executorConfig)
+ className, err :=
paths.ExecutableName(paths.AbsoluteExecutableFileFolderPath)
+ if err != nil {
+ return nil, fmt.Errorf("no executable file name found
for JAVA pipeline at %s", paths.AbsoluteExecutableFileFolderPath)
}
- builder = builder.WithRunner().WithArgs(args).ExecutorBuilder
- builder =
builder.WithTestRunner().WithWorkingDir(paths.AbsoluteBaseFolderPath).ExecutorBuilder
//change directory for unit test
+ builder = builder.
+ WithRunner().
Review comment:
We already have `WithRunner()` at the beginning of the building of the
executor, should we call it once more here?
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
prep, err := utils.GetPreparators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
- executorConfig := sdkEnv.ExecutorConfig
builder := executors.NewExecutorBuilder().
- WithExecutableFileName(paths.AbsoluteExecutableFilePath).
- WithWorkingDir(paths.AbsoluteBaseFolderPath).
- WithValidator().
- WithSdkValidators(val).
WithPreparator().
WithSdkPreparators(prep).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Compiler return executor with set args for compiler
+func Compiler(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
*executors.ExecutorBuilder {
Review comment:
ditto
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
prep, err := utils.GetPreparators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
- executorConfig := sdkEnv.ExecutorConfig
builder := executors.NewExecutorBuilder().
- WithExecutableFileName(paths.AbsoluteExecutableFilePath).
- WithWorkingDir(paths.AbsoluteBaseFolderPath).
- WithValidator().
- WithSdkValidators(val).
WithPreparator().
WithSdkPreparators(prep).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Compiler return executor with set args for compiler
+func Compiler(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
*executors.ExecutorBuilder {
+ sdk := sdkEnv.ApacheBeamSdk
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithCompiler().
WithCommand(executorConfig.CompileCmd).
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithArgs(executorConfig.CompileArgs).
WithFileName(paths.AbsoluteSourceFilePath).
+ ExecutorBuilder
+
+ switch sdk {
+ case pb.Sdk_SDK_JAVA:
+ builder.
+ WithCompiler().
+
WithFileName(GetFirstFileFromFolder(paths.AbsoluteSourceFileFolderPath))
+ }
+ return &builder
+}
+
+// Runner return executor with set args for runner
+func Runner(paths *fs_tool.LifeCyclePaths, pipelineOptions string, sdkEnv
*environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
+
+ if sdk == pb.Sdk_SDK_JAVA {
+ pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
+ }
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithRunner().
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithCommand(executorConfig.RunCmd).
WithArgs(executorConfig.RunArgs).
WithPipelineOptions(strings.Split(pipelineOptions, " ")).
- WithTestRunner().
- WithCommand(executorConfig.TestCmd).
- WithArgs(executorConfig.TestArgs).
- WithWorkingDir(paths.AbsoluteSourceFileFolderPath).
ExecutorBuilder
switch sdk {
- case pb.Sdk_SDK_JAVA: // Executable name for java class will be known
after compilation
- args := make([]string, 0)
- for _, arg := range executorConfig.RunArgs {
- if strings.Contains(arg, javaLogConfigFilePlaceholder) {
- logConfigFilePath :=
filepath.Join(paths.AbsoluteBaseFolderPath, javaLogConfigFileName)
- arg = strings.Replace(arg,
javaLogConfigFilePlaceholder, logConfigFilePath, 1)
- }
- args = append(args, arg)
+ case pb.Sdk_SDK_JAVA: // Executable name for java class is known after
compilation
+ args := replaceLogPlaceholder(paths, executorConfig)
+ className, err :=
paths.ExecutableName(paths.AbsoluteExecutableFileFolderPath)
+ if err != nil {
+ return nil, fmt.Errorf("no executable file name found
for JAVA pipeline at %s", paths.AbsoluteExecutableFileFolderPath)
}
- builder = builder.WithRunner().WithArgs(args).ExecutorBuilder
- builder =
builder.WithTestRunner().WithWorkingDir(paths.AbsoluteBaseFolderPath).ExecutorBuilder
//change directory for unit test
+ builder = builder.
+ WithRunner().
+ WithArgs(args).
+ WithExecutableFileName(className).
+ ExecutorBuilder
case pb.Sdk_SDK_GO: //go run command is executable file itself
builder = builder.
- WithExecutableFileName("").
WithRunner().
-
WithCommand(paths.AbsoluteExecutableFilePath).ExecutorBuilder
+ WithExecutableFileName("").
+ WithCommand(paths.AbsoluteExecutableFilePath).
+ ExecutorBuilder
case pb.Sdk_SDK_PYTHON:
- builder =
*builder.WithExecutableFileName(paths.AbsoluteExecutableFilePath)
- case pb.Sdk_SDK_SCIO:
- return nil, fmt.Errorf("SCIO is not supported yet")
- default:
- return nil, fmt.Errorf("incorrect sdk: %s",
sdkEnv.ApacheBeamSdk)
+ builder = builder.
+ WithRunner().
+
WithExecutableFileName(paths.AbsoluteExecutableFilePath).
+ ExecutorBuilder
+ }
+ return &builder, nil
+}
+
+// TestRunner return executor with set args for runner
+func TestRunner(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
+ WithTestRunner().
+ WithExecutableFileName(paths.AbsoluteExecutableFilePath).
+ WithCommand(executorConfig.TestCmd).
+ WithArgs(executorConfig.TestArgs).
+ WithWorkingDir(paths.AbsoluteSourceFileFolderPath).
+ ExecutorBuilder
+
+ switch sdk {
+ case pb.Sdk_SDK_JAVA: // Executable name for java class is known after
compilation
+ className, err :=
paths.ExecutableName(paths.AbsoluteExecutableFileFolderPath)
+ if err != nil {
+ return nil, fmt.Errorf("no executable file name found
for JAVA pipeline at %s", paths.AbsoluteExecutableFileFolderPath)
+ }
+ builder = builder.WithTestRunner().
+ WithExecutableFileName(className).
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
+ ExecutorBuilder //change directory for unit test
}
return &builder, nil
}
-// GetFileNameFromFolder return a name of the first file in a specified folder
-func GetFileNameFromFolder(folderAbsolutePath, extension string) string {
- files, _ := filepath.Glob(fmt.Sprintf("%s/*%s", folderAbsolutePath,
extension))
+// replaceLogPlaceholder replaces placeholder for log for JAVA SDK
+func replaceLogPlaceholder(paths *fs_tool.LifeCyclePaths, executorConfig
*environment.ExecutorConfig) []string {
Review comment:
ditto
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
Review comment:
Maybe, we can also remove `*` from `sdkEnv`?
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
prep, err := utils.GetPreparators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
- executorConfig := sdkEnv.ExecutorConfig
builder := executors.NewExecutorBuilder().
- WithExecutableFileName(paths.AbsoluteExecutableFilePath).
- WithWorkingDir(paths.AbsoluteBaseFolderPath).
- WithValidator().
- WithSdkValidators(val).
WithPreparator().
WithSdkPreparators(prep).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Compiler return executor with set args for compiler
+func Compiler(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
*executors.ExecutorBuilder {
+ sdk := sdkEnv.ApacheBeamSdk
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithCompiler().
WithCommand(executorConfig.CompileCmd).
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithArgs(executorConfig.CompileArgs).
WithFileName(paths.AbsoluteSourceFilePath).
+ ExecutorBuilder
+
+ switch sdk {
+ case pb.Sdk_SDK_JAVA:
+ builder.
+ WithCompiler().
+
WithFileName(GetFirstFileFromFolder(paths.AbsoluteSourceFileFolderPath))
+ }
+ return &builder
+}
+
+// Runner return executor with set args for runner
+func Runner(paths *fs_tool.LifeCyclePaths, pipelineOptions string, sdkEnv
*environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
+
+ if sdk == pb.Sdk_SDK_JAVA {
+ pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
+ }
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithRunner().
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithCommand(executorConfig.RunCmd).
WithArgs(executorConfig.RunArgs).
WithPipelineOptions(strings.Split(pipelineOptions, " ")).
- WithTestRunner().
- WithCommand(executorConfig.TestCmd).
- WithArgs(executorConfig.TestArgs).
- WithWorkingDir(paths.AbsoluteSourceFileFolderPath).
ExecutorBuilder
switch sdk {
- case pb.Sdk_SDK_JAVA: // Executable name for java class will be known
after compilation
- args := make([]string, 0)
- for _, arg := range executorConfig.RunArgs {
- if strings.Contains(arg, javaLogConfigFilePlaceholder) {
- logConfigFilePath :=
filepath.Join(paths.AbsoluteBaseFolderPath, javaLogConfigFileName)
- arg = strings.Replace(arg,
javaLogConfigFilePlaceholder, logConfigFilePath, 1)
- }
- args = append(args, arg)
+ case pb.Sdk_SDK_JAVA: // Executable name for java class is known after
compilation
+ args := replaceLogPlaceholder(paths, executorConfig)
+ className, err :=
paths.ExecutableName(paths.AbsoluteExecutableFileFolderPath)
+ if err != nil {
+ return nil, fmt.Errorf("no executable file name found
for JAVA pipeline at %s", paths.AbsoluteExecutableFileFolderPath)
}
- builder = builder.WithRunner().WithArgs(args).ExecutorBuilder
- builder =
builder.WithTestRunner().WithWorkingDir(paths.AbsoluteBaseFolderPath).ExecutorBuilder
//change directory for unit test
+ builder = builder.
+ WithRunner().
+ WithArgs(args).
+ WithExecutableFileName(className).
+ ExecutorBuilder
case pb.Sdk_SDK_GO: //go run command is executable file itself
builder = builder.
- WithExecutableFileName("").
WithRunner().
-
WithCommand(paths.AbsoluteExecutableFilePath).ExecutorBuilder
+ WithExecutableFileName("").
+ WithCommand(paths.AbsoluteExecutableFilePath).
+ ExecutorBuilder
case pb.Sdk_SDK_PYTHON:
- builder =
*builder.WithExecutableFileName(paths.AbsoluteExecutableFilePath)
- case pb.Sdk_SDK_SCIO:
- return nil, fmt.Errorf("SCIO is not supported yet")
- default:
- return nil, fmt.Errorf("incorrect sdk: %s",
sdkEnv.ApacheBeamSdk)
+ builder = builder.
+ WithRunner().
Review comment:
ditto
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
prep, err := utils.GetPreparators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
- executorConfig := sdkEnv.ExecutorConfig
builder := executors.NewExecutorBuilder().
- WithExecutableFileName(paths.AbsoluteExecutableFilePath).
- WithWorkingDir(paths.AbsoluteBaseFolderPath).
- WithValidator().
- WithSdkValidators(val).
WithPreparator().
WithSdkPreparators(prep).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Compiler return executor with set args for compiler
+func Compiler(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
*executors.ExecutorBuilder {
+ sdk := sdkEnv.ApacheBeamSdk
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithCompiler().
WithCommand(executorConfig.CompileCmd).
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithArgs(executorConfig.CompileArgs).
WithFileName(paths.AbsoluteSourceFilePath).
+ ExecutorBuilder
+
+ switch sdk {
+ case pb.Sdk_SDK_JAVA:
+ builder.
+ WithCompiler().
+
WithFileName(GetFirstFileFromFolder(paths.AbsoluteSourceFileFolderPath))
+ }
+ return &builder
+}
+
+// Runner return executor with set args for runner
+func Runner(paths *fs_tool.LifeCyclePaths, pipelineOptions string, sdkEnv
*environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
+
+ if sdk == pb.Sdk_SDK_JAVA {
+ pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
+ }
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithRunner().
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithCommand(executorConfig.RunCmd).
WithArgs(executorConfig.RunArgs).
WithPipelineOptions(strings.Split(pipelineOptions, " ")).
- WithTestRunner().
- WithCommand(executorConfig.TestCmd).
- WithArgs(executorConfig.TestArgs).
- WithWorkingDir(paths.AbsoluteSourceFileFolderPath).
ExecutorBuilder
switch sdk {
- case pb.Sdk_SDK_JAVA: // Executable name for java class will be known
after compilation
- args := make([]string, 0)
- for _, arg := range executorConfig.RunArgs {
- if strings.Contains(arg, javaLogConfigFilePlaceholder) {
- logConfigFilePath :=
filepath.Join(paths.AbsoluteBaseFolderPath, javaLogConfigFileName)
- arg = strings.Replace(arg,
javaLogConfigFilePlaceholder, logConfigFilePath, 1)
- }
- args = append(args, arg)
+ case pb.Sdk_SDK_JAVA: // Executable name for java class is known after
compilation
+ args := replaceLogPlaceholder(paths, executorConfig)
+ className, err :=
paths.ExecutableName(paths.AbsoluteExecutableFileFolderPath)
+ if err != nil {
+ return nil, fmt.Errorf("no executable file name found
for JAVA pipeline at %s", paths.AbsoluteExecutableFileFolderPath)
}
- builder = builder.WithRunner().WithArgs(args).ExecutorBuilder
- builder =
builder.WithTestRunner().WithWorkingDir(paths.AbsoluteBaseFolderPath).ExecutorBuilder
//change directory for unit test
+ builder = builder.
+ WithRunner().
+ WithArgs(args).
+ WithExecutableFileName(className).
+ ExecutorBuilder
case pb.Sdk_SDK_GO: //go run command is executable file itself
builder = builder.
- WithExecutableFileName("").
WithRunner().
-
WithCommand(paths.AbsoluteExecutableFilePath).ExecutorBuilder
+ WithExecutableFileName("").
+ WithCommand(paths.AbsoluteExecutableFilePath).
+ ExecutorBuilder
case pb.Sdk_SDK_PYTHON:
- builder =
*builder.WithExecutableFileName(paths.AbsoluteExecutableFilePath)
- case pb.Sdk_SDK_SCIO:
- return nil, fmt.Errorf("SCIO is not supported yet")
- default:
- return nil, fmt.Errorf("incorrect sdk: %s",
sdkEnv.ApacheBeamSdk)
+ builder = builder.
+ WithRunner().
+
WithExecutableFileName(paths.AbsoluteExecutableFilePath).
+ ExecutorBuilder
+ }
+ return &builder, nil
+}
+
+// TestRunner return executor with set args for runner
+func TestRunner(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
Review comment:
ditto
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
prep, err := utils.GetPreparators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
- executorConfig := sdkEnv.ExecutorConfig
builder := executors.NewExecutorBuilder().
- WithExecutableFileName(paths.AbsoluteExecutableFilePath).
- WithWorkingDir(paths.AbsoluteBaseFolderPath).
- WithValidator().
- WithSdkValidators(val).
WithPreparator().
WithSdkPreparators(prep).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Compiler return executor with set args for compiler
+func Compiler(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
*executors.ExecutorBuilder {
+ sdk := sdkEnv.ApacheBeamSdk
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithCompiler().
WithCommand(executorConfig.CompileCmd).
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithArgs(executorConfig.CompileArgs).
WithFileName(paths.AbsoluteSourceFilePath).
+ ExecutorBuilder
+
+ switch sdk {
+ case pb.Sdk_SDK_JAVA:
+ builder.
+ WithCompiler().
+
WithFileName(GetFirstFileFromFolder(paths.AbsoluteSourceFileFolderPath))
+ }
+ return &builder
+}
+
+// Runner return executor with set args for runner
+func Runner(paths *fs_tool.LifeCyclePaths, pipelineOptions string, sdkEnv
*environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
Review comment:
ditto
##########
File path: playground/backend/internal/setup_tools/builder/setup_builder.go
##########
@@ -31,73 +31,139 @@ const (
javaLogConfigFilePlaceholder = "{logConfigFile}"
)
-// SetupExecutorBuilder return executor with set args for validator,
preparator, compiler and runner
-func SetupExecutorBuilder(paths fs_tool.LifeCyclePaths, pipelineOptions
string, sdkEnv *environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+// Validator return executor with set args for validator
+func Validator(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
sdk := sdkEnv.ApacheBeamSdk
-
- if sdk == pb.Sdk_SDK_JAVA {
- pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
- }
-
val, err := utils.GetValidators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
+ builder := executors.NewExecutorBuilder().
+ WithValidator().
+ WithSdkValidators(val).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Preparer return executor with set args for preparator
+func Preparer(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
(*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
prep, err := utils.GetPreparators(sdk, paths.AbsoluteSourceFilePath)
if err != nil {
return nil, err
}
- executorConfig := sdkEnv.ExecutorConfig
builder := executors.NewExecutorBuilder().
- WithExecutableFileName(paths.AbsoluteExecutableFilePath).
- WithWorkingDir(paths.AbsoluteBaseFolderPath).
- WithValidator().
- WithSdkValidators(val).
WithPreparator().
WithSdkPreparators(prep).
+ ExecutorBuilder
+ return &builder, err
+}
+
+// Compiler return executor with set args for compiler
+func Compiler(paths *fs_tool.LifeCyclePaths, sdkEnv *environment.BeamEnvs)
*executors.ExecutorBuilder {
+ sdk := sdkEnv.ApacheBeamSdk
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithCompiler().
WithCommand(executorConfig.CompileCmd).
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithArgs(executorConfig.CompileArgs).
WithFileName(paths.AbsoluteSourceFilePath).
+ ExecutorBuilder
+
+ switch sdk {
+ case pb.Sdk_SDK_JAVA:
+ builder.
+ WithCompiler().
+
WithFileName(GetFirstFileFromFolder(paths.AbsoluteSourceFileFolderPath))
+ }
+ return &builder
+}
+
+// Runner return executor with set args for runner
+func Runner(paths *fs_tool.LifeCyclePaths, pipelineOptions string, sdkEnv
*environment.BeamEnvs) (*executors.ExecutorBuilder, error) {
+ sdk := sdkEnv.ApacheBeamSdk
+
+ if sdk == pb.Sdk_SDK_JAVA {
+ pipelineOptions = utils.ReplaceSpacesWithEquals(pipelineOptions)
+ }
+ executorConfig := sdkEnv.ExecutorConfig
+ builder := executors.NewExecutorBuilder().
WithRunner().
+ WithWorkingDir(paths.AbsoluteBaseFolderPath).
WithCommand(executorConfig.RunCmd).
WithArgs(executorConfig.RunArgs).
WithPipelineOptions(strings.Split(pipelineOptions, " ")).
- WithTestRunner().
- WithCommand(executorConfig.TestCmd).
- WithArgs(executorConfig.TestArgs).
- WithWorkingDir(paths.AbsoluteSourceFileFolderPath).
ExecutorBuilder
switch sdk {
- case pb.Sdk_SDK_JAVA: // Executable name for java class will be known
after compilation
- args := make([]string, 0)
- for _, arg := range executorConfig.RunArgs {
- if strings.Contains(arg, javaLogConfigFilePlaceholder) {
- logConfigFilePath :=
filepath.Join(paths.AbsoluteBaseFolderPath, javaLogConfigFileName)
- arg = strings.Replace(arg,
javaLogConfigFilePlaceholder, logConfigFilePath, 1)
- }
- args = append(args, arg)
+ case pb.Sdk_SDK_JAVA: // Executable name for java class is known after
compilation
+ args := replaceLogPlaceholder(paths, executorConfig)
+ className, err :=
paths.ExecutableName(paths.AbsoluteExecutableFileFolderPath)
+ if err != nil {
+ return nil, fmt.Errorf("no executable file name found
for JAVA pipeline at %s", paths.AbsoluteExecutableFileFolderPath)
}
- builder = builder.WithRunner().WithArgs(args).ExecutorBuilder
- builder =
builder.WithTestRunner().WithWorkingDir(paths.AbsoluteBaseFolderPath).ExecutorBuilder
//change directory for unit test
+ builder = builder.
+ WithRunner().
+ WithArgs(args).
+ WithExecutableFileName(className).
+ ExecutorBuilder
case pb.Sdk_SDK_GO: //go run command is executable file itself
builder = builder.
- WithExecutableFileName("").
WithRunner().
Review comment:
ditto
--
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: 708184)
Time Spent: 1h 40m (was: 1.5h)
> [Playground] Split builder (refactoring)
> ----------------------------------------
>
> Key: BEAM-13560
> URL: https://issues.apache.org/jira/browse/BEAM-13560
> Project: Beam
> Issue Type: Improvement
> Components: beam-playground
> Reporter: Daria Malkova
> Assignee: Daria Malkova
> Priority: P3
> Labels: beam-playground-backend, beam-playground-sprint-7
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> Improve usage of executor builder by splitting it to parts.
> Now executor builder is created at once for all steps: validation,
> preparation, compiling, and run/test. To make a change at some step we have
> to change the created executor. To avoid it, we can create a builder for each
> step separately after the previous steps are executed.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)