-
Notifications
You must be signed in to change notification settings - Fork 671
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5542 +/- ##
==========================================
- Coverage 36.18% 34.61% -1.57%
==========================================
Files 1302 990 -312
Lines 109666 85001 -24665
==========================================
- Hits 39678 29424 -10254
+ Misses 65841 52667 -13174
+ Partials 4147 2910 -1237
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Yee Hing Tong <[email protected]>
Signed-off-by: Yee Hing Tong <[email protected]> Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
…and support json idl attribute access Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
108350f
to
a503b8b
Compare
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
if upstreamTypeCopy.GetSimple() == flyte.SimpleType_STRUCT && downstreamTypeCopy.GetSimple() == flyte.SimpleType_JSON { | ||
return true | ||
} |
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 for case like:
@reference_task(
project="flytesnacks",
domain="development",
name="create_reference_task.creat_reference_task_dict",
version="nNDnS6m4_fo-GXPxVUm2TA",
)
def t1(
) -> dict: # return STRUCT
...
@task(container_image=image)
def t2(input: dict) -> dict: # input STRUCT, return JSON
print(input)
for key, value in input.items():
print(f'Key: {key}, Value: {value}')
print(f'Key: {type(key)}, Value: {type(value)}')
return input
@workflow
def wf() -> dict:
d1 = t1()
d2 = t2(input=d1)
return d2
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 comment
The reason will be displayed to describe this comment to others. Learn more.
for creating execution by flytectl
.
flytectl create execution --execFile build/PR/JSON/demo/flytectl/create_json_dataclass.yaml -p flytesnacks -d development
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
func TestResolveAttrPathInJson(t *testing.T) { | ||
// Helper function to convert a map to JSON and then to msgpack |
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.
- Test the map type first, then test the list type.
- Within each category, order the tests by data type: integers (int), floats (float), strings (string), and nested maps or lists.
- Finally, arrange the exception case tests.
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
} | ||
currVal = convertNumbers(tmpVal) | ||
|
||
// Turn the current value to a map so it can be resolved more easily |
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.
hmm, where did you turn the current value to a map?
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 my fault, nice catch!!
return literal, nil | ||
} | ||
|
||
// convertJSONToLiteral converts the protobuf struct (e.g. dataclass) to literal |
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.
// convertJSONToLiteral converts the protobuf struct (e.g. dataclass) to literal | |
// convertJSONToLiteral converts the JSON (e.g. dataclass) to literal |
@eapolinario Can you review? |
Signed-off-by: Future-Outlier <[email protected]> Co-authored-by: Kevin Su <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
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.
Can you comment on the use of github.com/vmihailenco/msgpack to handle msgpack-encoded values? I see that this is not listed in the official msgpack website.
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
…aultLiteralForType Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
|
||
// The format used to serialize the byte array. | ||
// This field identifies the specific format of the serialized JSON data, | ||
// allowing future flexibility in supporting different JSON variants. |
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.
add a comment here saying that serialization formats need to be supported in python, golang, rust, and javascript, in order for the full flyte experience to work. (just throwing rust in there for now, we don't have anything yet).
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.
Yes, you're right, this is a pretty good and important advice, thank you.
|
||
// The format used to serialize the byte array. | ||
// This field identifies the specific format of the serialized JSON data, | ||
// allowing future flexibility in supporting different JSON variants. |
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.
remove the json part of this comment, it's no longer true.
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.
yes, thank you.
Move to #5742 |
Tracking issue
#5318
Why are the changes needed?
What changes were proposed in this pull request?
flyteidl
flytepropeller
upstreamType (Struct) -> downstreamType (Json)
flytectl
How was this patch tested?
unit tests and remote execution.
Example are from here
Setup process
Screenshots
[flytepropeller] attribute access
[flytepropeller] backward compatible
upstream (struct) -> downstream (json)
upstream (struct) -> downstream (json)
[flytepropeller] others
dict example
[flytectl] create execution with inputs
[flytectl] get task
Note: For struct and JSON, the input will be an empty {} or []. This is an existing bug, and I am not planning to fix it in this PR. I genuinely believe this is a relatively low-priority issue."
Check all the applicable boxes
Related PRs
Docs link