Hi! If I define a workflow with a dataclass/struc...
# announcements
b
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
sorry, what do you mean by introspecting the fields of the
STRUCT
b
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
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
@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
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>")
205 Views