Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose subworkflow inputs, outputs in node execution #503

Merged
merged 8 commits into from
Jun 4, 2021

Conversation

cosmicBboy
Copy link
Contributor

@cosmicBboy cosmicBboy commented Jun 2, 2021

Signed-off-by: cosmicBboy [email protected]

TL;DR

Add support for inspecting inputs and outputs of subworkflows in the control plane objects.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

As a user, I can get a FlyteWorkflowExecution and access the inputs and outputs of its child node executions, including subworkflows. This is enabled by adding support in FlyteNodeExecution for determining whether it is associated with a task or a subworkflow via the metadata.is_parent_node attribute.

wf_exec = FlyteWorkflowExecution.fetch(...)
wf_exec.wait_for_completion()

for node_exec in wf_exec.node_executions:
    if node_exec.metadata.is_parent_node:
       node_exec.subworkflow_node_executions  # Dict[str, FlyteNodeExecution]
       node_exec.inputs  # subworkflow inputs
       node_exec.outputs  # subworkflow outputs
    else:
       node_exec.task_executions  # List[TaskExecution]
       node_exec.inputs  # task inputs
       node_exec.outputs  # task outputs

Tracking Issue

flyteorg/flyte#975

Follow-up issue

NA
OR
https://github.com/lyft/flyte/issues/

Signed-off-by: cosmicBboy <[email protected]>
Signed-off-by: cosmicBboy <[email protected]>
@codecov
Copy link

codecov bot commented Jun 3, 2021

Codecov Report

Merging #503 (0f1e987) into master (3497045) will increase coverage by 0.17%.
The diff coverage is 90.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #503      +/-   ##
==========================================
+ Coverage   85.00%   85.17%   +0.17%     
==========================================
  Files         364      366       +2     
  Lines       27456    27762     +306     
  Branches     2243     2263      +20     
==========================================
+ Hits        23339    23647     +308     
+ Misses       3500     3492       -8     
- Partials      617      623       +6     
Impacted Files Coverage Δ
flytekit/clients/helpers.py 58.82% <ø> (ø)
flytekit/control_plane/component_nodes.py 69.35% <0.00%> (+12.90%) ⬆️
flytekit/control_plane/nodes.py 74.55% <89.18%> (+8.10%) ⬆️
flytekit/clients/friendly.py 66.66% <100.00%> (+1.37%) ⬆️
flytekit/control_plane/tasks/task.py 95.83% <100.00%> (+0.08%) ⬆️
flytekit/control_plane/workflow.py 67.41% <100.00%> (+0.37%) ⬆️
flytekit/models/node_execution.py 89.61% <100.00%> (ø)
...lytekit/integration/control_plane/test_workflow.py 98.59% <100.00%> (+0.23%) ⬆️
tests/flytekit/unit/core/test_references.py 96.59% <0.00%> (-0.68%) ⬇️
flytekit/core/promise.py 77.26% <0.00%> (-0.13%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3497045...0f1e987. Read the comment docs.

flytekit/clients/friendly.py Outdated Show resolved Hide resolved
def executions(self) -> _artifact_mixin.ExecutionArtifact:
return self.task_executions or self.workflow_executions or []
def executions(self) -> List[_artifact_mixin.ExecutionArtifact]:
return self.task_executions or list(self.subworkflow_node_executions.values()) or []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the latter half of this just self._subworkflow_node_executions? why the transformations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_subworkflow_node_executions is a Dict mapping node id to node execution, so it needs to be transformed to output a list of node executions.

We could alternatively have executions output a Union[List, Dict] depending on whether it's task executions of subworkflow node executions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the property subworkflow_node_executions is a Dict (see above)... we don't have to convert it into a dict, but I found it convenient to be able to access the subworkflow node executions by node_id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right but we don't necessarily need to access these through the property since it's all in the same class right? sorry this is a minor performance nit and not really worth refactoring :)

flytekit/control_plane/nodes.py Outdated Show resolved Hide resolved
for t in _iterate_task_executions(client, self.id)
]
# TODO: sync sub-workflows as well
if self.metadata.is_parent_node:
Copy link
Contributor

@wild-endeavor wild-endeavor Jun 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this field true for the parent node of a dynamic workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to test that... in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be false for dynamic workflows

katrogan
katrogan previously approved these changes Jun 4, 2021
Signed-off-by: cosmicBboy <[email protected]>
@cosmicBboy cosmicBboy merged commit abd6f9f into master Jun 4, 2021
@cosmicBboy cosmicBboy deleted the controlplane-subworkflows branch June 7, 2021 13:54
EngHabu pushed a commit that referenced this pull request Jun 25, 2021
* expose subworkflow inputs, outputs in node execution

Signed-off-by: cosmicBboy <[email protected]>

* fix lint

Signed-off-by: cosmicBboy <[email protected]>

* add docstring

Signed-off-by: cosmicBboy <[email protected]>

* add docstring to list_node_executions, update sync logic

Signed-off-by: cosmicBboy <[email protected]>

* add comment to subworkflow get_interface @wild-endeavor

Signed-off-by: cosmicBboy <[email protected]>

* update executions property

Signed-off-by: cosmicBboy <[email protected]>

* cache interface for node execution, redefine as property

Signed-off-by: cosmicBboy <[email protected]>

* fix lint

Signed-off-by: cosmicBboy <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>
wild-endeavor pushed a commit that referenced this pull request Jun 30, 2021
* expose subworkflow inputs, outputs in node execution

Signed-off-by: cosmicBboy <[email protected]>

* fix lint

Signed-off-by: cosmicBboy <[email protected]>

* add docstring

Signed-off-by: cosmicBboy <[email protected]>

* add docstring to list_node_executions, update sync logic

Signed-off-by: cosmicBboy <[email protected]>

* add comment to subworkflow get_interface @wild-endeavor

Signed-off-by: cosmicBboy <[email protected]>

* update executions property

Signed-off-by: cosmicBboy <[email protected]>

* cache interface for node execution, redefine as property

Signed-off-by: cosmicBboy <[email protected]>

* fix lint

Signed-off-by: cosmicBboy <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
wild-endeavor pushed a commit that referenced this pull request Jun 30, 2021
* expose subworkflow inputs, outputs in node execution

Signed-off-by: cosmicBboy <[email protected]>

* fix lint

Signed-off-by: cosmicBboy <[email protected]>

* add docstring

Signed-off-by: cosmicBboy <[email protected]>

* add docstring to list_node_executions, update sync logic

Signed-off-by: cosmicBboy <[email protected]>

* add comment to subworkflow get_interface @wild-endeavor

Signed-off-by: cosmicBboy <[email protected]>

* update executions property

Signed-off-by: cosmicBboy <[email protected]>

* cache interface for node execution, redefine as property

Signed-off-by: cosmicBboy <[email protected]>

* fix lint

Signed-off-by: cosmicBboy <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants