Esempio n. 1
0
def test_fetch_execute_launch_plan_with_subworkflows(flyteclient,
                                                     flyte_workflows_register):
    remote = FlyteRemote(Config.auto(), PROJECT, "development")

    flyte_launch_plan = remote.fetch_launch_plan(
        name="workflows.basic.subworkflows.parent_wf", version=f"v{VERSION}")
    execution = remote.execute(flyte_launch_plan, {"a": 101}, wait=True)
    # check node execution inputs and outputs
    assert execution.node_executions["n0"].inputs == {"a": 101}
    assert execution.node_executions["n0"].outputs == {
        "t1_int_output": 103,
        "c": "world"
    }
    assert execution.node_executions["n1"].inputs == {"a": 103}
    assert execution.node_executions["n1"].outputs == {
        "o0": "world",
        "o1": "world"
    }

    # check subworkflow task execution inputs and outputs
    subworkflow_node_executions = execution.node_executions[
        "n1"].subworkflow_node_executions
    subworkflow_node_executions["n1-0-n0"].inputs == {"a": 103}
    subworkflow_node_executions["n1-0-n1"].outputs == {
        "t1_int_output": 107,
        "c": "world"
    }
Esempio n. 2
0
def test_fetch_execute_launch_plan_list_of_floats(flyteclient,
                                                  flyte_workflows_register):
    remote = FlyteRemote(Config.auto(), PROJECT, "development")
    flyte_launch_plan = remote.fetch_launch_plan(
        name="workflows.basic.list_float_wf.my_wf", version=f"v{VERSION}")
    xs: typing.List[float] = [42.24, 999.1, 0.0001]
    execution = remote.execute(flyte_launch_plan, inputs={"xs": xs}, wait=True)
    assert execution.outputs["o0"] == "[42.24, 999.1, 0.0001]"
Esempio n. 3
0
def test_fetch_execute_launch_plan_with_child_workflows(
        flyteclient, flyte_workflows_register):
    remote = FlyteRemote(Config.auto(), PROJECT, "development")

    flyte_launch_plan = remote.fetch_launch_plan(
        name="workflows.basic.child_workflow.parent_wf", version=f"v{VERSION}")
    execution = remote.execute(flyte_launch_plan, {"a": 3}, wait=True)

    # check node execution inputs and outputs
    assert execution.node_executions["n0"].inputs == {"a": 3}
    assert execution.node_executions["n0"].outputs["o0"] == 6
    assert execution.node_executions["n1"].inputs == {"a": 6}
    assert execution.node_executions["n1"].outputs["o0"] == 12
    assert execution.node_executions["n2"].inputs == {"a": 6, "b": 12}
    assert execution.node_executions["n2"].outputs["o0"] == 18
Esempio n. 4
0
def test_monitor_workflow_execution(flyteclient, flyte_workflows_register,
                                    flyte_remote_env):
    remote = FlyteRemote(Config.auto(), PROJECT, "development")
    flyte_launch_plan = remote.fetch_launch_plan(
        name="workflows.basic.hello_world.my_wf", version=f"v{VERSION}")
    execution = remote.execute(flyte_launch_plan, {})

    poll_interval = datetime.timedelta(seconds=1)
    time_to_give_up = datetime.datetime.utcnow() + datetime.timedelta(
        seconds=60)

    execution = remote.sync_execution(execution, sync_nodes=True)
    while datetime.datetime.utcnow() < time_to_give_up:

        if execution.is_done:
            break

        with pytest.raises(
                FlyteAssertion,
                match=
                "Please wait until the node execution has completed before requesting the outputs"
        ):
            execution.outputs

        time.sleep(poll_interval.total_seconds())
        execution = remote.sync_execution(execution, sync_nodes=True)

        if execution.node_executions:
            assert execution.node_executions[
                "start-node"].closure.phase == 3  # SUCCEEEDED

    for key in execution.node_executions:
        assert execution.node_executions[key].closure.phase == 3

    assert execution.node_executions["n0"].inputs == {}
    assert execution.node_executions["n0"].outputs["o0"] == "hello world"
    assert execution.node_executions["n0"].task_executions[0].inputs == {}
    assert execution.node_executions["n0"].task_executions[0].outputs[
        "o0"] == "hello world"
    assert execution.inputs == {}
    assert execution.outputs["o0"] == "hello world"
Esempio n. 5
0
def fetch_execute_launch_plan_with_args(flyteclient, flyte_workflows_register):
    remote = FlyteRemote(Config.auto(), PROJECT, "development")
    flyte_launch_plan = remote.fetch_launch_plan(
        name="workflows.basic.basic_workflow.my_wf", version=f"v{VERSION}")
    execution = remote.execute(flyte_launch_plan, {
        "a": 10,
        "b": "foobar"
    },
                               wait=True)
    assert execution.node_executions["n0"].inputs == {"a": 10}
    assert execution.node_executions["n0"].outputs == {
        "t1_int_output": 12,
        "c": "world"
    }
    assert execution.node_executions["n1"].inputs == {
        "a": "world",
        "b": "foobar"
    }
    assert execution.node_executions["n1"].outputs == {"o0": "foobarworld"}
    assert execution.node_executions["n0"].task_executions[0].inputs == {
        "a": 10
    }
    assert execution.node_executions["n0"].task_executions[0].outputs == {
        "t1_int_output": 12,
        "c": "world"
    }
    assert execution.node_executions["n1"].task_executions[0].inputs == {
        "a": "world",
        "b": "foobar"
    }
    assert execution.node_executions["n1"].task_executions[0].outputs == {
        "o0": "foobarworld"
    }
    assert execution.inputs["a"] == 10
    assert execution.inputs["b"] == "foobar"
    assert execution.outputs["o0"] == 12
    assert execution.outputs["o1"] == "foobarworld"
Esempio n. 6
0
def test_fetch_execute_launch_plan(flyteclient, flyte_workflows_register):
    remote = FlyteRemote(Config.auto(), PROJECT, "development")
    flyte_launch_plan = remote.fetch_launch_plan(
        name="workflows.basic.hello_world.my_wf", version=f"v{VERSION}")
    execution = remote.execute(flyte_launch_plan, {}, wait=True)
    assert execution.outputs["o0"] == "hello world"
Esempio n. 7
0
def test_fetch_not_exist_launch_plan(flyteclient):
    remote = FlyteRemote(Config.auto(), PROJECT, "development")
    with pytest.raises(FlyteEntityNotExistException):
        remote.fetch_launch_plan(name="workflows.basic.list_float_wf.fake_wf",
                                 version=f"v{VERSION}")