https://flyte.org logo
#announcements
Title
# announcements
b

Bernhard Stadlbauer

05/03/2022, 7:37 AM
Hi! If I define a workflow with a dataclass/struct as input, along the lines of:
Copy code
@dataclass_json
@dataclass
class Foo:
    bar: int
    baz: float
    

@workflow
def my_wf(foo: Foo):
    ...
Is it possible to introspect the fields of the
STRUCT
or is this checked at runtime?
k

Kevin Su

05/03/2022, 9:08 AM
sorry, what do you mean by introspecting the fields of the
STRUCT
b

Bernhard Stadlbauer

05/03/2022, 9:19 AM
Is there a way within
flytectl
or
FlyteRemote
to get the values and types of the struct? In the example above, what I would be interested in is to determine that
Foo
has two inputs
bar: int
and
baz: float
by inspecting the Workflow (or LaunchPlan)
my_wf
k

Kevin Su

05/03/2022, 2:14 PM
yes, you can use flyte remote to get the type and value. something like below:
Copy code
from flytekit.configuration import Config
from flytekit.remote import FlyteRemote

remote = FlyteRemote(Config.auto(), default_project="flytesnacks", default_domain="development")
exec = remote.fetch_execution(name="f67cb4cc7ad6b46a6b80")
print(exec.inputs.get("foo").x)
print(type(exec.inputs.get("foo").y))
print(exec.inputs.variable_map) # Get JsonSchema of foo
b

Bernhard Stadlbauer

05/10/2022, 8:54 AM
@Kevin Su Would this also be possible for LaunchPlan which has not been executed yet? I.e. inspecting which parameters it would need (in case of a dataclass/Struct input)
k

Kevin Su

05/10/2022, 11:36 PM
yes, you can use
fetch_launch_plan
.
Copy code
lp = remote.fetch_launch_plan(name="<http://raw_container.workflows.example.wf|raw_container.workflows.example.wf>")
49 Views