[ https://issues.apache.org/jira/browse/BEAM-13633?focusedWorklogId=710024&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-710024 ]
ASF GitHub Bot logged work on BEAM-13633: ----------------------------------------- Author: ASF GitHub Bot Created on: 17/Jan/22 15:34 Start Date: 17/Jan/22 15:34 Worklog Time Spent: 10m Work Description: 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 710024) Time Spent: 2h 40m (was: 2.5h) > 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: 2h 40m > 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)