Skip to content

Commit

Permalink
Merge pull request #16593 from [BEAM-13725][Playground] Add graph to …
Browse files Browse the repository at this point in the history
…the precompiled objects

* [BEAM-13725][Playground]
Add graph field to `PrecompiledObject`

* [BEAM-13725][Playground]
Fix test

* [BEAM-137235][Playground]
Remove `graph` from PrecompiledObject
Add a new methods to receive graph of the PrecompiledObject.

* [BEAM-13725][Playground]
Update comments;
Remove unnecessary field;

* [BEAM-13725][Playground]
Fix tests

* [BEAM-13725][Playground]
Regenerate proto files

* [BEAM-13725][Playground]
renaming

* [BEAM-13725][Playground]
Regenerate files

* [BEAM-13725][Playground]
Regenerate proto files
  • Loading branch information
Aydar Zainutdinov committed Feb 4, 2022
1 parent fda0b00 commit d8ab299
Show file tree
Hide file tree
Showing 10 changed files with 713 additions and 225 deletions.
13 changes: 13 additions & 0 deletions playground/api/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ message GetPrecompiledObjectLogsRequest{
string cloud_path = 1;
}

// GetPrecompiledObjectGraphRequest contains information of the PrecompiledObject cloud path.
message GetPrecompiledObjectGraphRequest{
string cloud_path = 1;
}

// GetDefaultPrecompiledObjectRequest contains information of the needed PrecompiledObject sdk.
message GetDefaultPrecompiledObjectRequest {
Sdk sdk = 1;
Expand All @@ -222,6 +227,11 @@ message GetPrecompiledObjectLogsResponse {
string output = 1;
}

// GetPrecompiledObjectGraphResponse represents the string representation of the executed code graph in DOT format.
message GetPrecompiledObjectGraphResponse {
string graph = 1;
}

// GetDefaultPrecompiledObjectResponse represents the default PrecompiledObject and his category for the sdk.
message GetDefaultPrecompiledObjectResponse {
PrecompiledObject precompiled_object = 1;
Expand Down Expand Up @@ -271,6 +281,9 @@ service PlaygroundService {
// Get the logs of an PrecompiledObject.
rpc GetPrecompiledObjectLogs(GetPrecompiledObjectLogsRequest) returns (GetPrecompiledObjectLogsResponse);

// Get the graph of an PrecompiledObject.
rpc GetPrecompiledObjectGraph(GetPrecompiledObjectGraphRequest) returns (GetPrecompiledObjectGraphResponse);

// Get the default precompile object for the sdk.
rpc GetDefaultPrecompiledObject(GetDefaultPrecompiledObjectRequest) returns (GetDefaultPrecompiledObjectResponse);
}
12 changes: 12 additions & 0 deletions playground/backend/cmd/server/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,15 @@ func (controller *playgroundController) GetPrecompiledObjectLogs(ctx context.Con
response := pb.GetPrecompiledObjectLogsResponse{Output: logs}
return &response, nil
}

// GetPrecompiledObjectGraph returns the graph of the compiled and run example
func (controller *playgroundController) GetPrecompiledObjectGraph(ctx context.Context, info *pb.GetPrecompiledObjectGraphRequest) (*pb.GetPrecompiledObjectGraphResponse, error) {
cb := cloud_bucket.New()
logs, err := cb.GetPrecompiledObjectGraph(ctx, info.GetCloudPath())
if err != nil {
logger.Errorf("GetPrecompiledObjectGraph(): cloud storage error: %s", err.Error())
return nil, errors.InternalError("Error during getting Precompiled Object's graph", "Error with cloud connection")
}
response := pb.GetPrecompiledObjectGraphResponse{Graph: logs}
return &response, nil
}
519 changes: 329 additions & 190 deletions playground/backend/internal/api/v1/api.pb.go

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions playground/backend/internal/api/v1/api_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions playground/backend/internal/cloud_bucket/precompiled_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
BucketName = "playground-precompiled-objects"
OutputExtension = "output"
LogsExtension = "log"
GraphExtension = "graph"
MetaInfoName = "meta.info"
Timeout = time.Minute
javaExtension = "java"
Expand Down Expand Up @@ -129,6 +130,15 @@ func (cd *CloudStorage) GetPrecompiledObjectLogs(ctx context.Context, precompile
return result, nil
}

// GetPrecompiledObjectGraph returns the graph of the example
func (cd *CloudStorage) GetPrecompiledObjectGraph(ctx context.Context, precompiledObjectPath string) (string, error) {
data, err := cd.getFileFromBucket(ctx, precompiledObjectPath, GraphExtension)
if err != nil {
return "", err
}
return string(data), nil
}

// GetPrecompiledObjects returns stored at the cloud storage bucket precompiled objects for the target category
func (cd *CloudStorage) GetPrecompiledObjects(ctx context.Context, targetSdk pb.Sdk, targetCategory string) (*SdkToCategories, error) {
client, err := storage.NewClient(ctx, option.WithoutAuthentication())
Expand Down
94 changes: 94 additions & 0 deletions playground/frontend/lib/api/v1/api.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,53 @@ class GetPrecompiledObjectLogsRequest extends $pb.GeneratedMessage {
void clearCloudPath() => clearField(1);
}

class GetPrecompiledObjectGraphRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetPrecompiledObjectGraphRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'api.v1'), createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'cloudPath')
..hasRequiredFields = false
;

GetPrecompiledObjectGraphRequest._() : super();
factory GetPrecompiledObjectGraphRequest({
$core.String? cloudPath,
}) {
final _result = create();
if (cloudPath != null) {
_result.cloudPath = cloudPath;
}
return _result;
}
factory GetPrecompiledObjectGraphRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory GetPrecompiledObjectGraphRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
GetPrecompiledObjectGraphRequest clone() => GetPrecompiledObjectGraphRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
GetPrecompiledObjectGraphRequest copyWith(void Function(GetPrecompiledObjectGraphRequest) updates) => super.copyWith((message) => updates(message as GetPrecompiledObjectGraphRequest)) as GetPrecompiledObjectGraphRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static GetPrecompiledObjectGraphRequest create() => GetPrecompiledObjectGraphRequest._();
GetPrecompiledObjectGraphRequest createEmptyInstance() => create();
static $pb.PbList<GetPrecompiledObjectGraphRequest> createRepeated() => $pb.PbList<GetPrecompiledObjectGraphRequest>();
@$core.pragma('dart2js:noInline')
static GetPrecompiledObjectGraphRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<GetPrecompiledObjectGraphRequest>(create);
static GetPrecompiledObjectGraphRequest? _defaultInstance;

@$pb.TagNumber(1)
$core.String get cloudPath => $_getSZ(0);
@$pb.TagNumber(1)
set cloudPath($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasCloudPath() => $_has(0);
@$pb.TagNumber(1)
void clearCloudPath() => clearField(1);
}

class GetDefaultPrecompiledObjectRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetDefaultPrecompiledObjectRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'api.v1'), createEmptyInstance: create)
..e<Sdk>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sdk', $pb.PbFieldType.OE, defaultOrMaker: Sdk.SDK_UNSPECIFIED, valueOf: Sdk.valueOf, enumValues: Sdk.values)
Expand Down Expand Up @@ -1653,6 +1700,53 @@ class GetPrecompiledObjectLogsResponse extends $pb.GeneratedMessage {
void clearOutput() => clearField(1);
}

class GetPrecompiledObjectGraphResponse extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetPrecompiledObjectGraphResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'api.v1'), createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'graph')
..hasRequiredFields = false
;

GetPrecompiledObjectGraphResponse._() : super();
factory GetPrecompiledObjectGraphResponse({
$core.String? graph,
}) {
final _result = create();
if (graph != null) {
_result.graph = graph;
}
return _result;
}
factory GetPrecompiledObjectGraphResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory GetPrecompiledObjectGraphResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
GetPrecompiledObjectGraphResponse clone() => GetPrecompiledObjectGraphResponse()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
GetPrecompiledObjectGraphResponse copyWith(void Function(GetPrecompiledObjectGraphResponse) updates) => super.copyWith((message) => updates(message as GetPrecompiledObjectGraphResponse)) as GetPrecompiledObjectGraphResponse; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static GetPrecompiledObjectGraphResponse create() => GetPrecompiledObjectGraphResponse._();
GetPrecompiledObjectGraphResponse createEmptyInstance() => create();
static $pb.PbList<GetPrecompiledObjectGraphResponse> createRepeated() => $pb.PbList<GetPrecompiledObjectGraphResponse>();
@$core.pragma('dart2js:noInline')
static GetPrecompiledObjectGraphResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<GetPrecompiledObjectGraphResponse>(create);
static GetPrecompiledObjectGraphResponse? _defaultInstance;

@$pb.TagNumber(1)
$core.String get graph => $_getSZ(0);
@$pb.TagNumber(1)
set graph($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasGraph() => $_has(0);
@$pb.TagNumber(1)
void clearGraph() => clearField(1);
}

class GetDefaultPrecompiledObjectResponse extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetDefaultPrecompiledObjectResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'api.v1'), createEmptyInstance: create)
..aOM<PrecompiledObject>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'precompiledObject', subBuilder: PrecompiledObject.create)
Expand Down
31 changes: 31 additions & 0 deletions playground/frontend/lib/api/v1/api.pbgrpc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ class PlaygroundServiceClient extends $grpc.Client {
($0.GetPrecompiledObjectLogsRequest value) => value.writeToBuffer(),
($core.List<$core.int> value) =>
$0.GetPrecompiledObjectLogsResponse.fromBuffer(value));
static final _$getPrecompiledObjectGraph = $grpc.ClientMethod<
$0.GetPrecompiledObjectGraphRequest,
$0.GetPrecompiledObjectGraphResponse>(
'/api.v1.PlaygroundService/GetPrecompiledObjectGraph',
($0.GetPrecompiledObjectGraphRequest value) => value.writeToBuffer(),
($core.List<$core.int> value) =>
$0.GetPrecompiledObjectGraphResponse.fromBuffer(value));
static final _$getDefaultPrecompiledObject = $grpc.ClientMethod<
$0.GetDefaultPrecompiledObjectRequest,
$0.GetDefaultPrecompiledObjectResponse>(
Expand Down Expand Up @@ -214,6 +221,13 @@ class PlaygroundServiceClient extends $grpc.Client {
options: options);
}

$grpc.ResponseFuture<$0.GetPrecompiledObjectGraphResponse>
getPrecompiledObjectGraph($0.GetPrecompiledObjectGraphRequest request,
{$grpc.CallOptions? options}) {
return $createUnaryCall(_$getPrecompiledObjectGraph, request,
options: options);
}

$grpc.ResponseFuture<$0.GetDefaultPrecompiledObjectResponse>
getDefaultPrecompiledObject($0.GetDefaultPrecompiledObjectRequest request,
{$grpc.CallOptions? options}) {
Expand Down Expand Up @@ -345,6 +359,15 @@ abstract class PlaygroundServiceBase extends $grpc.Service {
($core.List<$core.int> value) =>
$0.GetPrecompiledObjectLogsRequest.fromBuffer(value),
($0.GetPrecompiledObjectLogsResponse value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.GetPrecompiledObjectGraphRequest,
$0.GetPrecompiledObjectGraphResponse>(
'GetPrecompiledObjectGraph',
getPrecompiledObjectGraph_Pre,
false,
false,
($core.List<$core.int> value) =>
$0.GetPrecompiledObjectGraphRequest.fromBuffer(value),
($0.GetPrecompiledObjectGraphResponse value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.GetDefaultPrecompiledObjectRequest,
$0.GetDefaultPrecompiledObjectResponse>(
'GetDefaultPrecompiledObject',
Expand Down Expand Up @@ -435,6 +458,12 @@ abstract class PlaygroundServiceBase extends $grpc.Service {
return getPrecompiledObjectLogs(call, await request);
}

$async.Future<$0.GetPrecompiledObjectGraphResponse>
getPrecompiledObjectGraph_Pre($grpc.ServiceCall call,
$async.Future<$0.GetPrecompiledObjectGraphRequest> request) async {
return getPrecompiledObjectGraph(call, await request);
}

$async.Future<$0.GetDefaultPrecompiledObjectResponse>
getDefaultPrecompiledObject_Pre($grpc.ServiceCall call,
$async.Future<$0.GetDefaultPrecompiledObjectRequest> request) async {
Expand Down Expand Up @@ -470,6 +499,8 @@ abstract class PlaygroundServiceBase extends $grpc.Service {
$grpc.ServiceCall call, $0.GetPrecompiledObjectOutputRequest request);
$async.Future<$0.GetPrecompiledObjectLogsResponse> getPrecompiledObjectLogs(
$grpc.ServiceCall call, $0.GetPrecompiledObjectLogsRequest request);
$async.Future<$0.GetPrecompiledObjectGraphResponse> getPrecompiledObjectGraph(
$grpc.ServiceCall call, $0.GetPrecompiledObjectGraphRequest request);
$async.Future<$0.GetDefaultPrecompiledObjectResponse>
getDefaultPrecompiledObject($grpc.ServiceCall call,
$0.GetDefaultPrecompiledObjectRequest request);
Expand Down
Loading

0 comments on commit d8ab299

Please sign in to comment.