[ 
https://issues.apache.org/jira/browse/BEAM-13633?focusedWorklogId=714566&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-714566
 ]

ASF GitHub Bot logged work on BEAM-13633:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Jan/22 15:13
            Start Date: 25/Jan/22 15:13
    Worklog Time Spent: 10m 
      Work Description: pavel-avilov commented on a change in pull request 
#16484:
URL: https://github.com/apache/beam/pull/16484#discussion_r791815704



##########
File path: playground/backend/cmd/server/controller.go
##########
@@ -294,3 +293,35 @@ 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())
+       }
+       catalog, err := controller.cacheService.GetCatalog(ctx)
+       if err != nil {
+               logger.Errorf("GetDefaultPrecompiledObject(): cache error: %s", 
err.Error())
+               catalog, err = utils.GetCatalogFromStorage(ctx)
+               if err != nil {
+                       return nil, errors.InternalError("Error during getting 
Precompiled Objects", "Error with cloud connection")
+               }
+               if err = controller.cacheService.SetCatalog(ctx, catalog); err 
!= nil {
+                       logger.Errorf("GetDefaultPrecompiledObject(): cache 
error: %s", err.Error())
+               }
+       }

Review comment:
       Done.

##########
File path: playground/backend/cmd/server/server.go
##########
@@ -109,6 +118,18 @@ func setupCache(ctx context.Context, appEnv 
environment.ApplicationEnvs) (cache.
        }
 }
 
+// setupExamplesCatalog saves precompiled objects catalog from storage to cache
+func setupExamplesCatalog(ctx context.Context, cacheService cache.Cache) error 
{

Review comment:
       This goes from [[BEAM-13632]](https://github.com/apache/beam/pull/16493)

##########
File path: playground/backend/internal/utils/precompiled_objects_utils.go
##########
@@ -34,7 +36,75 @@ func PutPrecompiledObjectsToCategory(categoryName string, 
precompiledObjects *cl
                        Type:            object.Type,
                        PipelineOptions: object.PipelineOptions,
                        Link:            object.Link,
+                       DefaultExample:  object.DefaultExample,
                })
        }
        sdkCategory.Categories = append(sdkCategory.Categories, &category)
 }
+
+// GetCatalogFromStorage returns the precompiled objects catalog from the 
cloud storage
+func GetCatalogFromStorage(ctx context.Context) ([]*pb.Categories, error) {

Review comment:
       This goes from [[BEAM-13632]](https://github.com/apache/beam/pull/16493)




-- 
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-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 714566)
    Time Spent: 4h 50m  (was: 4h 40m)

> Implement method to get a default example for each SDKs
> -------------------------------------------------------
>
>                 Key: BEAM-13633
>                 URL: https://issues.apache.org/jira/browse/BEAM-13633
>             Project: Beam
>          Issue Type: Sub-task
>          Components: beam-playground
>            Reporter: Pavel Avilov
>            Assignee: Pavel Avilov
>            Priority: P2
>              Labels: beam-playground-backend, beam-playground-sprint-7
>          Time Spent: 4h 50m
>  Remaining Estimate: 0h
>
> Need to implement a method that will return a default example for each SDKs. 
> Store the description of default examples in the config.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to