Skip to content

Commit

Permalink
Updated named_outputs (flyteorg#675)
Browse files Browse the repository at this point in the history
Minor wording changes
Changed namedtuple to NamedTuple
Signed-off-by: SmritiSatyanV <[email protected]>
  • Loading branch information
SmritiSatyanV authored Mar 7, 2022
1 parent 5c4b2fd commit 88d248d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions cookbook/core/flyte_basics/named_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Named Outputs
-------------
By default, Flyte names the outputs of a task or workflow using a standardized convention. All outputs are named
By default, Flyte names the outputs of a task or workflow using a standardized convention. All the outputs are named
as ``o1, o2, o3, ... o<n>.`` where ``o`` is the standard prefix and ``1, 2, .. <n>`` is the index position within the return values.
It is also possible to name the outputs of a task or a workflow so that it's easier to refer to them while
debugging or visualizing them in the UI. This is not possible to do natively in Python, so Flytekit provides an
alternate way using ``typing.NamedTuple``.
It is possible to give custom names to the outputs of a task or a workflow, so it's easier to refer to them while
debugging or visualising them in the UI. This is not possible natively in Python, so Flytekit provides an
alternative using ``typing.NamedTuple``.
The following example shows how to name outputs of a task and a workflow.
"""
Expand All @@ -21,8 +21,8 @@
#
# .. note::
#
# Note the name of the NamedTuple does not matter, but the names and types of the variables do. We used a
# a default name like ``OP``. Also named tuples can be inline, but by convention we prefer to declare them, as pypy
# Note that the name of the NamedTuple does not matter, but the names and types of the variables do. We used a
# a default name like ``OP``. NamedTuples can be inline, but by convention we prefer to declare them, as pypy
# linter errors can be avoided this way.
#
# .. code-block::
Expand All @@ -39,18 +39,18 @@ def say_hello() -> hello_output:


# %%
# You can also declare the namedtuple ahead of time and then use it in the signature as follows:
# You can also declare the NamedTuple ahead of time and then use it in the signature as follows:
wf_outputs = typing.NamedTuple("OP2", greet1=str, greet2=str)


# %%
# As shown in this example, you can now refer to the declared namedtuple.
# Also as you can see in the workflow, ``say_hello`` returns a tuple, but as with other tuples, you can simply unbox
# it inline. Also the workflow itself returns a tuple. You can also construct the tuple as you return.
# As shown in this example, you can now refer to the declared NamedTuple.
# As seen in the workflow, ``say_hello`` returns a tuple. Like other tuples, you can simply unbox
# it inline. Also the workflow itself returns a tuple. You can also construct the tuple as you return the output.
#
# .. note::
#
# Note that we are de-referencing the individual task execution outputs because named-outputs use named-tuples
# Note that we are de-referencing the individual task execution outputs because named-outputs use NamedTuple
# which are tuples that need to be de-referenced.

@workflow
Expand Down

0 comments on commit 88d248d

Please sign in to comment.