AydarZaynutdinov commented on a change in pull request #16484:
URL: https://github.com/apache/beam/pull/16484#discussion_r786111832



##########
File path: playground/backend/internal/cloud_bucket/precompiled_objects_test.go
##########
@@ -250,6 +250,6 @@ func Benchmark_GetPrecompiledObjectOutput(b *testing.B) {
 
 func Benchmark_GetPrecompiledObject(b *testing.B) {

Review comment:
       ```suggestion
   func Benchmark_GetPrecompiledObjectCode(b *testing.B) {
   ```

##########
File path: playground/backend/internal/environment/environment_service_test.go
##########
@@ -308,3 +310,40 @@ func Test_getConfigFromJson(t *testing.T) {
                })
        }
 }
+
+func Test_getDefaultExamplesFromJson(t *testing.T) {
+       type args struct {
+               configPath string
+       }
+       tests := []struct {
+               name    string
+               args    args
+               want    string
+               wantErr bool
+       }{
+               {
+                       name:    "get object from json",
+                       args:    args{filepath.Join(configFolderName, 
defaultSdk.String()+jsonExt)},
+                       want:    "SDK_JAVA/MinimalWordCount",
+                       wantErr: false,
+               },
+               {
+                       name:    "error if wrong json path",

Review comment:
       ditto

##########
File path: playground/backend/internal/environment/environment_service_test.go
##########
@@ -308,3 +310,40 @@ func Test_getConfigFromJson(t *testing.T) {
                })
        }
 }
+
+func Test_getDefaultExamplesFromJson(t *testing.T) {
+       type args struct {
+               configPath string
+       }
+       tests := []struct {
+               name    string
+               args    args
+               want    string
+               wantErr bool
+       }{
+               {
+                       name:    "get object from json",

Review comment:
       Please add a comment for this test case

##########
File path: playground/backend/cmd/server/controller.go
##########
@@ -294,3 +294,28 @@ func (controller *playgroundController) 
GetPrecompiledObjectLogs(ctx context.Con
        response := pb.GetPrecompiledObjectLogsResponse{Output: logs}
        return &response, nil
 }
+
+// GetDefaultPrecompiledObject returns the default precompile object for sdk.
+func (controller *playgroundController) GetDefaultPrecompiledObject(ctx 
context.Context, info *pb.GetDefaultPrecompiledObjectRequest) 
(*pb.GetDefaultPrecompiledObjectResponse, error) {
+       switch info.Sdk {
+       case pb.Sdk_SDK_UNSPECIFIED, pb.Sdk_SDK_SCIO:
+               logger.Errorf("GetDefaultPrecompiledObject(): unimplemented 
sdk: %s\n", info.Sdk)
+               return nil, errors.InvalidArgumentError("Error during 
preparing", "Sdk is not implemented yet: %s", info.Sdk.String())
+       }
+
+       bucket := cloud_bucket.New()
+       precompiledObject, err := bucket.GetDefaultPrecompileObject(ctx, 
info.Sdk, controller.env.ApplicationEnvs.WorkingDir())
+       if err != nil {
+               logger.Errorf("GetDefaultPrecompileObject(): cloud storage 
error: %s", err.Error())
+               return nil, errors.InternalError("Error during getting default 
Precompiled Object", "Error with cloud connection")
+       }
+
+       response := pb.GetDefaultPrecompiledObjectResponse{PrecompiledObject: 
&pb.PrecompiledObject{
+               CloudPath:       precompiledObject.CloudPath,
+               Name:            precompiledObject.Name,
+               Description:     precompiledObject.Description,
+               Type:            precompiledObject.Type,
+               PipelineOptions: precompiledObject.PipelineOptions,
+       }}

Review comment:
       Could you please also add the `link` field according to [this 
one](https://github.com/apache/beam/pull/16506)




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