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



##########
File path: playground/backend/internal/cloud_bucket/precompiled_objects.go
##########
@@ -173,6 +175,30 @@ func (cd *CloudStorage) GetPrecompiledObjects(ctx 
context.Context, targetSdk pb.
        return &precompiledObjects, nil
 }
 
+// GetDefaultPrecompileObject returns the default precompiled object for the 
sdk
+func (cd *CloudStorage) GetDefaultPrecompileObject(ctx context.Context, 
targetSdk pb.Sdk, workingDir string) (*ObjectInfo, error) {

Review comment:
       ```suggestion
   func (cd *CloudStorage) GetDefaultPrecompiledObject(ctx context.Context, 
targetSdk pb.Sdk, workingDir string) (*ObjectInfo, error) {
   ```

##########
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:
       Shouldn't we return the code of the example as well? Or it will be 
requested from the frontend after receiving this response?




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