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 2021/10/05 19:21:49 UTC

[GitHub] [beam] damondouglas commented on a change in pull request #15645: [BEAM-12988] [Playground] Add FileSystem service

damondouglas commented on a change in pull request #15645:
URL: https://github.com/apache/beam/pull/15645#discussion_r722513958



##########
File path: playground/backend/internal/fs_tool/fs_test.go
##########
@@ -0,0 +1,49 @@
+// 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 fs_tool
+
+import (
+	pb "beam.apache.org/playground/backend/internal/api"

Review comment:
       @pabloem FYI I don't think this is a blocker but the code for playground/backend/internal/api is not part of this PR.  It's a simple enough test that I'm ok moving forward and trusting everything will come together in time.

##########
File path: playground/backend/internal/fs_tool/fs.go
##########
@@ -0,0 +1,57 @@
+// 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 fs_tool
+
+import (
+	pb "beam.apache.org/playground/backend/internal/api"
+	"fmt"
+	"github.com/google/uuid"
+)
+
+// FileSystemService interface for all type(Java/Go/Python/Scio) of FileSystem services.
+type FileSystemService interface {

Review comment:
       May we consider breaking up this interface to follow more of the typical interface to method 1:1 carnality we see with go?  Brainstorming out loud, what do we think about the following?  The following isn't complete but just a conversation starter.  I removed the `bool` from the return signatures as it could be part of the error.
   
   ```
   import "io/fs"
   
   type Setup interface {
       Create() (fs.FS, error)
   }
   
   type Teardown interface {
       Delete() error
   }
   
   type LifeCycle struct {
       sdk pb.Sdk
       root fs.FS
       folderGlobs []string
   }
   
   func New(ctx context.Context, sdk pb.Sdk) (*LifeCycle, error) {
           switch sdk {
   	case pb.Sdk_SDK_JAVA:
   		return &LifeCycle{
                        sdk: sdk,
                        root: javaFS, // See java_fs.go
                        folderGlobs: javaGlobs,
                   }, nil
   	default:
   		return nil, fmt.Errorf("%s isn't supported now", sdk)
   	}
   }
   
   func (lc *LifeCycle) Create() (fs.FS, error) {
       for _, k := range lc.folderGlobs {
           if err := MkdirAll( ... ); err != nil {
                ...
           }
       }
   }
   
   func (lc *LifeCycle) Delete() error {
       ....
   }
   ```

##########
File path: playground/backend/internal/fs_tool/java_fs.go
##########
@@ -0,0 +1,140 @@
+// 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 fs_tool
+
+import (
+	"fmt"
+	"github.com/google/uuid"
+	"io/fs"
+	"io/ioutil"
+	"os"
+	"path/filepath"
+)
+
+const (
+	parentBaseFileFolder   = "internal"
+	javaBaseFileFolder     = parentBaseFileFolder + "/executable_files"
+	javaSrcFileFolder      = javaBaseFileFolder + "/src"
+	javaBinFileFolder      = javaBaseFileFolder + "/bin"
+	javaExecutableFileType = "java"
+	javaCompiledFileType   = "class"
+)
+

Review comment:
       In addition to comments on the interface in playground/backend/internal/fs_tool/fs.go:
   
   ```
   var (
   
     javaGlobs = []string{
          parentBaseFileFolder,
          javaBaseFileFolder,
          javaSrcFileFolder,
          javaBinFileFolder,
     }
   
      javaFs = os.DirFS(parentBaseFileFolder)
   )
   
   ```
   
           

##########
File path: playground/backend/internal/fs_tool/java_fs.go
##########
@@ -0,0 +1,140 @@
+// 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 fs_tool
+
+import (
+	"fmt"
+	"github.com/google/uuid"
+	"io/fs"
+	"io/ioutil"
+	"os"
+	"path/filepath"
+)
+
+const (
+	parentBaseFileFolder   = "internal"
+	javaBaseFileFolder     = parentBaseFileFolder + "/executable_files"
+	javaSrcFileFolder      = javaBaseFileFolder + "/src"
+	javaBinFileFolder      = javaBaseFileFolder + "/bin"
+	javaExecutableFileType = "java"
+	javaCompiledFileType   = "class"
+)
+
+type JavaFileSystemService struct{}

Review comment:
       The comments above may remove the need for a specific JavaFileSystemService struct.




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