Hi all! Is there a way to force an input string to...
# flyte-support
i
Hi all! Is there a way to force an input string to be json structured on the UI, same as when the input is a dataclass ? as shown in the screenshot
d
Use default input
i
can you elaborate more?
you mean add a default value that is a json ?
d
oh you don't have to use default input
just copy the input value like this
image.png
Copy code
{
  "input": {
    "d": {
      "f": [
        1,
        2,
        3
      ],
      "e": 1
    },
    "c": [
      1,
      2,
      3
    ],
    "b": 2,
    "a": 1
  }
}
you can get something like this
than you can use it as input
i
sorry, but i think you missed my point. I need the input field to have a struct validation. the field is meant to be for free input, but need to be json parsable .
d
can you give me an example?
a task
python code
i
Copy code
@task
def do_something(inp: Union[str, List[Dict[str, str]]]) -> bool:
    return True


@workflow
def wf(inp: (What type annotation should I use here?)) -> bool:
    return do_something(inp=inp)
if I use
Union[str, List[Dict[str, str]]]
the UI is buggy:
d
oh no....
i
so I want something like this
d
if you give a default input here, you can copy the input struct json in the flyteconsole, and then you can find the pattern to generate the struct.
Copy code
@task
def do_something(inp: Union[str, List[Dict[str, str]]]) -> bool:
    return True


@workflow
def wf(inp: (GIVE DEFAULT INPUT)) -> bool:
    return do_something(inp=inp)
i
there is no input struct json
I want to get to that point .
d
oh
i
i used a dataclass just to take the screenshot.. but a dataclass doesnt work with map_task so I cant use it
d
you mean you don't have choice
oh no
cc Frontend team