daria-malkova commented on a change in pull request #16563:
URL: https://github.com/apache/beam/pull/16563#discussion_r788517325



##########
File path: 
playground/backend/internal/setup_tools/life_cycle/life_cycle_setuper.go
##########
@@ -65,6 +70,11 @@ func Setup(sdk pb.Sdk, code string, pipelineId uuid.UUID, 
workingDir, pipelinesF
                        lc.DeleteFolders()
                        return nil, errors.New("error during create necessary 
files for the Java sdk")
                }
+       case pb.Sdk_SDK_SCIO:
+               if lc, err = prepareSbtFiles(lc, 
lc.Paths.AbsoluteBaseFolderPath, workingDir); err != nil {
+                       lc.DeleteFolders()
+                       return nil, errors.New("error during create necessary 
files for the Java sdk")

Review comment:
       Done

##########
File path: 
playground/backend/internal/setup_tools/life_cycle/life_cycle_setuper.go
##########
@@ -143,3 +153,42 @@ func updateJavaLogConfigFile(paths fs_tool.LifeCyclePaths) 
error {
        }
        return nil
 }
+
+func prepareSbtFiles(lc *fs_tool.LifeCycle, pipelineFolder string, workingDir 
string) (*fs_tool.LifeCycle, error) {
+       cmd := exec.Command("sh", filepath.Join(workingDir, 
"new_scio_project.sh"))
+       cmd.Dir = pipelineFolder
+       fmt.Println(cmd.String())

Review comment:
       Done
   

##########
File path: playground/backend/internal/validators/scio_validators.go
##########
@@ -0,0 +1,50 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package validators
+
+import (
+       "beam.apache.org/playground/backend/internal/fs_tool"
+)
+
+const (
+       scalaExtension = ".scala"
+       //scioUnitTestPattern = "@Test"

Review comment:
       Done

##########
File path: playground/backend/new_scio_project.sh
##########
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+yes scioproject | sbt new spotify/scio-template.g8

Review comment:
       Done

##########
File path: 
playground/backend/internal/setup_tools/life_cycle/life_cycle_setuper.go
##########
@@ -143,3 +153,42 @@ func updateJavaLogConfigFile(paths fs_tool.LifeCyclePaths) 
error {
        }
        return nil
 }
+
+func prepareSbtFiles(lc *fs_tool.LifeCycle, pipelineFolder string, workingDir 
string) (*fs_tool.LifeCycle, error) {
+       cmd := exec.Command("sh", filepath.Join(workingDir, 
"new_scio_project.sh"))
+       cmd.Dir = pipelineFolder
+       fmt.Println(cmd.String())
+       _, err := cmd.Output()
+       if err != nil {
+               return nil, err
+       }
+
+       sourceFileFolder := filepath.Join(pipelineFolder, projectPath)
+       fileName := lc.Paths.SourceFileName
+       absFileFolderPath, _ := filepath.Abs(sourceFileFolder)
+       absFilePath, _ := filepath.Abs(filepath.Join(absFileFolderPath, 
fileName))
+       absLogFilePath, _ := filepath.Abs(filepath.Join(absFileFolderPath, 
logFileName))
+       projectFolder, _ := filepath.Abs(filepath.Join(pipelineFolder, 
scioProjectName))
+       executableName := lc.Paths.ExecutableName
+
+       _, err = exec.Command("rm", filepath.Join(absFileFolderPath, 
"WordCount.scala")).Output()
+       if err != nil {
+               return nil, err
+       }

Review comment:
       and it is better to delete it to avoid conflicts

##########
File path: 
playground/backend/internal/setup_tools/life_cycle/life_cycle_setuper.go
##########
@@ -143,3 +153,42 @@ func updateJavaLogConfigFile(paths fs_tool.LifeCyclePaths) 
error {
        }
        return nil
 }
+
+func prepareSbtFiles(lc *fs_tool.LifeCycle, pipelineFolder string, workingDir 
string) (*fs_tool.LifeCycle, error) {
+       cmd := exec.Command("sh", filepath.Join(workingDir, 
"new_scio_project.sh"))
+       cmd.Dir = pipelineFolder
+       fmt.Println(cmd.String())
+       _, err := cmd.Output()
+       if err != nil {
+               return nil, err
+       }
+
+       sourceFileFolder := filepath.Join(pipelineFolder, projectPath)
+       fileName := lc.Paths.SourceFileName
+       absFileFolderPath, _ := filepath.Abs(sourceFileFolder)
+       absFilePath, _ := filepath.Abs(filepath.Join(absFileFolderPath, 
fileName))
+       absLogFilePath, _ := filepath.Abs(filepath.Join(absFileFolderPath, 
logFileName))
+       projectFolder, _ := filepath.Abs(filepath.Join(pipelineFolder, 
scioProjectName))
+       executableName := lc.Paths.ExecutableName
+
+       _, err = exec.Command("rm", filepath.Join(absFileFolderPath, 
"WordCount.scala")).Output()
+       if err != nil {
+               return nil, err
+       }

Review comment:
       we have a template to create scio sbt project that is automatically add 
WordCount example to the created project

##########
File path: playground/backend/internal/validators/scio_validators.go
##########
@@ -0,0 +1,50 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package validators
+
+import (
+       "beam.apache.org/playground/backend/internal/fs_tool"
+)
+
+const (
+       scalaExtension = ".scala"
+       //scioUnitTestPattern = "@Test"
+)
+
+// GetScioValidators return validators methods that should be applied to scio 
code
+// The last validator should check that the code is unit tests or not
+func GetScioValidators(filePath string) *[]Validator {
+       validatorArgs := make([]interface{}, 2)
+       validatorArgs[0] = filePath
+       validatorArgs[1] = scalaExtension
+       pathCheckerValidator := Validator{
+               Validator: fs_tool.CheckPathIsValid,
+               Args:      validatorArgs,
+               Name:      "Valid path",
+       }
+       unitTestValidator := Validator{
+               Validator: checkIsUnitTestScio,
+               Args:      validatorArgs,
+               Name:      UnitTestValidatorName,
+       }
+       validators := []Validator{pathCheckerValidator, unitTestValidator}
+       return &validators
+}
+
+//checkIsUnitTestScio checks if the pipeline is a UnitTest
+func checkIsUnitTestScio(args ...interface{}) (bool, error) {
+       return false, nil

Review comment:
       Right




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