-
Notifications
You must be signed in to change notification settings - Fork 680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON IDL #5542
JSON IDL #5542
Changes from 13 commits
d26c228
a5d515d
707a013
5d85d16
fa8bbd5
a503b8b
0b32845
1dcfbc4
d5d7b79
c7c82ac
00d6e2b
a005a2d
7ece699
8c0ab5c
b3543e5
cb2876c
aa68c42
ded1f7c
62b7aa4
e44d309
b099d06
df99f28
9fe07af
5e2b35d
77ea3ed
e5af3a3
3f155d6
19bac6a
bade905
4e3c28f
b523b9d
2cf54c3
1b0edc8
fa8cca2
a56d56a
5adafcc
cf95f40
1631a94
6f07cdd
44da0cd
2a12ce2
27dbc63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,19 +4,19 @@ | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/vmihailenco/msgpack/v5" | ||
"math" | ||
"reflect" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/flyteorg/flyte/flytestdlib/storage" | ||
"github.com/golang/protobuf/jsonpb" | ||
"github.com/golang/protobuf/ptypes" | ||
structpb "github.com/golang/protobuf/ptypes/struct" | ||
"github.com/pkg/errors" | ||
|
||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/flyteorg/flyte/flytestdlib/storage" | ||
) | ||
|
||
func MakePrimitive(v interface{}) (*core.Primitive, error) { | ||
|
@@ -250,6 +250,18 @@ | |
}, | ||
}, | ||
}, nil | ||
case core.SimpleType_JSON: | ||
return &core.Literal{ | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Json{ | ||
Json: &core.Json{ | ||
Value: []byte(""), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} | ||
return nil, errors.Errorf("Not yet implemented. Default creation is not yet implemented for [%s] ", t.Simple.String()) | ||
case *core.LiteralType_Blob: | ||
|
@@ -385,6 +397,12 @@ | |
scalar.Value = &core.Scalar_Generic{ | ||
Generic: st, | ||
} | ||
case core.SimpleType_JSON: | ||
scalar.Value = &core.Scalar_Json{ | ||
Json: &core.Json{ | ||
Value: []byte(s), | ||
}, | ||
} | ||
case core.SimpleType_BINARY: | ||
scalar.Value = &core.Scalar_Binary{ | ||
Binary: &core.Binary{ | ||
|
@@ -567,6 +585,19 @@ | |
strValue = string(byteValue) | ||
} | ||
} | ||
if newT.Simple == core.SimpleType_JSON { | ||
if _, isValueStringType := v.(string); !isValueStringType { | ||
jsonBytes, err := json.Marshal(v) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to marshal to json string for json value %v", v) | ||
} | ||
jsonBytes, err = msgpack.Marshal(jsonBytes) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to marshal to msgpack bytes for json value %v", v) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for creating execution by flytectl create execution --execFile build/PR/JSON/demo/flytectl/create_json_dataclass.yaml -p flytesnacks -d development |
||
} | ||
strValue = string(jsonBytes) | ||
} | ||
} | ||
lv, err := MakeLiteralForSimpleType(newT.Simple, strValue) | ||
if err != nil { | ||
return nil, err | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is covered by
flyteidl/clients/go/coreutils/literals.go