is there a flyte literal parser utility to produce...
# flytekit
d
is there a flyte literal parser utility to produce the json that gets surfaced in the flyte UI?
y
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
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
for which object?
a task?
or like a flyte literal integer 3
d
the latter
LiteralMap -> json, or dict etc
y
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
Ah but this containers the literal types like primitive stringvalue etc
y
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
Yea literally what appears in flyte console
y
unf that’s probably done in js/ts only
can ask nastya if you’d like?
d
That's fine. Just need the example
y
the code that does this?
d
Yes
y
@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
Carina could be a better person to check with as she is literally makes it better right now :)
c
@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
@Dylan Wilder there is some stuff in golang
this is what powers Flytectl
d
thanks ketan, this is what i was looking for! i had written this a while back but lost the code 🙂
👍 2
198 Views