forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inline execution event data can be offloaded to cloud blobstore (flyt…
- Loading branch information
Katrina Rogan
authored
Nov 9, 2021
1 parent
7b9a974
commit c8a4162
Showing
14 changed files
with
390 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/flyteorg/flyteadmin/pkg/errors" | ||
"github.com/flyteorg/flyteadmin/pkg/manager/impl/shared" | ||
"google.golang.org/grpc/codes" | ||
|
||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/flyteorg/flytestdlib/storage" | ||
) | ||
|
||
func OffloadLiteralMap(ctx context.Context, storageClient *storage.DataStore, literalMap *core.LiteralMap, nestedKeys ...string) (storage.DataReference, error) { | ||
if literalMap == nil { | ||
literalMap = &core.LiteralMap{} | ||
} | ||
nestedKeyReference := []string{ | ||
shared.Metadata, | ||
} | ||
nestedKeyReference = append(nestedKeyReference, nestedKeys...) | ||
uri, err := storageClient.ConstructReference(ctx, storageClient.GetBaseContainerFQN(ctx), nestedKeyReference...) | ||
if err != nil { | ||
return "", errors.NewFlyteAdminErrorf(codes.Internal, "Failed to construct data reference for [%+v] with err: %v", nestedKeys, err) | ||
} | ||
if err := storageClient.WriteProtobuf(ctx, uri, storage.Options{}, literalMap); err != nil { | ||
return "", errors.NewFlyteAdminErrorf(codes.Internal, "Failed to write protobuf for [%+v] with err: %v", nestedKeys, err) | ||
} | ||
return uri, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/flyteorg/flyteadmin/pkg/errors" | ||
"google.golang.org/grpc/codes" | ||
|
||
commonMocks "github.com/flyteorg/flyteadmin/pkg/common/mocks" | ||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/flyteorg/flytestdlib/storage" | ||
"github.com/golang/protobuf/proto" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var literalMap = &core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": { | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Primitive{ | ||
Primitive: &core.Primitive{ | ||
Value: &core.Primitive_Integer{ | ||
Integer: 4, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestOffloadLiteralMap(t *testing.T) { | ||
mockStorage := commonMocks.GetMockStorageClient() | ||
mockStorage.ComposedProtobufStore.(*commonMocks.TestDataStore).WriteProtobufCb = func(ctx context.Context, reference storage.DataReference, opts storage.Options, msg proto.Message) error { | ||
assert.Equal(t, reference.String(), "s3://bucket/metadata/nested/key") | ||
return nil | ||
} | ||
|
||
uri, err := OffloadLiteralMap(context.TODO(), mockStorage, literalMap, "nested", "key") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "s3://bucket/metadata/nested/key", uri.String()) | ||
} | ||
|
||
func TestOffloadLiteralMap_ConstructReferenceError(t *testing.T) { | ||
mockStorage := commonMocks.GetMockStorageClient() | ||
mockStorage.ComposedProtobufStore.(*commonMocks.TestDataStore).ConstructReferenceCb = func( | ||
ctx context.Context, reference storage.DataReference, nestedKeys ...string) (storage.DataReference, error) { | ||
return "foo", errors.NewFlyteAdminError(codes.Internal, "foo") | ||
} | ||
_, err := OffloadLiteralMap(context.TODO(), mockStorage, literalMap, "nested", "key") | ||
assert.Equal(t, err.(errors.FlyteAdminError).Code(), codes.Internal) | ||
} | ||
|
||
func TestOffloadLiteralMap_StorageFailure(t *testing.T) { | ||
mockStorage := commonMocks.GetMockStorageClient() | ||
mockStorage.ComposedProtobufStore.(*commonMocks.TestDataStore).WriteProtobufCb = func(ctx context.Context, reference storage.DataReference, opts storage.Options, msg proto.Message) error { | ||
assert.Equal(t, reference.String(), "s3://bucket/metadata/nested/key") | ||
return errors.NewFlyteAdminError(codes.Internal, "foo") | ||
} | ||
_, err := OffloadLiteralMap(context.TODO(), mockStorage, literalMap, "nested", "key") | ||
assert.Equal(t, err.(errors.FlyteAdminError).Code(), codes.Internal) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package transformers | ||
|
||
// OutputsObjectSuffix is used when execution event data includes inline outputs but the admin deployment is configured | ||
// to offload such data. The generated file path for the offloaded data will include the execution identifier and this suffix. | ||
const OutputsObjectSuffix = "offloaded_outputs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.