<#4398 [BUG] Having a approval gate in workflow se...
# flyte-github
a
#4398 [BUG] Having a approval gate in workflow seems to break remote.execute(wait=True) Issue created by EraYaN OS: Ubuntu 22.04 k8s: 1.27.1 Python: 3.10.12 Pip versions: flyteidl==1.5.19 flytekit==1.9.1 Flytectl version: { "App": "flytectl", "Build": "145bc5c", "Version": "0.6.45", "BuildTime": "2023-11-10 125147.268046582 +0100 CET m=+0.038245793" }{ "App": "controlPlane", "Build": "unknown", "Version": "unknown", "BuildTime": "2023-10-31 120708.85536627 +0000 UTC m=+0.029484135" } Helm:
Copy code
helm list -n flyte
NAME            NAMESPACE       REVISION        UPDATED                                         STATUS          CHART                   APP VERSION
flyte-backend   flyte           23              2023-09-25 17:27:47.302198664 +0200 CEST        deployed        flyte-binary-v1.9.1     1.16.0
Using this example
Copy code
"""A simple Flyte example."""

import typing
from flytekit import task, workflow, approve
import datetime

APPROVE_TIMEOUT = datetime.timedelta(hours=24)

@task 
def model_version() -> str:
    return "1.0.0"

@task
def respond(greeting: str) -> str:
    """A simple Flyte task to acknowledge the greeting "hello".

    The @task decorator allows Flyte to use this function as a Flyte task, which
    is executed as an isolated, containerized unit of compute.
    """
    return f"Nice greeting '{greeting}'!"

@task
def say_hello(name: str, version: str) -> str:
    """A simple Flyte task to say "hello".

    The @task decorator allows Flyte to use this function as a Flyte task, which
    is executed as an isolated, containerized unit of compute.
    """
    return f"hello {name}! using version {version}"


@task
def greeting_length(greeting: str) -> int:
    """A task the counts the length of a greeting."""
    return len(greeting)

@workflow
def wf(name: str = "union") -> typing.Tuple[str, int, str]:
    """Declare workflow called `wf`.

    The @workflow decorator defines an execution graph that is composed of tasks
    and potentially sub-workflows. In this simple example, the workflow is
    composed of just one task.

    There are a few important things to note about workflows:
    - Workflows are a domain-specific language (DSL) for creating execution
      graphs and therefore only support a subset of Python's behavior.
    - Tasks must be invoked with keyword arguments
    - The output variables of tasks are Promises, which are placeholders for
      values that are yet to be materialized, not the actual values.
    """
    version = model_version()
    greeting = say_hello(name=name, version=version)
    greeting_len = greeting_length(greeting=greeting)
    approved_greeting = approve(greeting, "check_greeting", APPROVE_TIMEOUT) # https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/advanced_composition/waiting_for_external_inputs.html#continue-executions-with-approve
    response = sub_wf(greeting=approved_greeting)
    return greeting, greeting_len, response


@workflow
def sub_wf(greeting: str = "main") -> str:
    """Declare workflow called `sub_wf`.
    """
    
    return respond(greeting=greeting)

if __name__ == "__main__":
    # Execute the workflow, simply by invoking it like a function and passing in
    # the necessary parameters
    print(f"Running wf() { wf(name='passengers') }")
Registered with
Copy code
pyflyte register -p test -d development test
And this script:
Copy code
#!/usr/bin/env python3

from flytekit.remote import FlyteRemote
from flytekit.configuration import Config

remote = FlyteRemote(config=Config.auto(),default_domain="development",default_project="test")

flyte_launchplan = remote.fetch_launch_plan(name="test.workflows.example.wf")
execution = remote.execute(flyte_launchplan, inputs={"name": "Flyte"}, wait=True)

print(execution.id)

print(execution.outputs)
Gives the following output (ran from WSL with flyte running in a k8s cluster on the LAN):
Copy code
> ./execute.py
 /mnt/c/Users/ErwindeHaan/source/repos/flyte-experiments/./execute.py:9 in <module>    
 ❱  9 execution = remote.execute(flyte_launchplan, inputs={"name": "Erwin de Haan"}, wait=True   
/home/erwin/.local/lib/python3.10/site-packages/flytekit/remote/remote.py:1155 in execute     
❱ 1155 │   │   │   return self.execute_remote_task_lp(       
/home/erwin/.local/lib/python3.10/site-packages/flytekit/remote/remote.py:1256 in execute_remote_task_lp   
❱ 1256 │   │   return self._execute(     
/home/erwin/.local/lib/python3.10/site-packages/flytekit/remote/remote.py:1063 in _execute        
❱ 1063 │   │   │   return self.wait(execution)    
/home/erwin/.local/lib/python3.10/site-packages/flytekit/remote/remote.py:1535 in wait
❱ 1535 │   │   │   execution = self.sync_execution(execution, sync_nodes=sync_nodes)  
/home/erwin/.local/lib/python3.10/site-packages/flytekit/remote/remote.py:1630 in sync_execution          
❱ 1630 │   │   │   │   node_execs[n.id.node_id] = self.sync_node_execution(n, node_mapping)  #   
/home/erwin/.local/lib/python3.10/site-packages/flytekit/remote/remote.py:1771 in sync_node_execution
❱ 1771 │   │   │   execution._interface = execution._node.flyte_entity.interface 

AttributeError: 'FlyteGateNode' object has no attribute 'interface'
if I remove the approval gate and pass the greeting directly to the sub workflow I get the expected output:
Copy code
<FlyteLiteral project: "test" domain: "development" name: "f2c5622283dda41b6b34">
Partially converted to native values, call get(key, <type_hint>) to convert rest...
{
  o2:
      <FlyteLiteral scalar { primitive { string_value: "Wow nice greeting \'hello Flyte! using model version 1.0.0\'!" } }>o0:
      <FlyteLiteral scalar { primitive { string_value: "hello Erwin de Haan! using model version 1.0.0" } }>o1:
      <FlyteLiteral scalar { primitive { integer: 46 } }>
}
Notes: Also just tried with latest versions of flytekit 1.10.0 and flyte helm chart 1.10.0 still same behaviour flyteorg/flyte