AydarZaynutdinov commented on a change in pull request #15803:
URL: https://github.com/apache/beam/pull/15803#discussion_r737224526
##########
File path: playground/backend/cmd/server/controller.go
##########
@@ -54,3 +121,125 @@ func (controller *playgroundController)
GetCompileOutput(ctx context.Context, in
compileOutput := pb.GetCompileOutputResponse{Output: "test compile
output"}
return &compileOutput, nil
}
+
+// setupValidators returns validators based on sdk
+func setupValidators(sdk pb.Sdk, filepath string) *[]validators.Validator {
+ var val *[]validators.Validator
+ switch sdk {
+ case pb.Sdk_SDK_JAVA:
+ val = validators.GetJavaValidators(filepath)
+ }
+ return val
+}
+
+// processCode validates, compiles and runs code by pipelineId.
+// During each operation updates status of execution and saves it into cache.
+// In case of some step is failed saves output logs to cache.
+// After success code running saves output to cache.
+// At the end of this method deletes all created folders
+func processCode(ctx context.Context, cacheService cache.Cache, lc
*fs_tool.LifeCycle, execBuilder *executors.CompileBuilder, pipelineId
uuid.UUID, env *environment.Environment) {
+ defer cleanUp(pipelineId, lc)
+
+ exec := execBuilder.Build()
+
+ // validate
+ log.Printf("%s: Validate() ...\n", pipelineId)
+
+ validateFunc := exec.Validate()
+ if err := validateFunc(); err != nil {
+ // error during validation
+ // TODO move to processError when status for validation error
will be added
+ log.Printf("%s: Validate: %s\n", pipelineId, err.Error())
+ setToCache(ctx, cacheService, pipelineId, cache.Status,
pb.Status_STATUS_ERROR)
+ return
+ }
+ log.Printf("%s: Validate() finish\n", pipelineId)
+
+ // compile
+ log.Printf("%s: Compile() ...\n", pipelineId)
+ compileCmd := exec.Compile()
+ if data, err := compileCmd.CombinedOutput(); err != nil {
+ processError(ctx, err, data, pipelineId, cacheService,
pb.Status_STATUS_COMPILE_ERROR)
+ return
+ }
+ log.Printf("%s: Compile() finish\n", pipelineId)
+
+ // set empty value to pipelineId: cache.SubKey_CompileOutput
+ setToCache(ctx, cacheService, pipelineId, cache.CompileOutput, "")
+
+ className, err := lc.ExecutableName(pipelineId,
env.ApplicationEnvs.WorkingDir())
+ if err != nil {
+ log.Printf("%s: get executable file name: %s\n", pipelineId,
err.Error())
+ setToCache(ctx, cacheService, pipelineId, cache.Status,
pb.Status_STATUS_ERROR)
+ return
+ }
+
+ exec = execBuilder.
+ WithRunner().
+ WithCommand(env.BeamSdkEnvs.ExecutorConfig.RunCmd).
+ WithArgs(env.BeamSdkEnvs.ExecutorConfig.RunArgs).
+ WithClassName(className).
Review comment:
Changed.
--
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]