# Collection Tasks


The tasks in this module can be used to represent collections of task results, such as lists, tuples, sets, and dictionaries.

In general, users will not instantiate these tasks by hand; they will automatically be applied when users create dependencies between a task and a collection of other objects.

# List

class

prefect.tasks.core.collections.List

(*args, **kwargs)[source]

Collects task results into a list.

Args:

  • *args (Any): positional arguments for the Task class
  • **kwargs (Any): keyword arguments for the Task class

methods:                                                                                                                                                       

prefect.tasks.core.collections.List.run

(**task_results)[source]

Args:

  • **task_results (Any): task results to collect into a list
Returns:
  • list: a list of task results



# Tuple

class

prefect.tasks.core.collections.Tuple

(*args, **kwargs)[source]

Collects task results into a tuple.

Args:

  • *args (Any): positional arguments for the Task class
  • **kwargs (Any): keyword arguments for the Task class

methods:                                                                                                                                                       

prefect.tasks.core.collections.Tuple.run

(**task_results)[source]

Args:

  • **task_results (Any): task results to collect into a tuple
Returns:
  • tuple: a tuple of task results



# Set

class

prefect.tasks.core.collections.Set

(*args, **kwargs)[source]

Collects task results into a set.

Args:

  • *args (Any): positional arguments for the Task class
  • **kwargs (Any): keyword arguments for the Task class

methods:                                                                                                                                                       

prefect.tasks.core.collections.Set.run

(**task_results)[source]

Args:

  • **task_results (Any): task results to collect into a set
Returns:
  • set: a set of task results



# Dict

class

prefect.tasks.core.collections.Dict

(*args, **kwargs)[source]

Collects task results into a dict.

Args:

  • *args (Any): positional arguments for the Task class
  • **kwargs (Any): keyword arguments for the Task class

methods:                                                                                                                                                       

prefect.tasks.core.collections.Dict.run

(keys, values)[source]

Args:

  • keys (Iterable[Any]): a list of keys that will form the dictionary
  • values (Iterable[Any]): a list of values for the dictionary
Returns:
  • dict: a dict of task results
Raises:
  • ValueError: if the number of keys and the number of values are different



This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC