https://flyte.org logo
#flytekit
Title
# flytekit
d

Dylan Wilder

05/05/2022, 8:33 PM
is there a flyte literal parser utility to produce the json that gets surfaced in the flyte UI?
y

Yee

05/05/2022, 9:33 PM
there’s an informal one that I use. but it’s more of an internal utilty for us.
wait, what do you mean by literal parser?
sorry - i was referring to parsing protobufs
d

Dylan Wilder

05/05/2022, 9:43 PM
yea i just want something that produces a user friendly json, minus the literal wrappers
if you can just point us to code that's cool too
and we can reproduce
as long as it's not go 😄
y

Yee

05/05/2022, 9:45 PM
for which object?
a task?
or like a flyte literal integer 3
d

Dylan Wilder

05/05/2022, 9:57 PM
the latter
LiteralMap -> json, or dict etc
y

Yee

05/05/2022, 10:00 PM
i mean… the command I use is this
Copy code
flyte-cli parse-proto -f map_input.pb -p flyteidl.core.literals_pb2.LiteralMap
and you can take a peek at the code, it’s not much
this is all it does
it’s dumb because you have to know what type of protobuf you have.
d

Dylan Wilder

05/05/2022, 10:19 PM
Ah but this containers the literal types like primitive stringvalue etc
y

Yee

05/05/2022, 10:20 PM
oh you want a normal representation?
there’s nothing for that, short of converting them into pure python native values, but that’s complicated.
d

Dylan Wilder

05/05/2022, 10:20 PM
Yea literally what appears in flyte console
y

Yee

05/05/2022, 10:21 PM
unf that’s probably done in js/ts only
can ask nastya if you’d like?
d

Dylan Wilder

05/05/2022, 10:22 PM
That's fine. Just need the example
y

Yee

05/05/2022, 10:23 PM
the code that does this?
d

Dylan Wilder

05/05/2022, 10:23 PM
Yes
y

Yee

05/05/2022, 10:24 PM
@Nastya Rusina or @Carina Ursu - can you point us to the JS/TS code that prettifies the flyte literal values? so that you don’t get “Literal(Scalar(Primitive(….”
n

Nastya Rusina

05/05/2022, 10:26 PM
Carina could be a better person to check with as she is literally makes it better right now :)
c

Carina Ursu

05/05/2022, 10:41 PM
@Dylan Wilder our existing code is processing the json directly into ui, you can look here as an entry point https://github.com/flyteorg/flyteconsole/blob/master/src/components/Literals/LiteralMapViewer.tsx The current change in progress would simplify the structure and then display it in the UI as raw json https://github.com/flyteorg/flyteconsole/pull/445 (entrypoint through src/components/Literals/helpers.ts : transformLiteralMap)
k

Ketan (kumare3)

05/05/2022, 11:12 PM
@Dylan Wilder there is some stuff in golang
this is what powers Flytectl
d

Dylan Wilder

05/06/2022, 12:50 PM
thanks ketan, this is what i was looking for! i had written this a while back but lost the code 🙂
👍 2
16 Views