Skip to content
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

[wip] Use Json type to represent naked dictionaries #2399

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eapolinario
Copy link
Collaborator

@eapolinario eapolinario commented May 8, 2024

Tracking issue

flyteorg/flyte#5318

Why are the changes needed?

As described in flyteorg/flyte#5318, we can use a json string as the transport for a variety of types, including naked dictionaries.

What changes were proposed in this pull request?

Leverage the new Json type defined in flyteorg/flyte#5337 to replace the usage of protobuf Struct as the transport for naked dictionaries with a json-encoded string.

Keep in mind that this is WIP. TODO:

  1. define how custom encoders are passed in, if necessary,
  2. make this backwards compatible with the old Struct
  3. fix+add tests

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

def to_literal(
self, ctx: FlyteContext, python_val: typing.Any, python_type: Type[dict], expected: LiteralType
) -> Literal:
if type(python_val) != dict:
raise TypeTransformerFailedError("Expected a dict")

if expected and expected.simple and expected.simple == SimpleType.STRUCT:
# TODO: back-compat with struct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do any backwards compat right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants