# Results


The Result classes in this prefect.engine.result package are results used internally by the Prefect pipeline to track and store results without persistence.

If you are looking for the API docs for the result subclasses you can use to enable task return value checkpointing or to store task data, see the API docs for the Result Subclasses in prefect.engine.results.

# Result

class

prefect.engine.result.base.Result

(value=None, validators=None, run_validators=True, location=None, serializer=None)[source]

A representation of the result of a Prefect task; this class contains information about the value of a task's result, a result handler specifying how to serialize or store this value securely, and a safe_value attribute which holds information about the current "safe" representation of this result.

Args:

  • value (Any, optional): the value of the result
  • validators (Iterable[Callable], optional): Iterable of validation functions to apply to the result to ensure it is valid.
  • run_validators (bool): Whether the result value should be validated.
  • location (Union[str, Callable], optional): Possibly templated location to be used for saving the result to the destination. If a callable function is provided, it should have signature callable(**kwargs) -> str and at write time all formatting kwargs will be passed and a fully formatted location is expected as the return value. Can be used for string formatting logic that .format(**kwargs) doesn't support
  • serializer (Serializer): a serializer that can transform Python objects to bytes and recover them. The serializer is used whenever the Result is writing to or reading from storage. Defaults to PickleSerializer.

methods:                                                                                                                                                       

prefect.engine.result.base.Result.copy

()[source]

Return a copy of the current result object.

prefect.engine.result.base.Result.exists

(location, **kwargs)[source]

Checks whether the target result exists.

Does not validate whether the result is valid, only that it is present.

Args:

  • location (str, optional): Location of the result in the specific result target. If provided, will check whether the provided location exists; otherwise, will use self.location
  • **kwargs (Any): string format arguments for location
Returns:
  • bool: whether or not the target result exists.

prefect.engine.result.base.Result.format

(**kwargs)[source]

Takes a set of string format key-value pairs and renders the result.location to a final location string

Args:

  • **kwargs (Any): string format arguments for result.location
Returns:
  • Result: a new result instance with the appropriately formatted location

prefect.engine.result.base.Result.from_value

(value)[source]

Create a new copy of the result object with the provided value.

Args:

  • value (Any): the value to use
Returns:
  • Result: a new Result instance with the given value

prefect.engine.result.base.Result.read

(location)[source]

Reads from the target result and returns a corresponding Result instance.

Args:

  • location (str): Location of the result in the specific result target.
Returns:
  • Any: The value saved to the result.

prefect.engine.result.base.Result.validate

()[source]

Run any validator functions associated with this result and return whether the result is valid or not. All individual validator functions must return True for this method to return True. Emits a warning log if run_validators isn't true, and proceeds to run validation functions anyway.


Returns:

  • bool: whether or not the Result passed all validation functions

prefect.engine.result.base.Result.write

(value_, **kwargs)[source]

Serialize and write the result to the target location.

Args:

  • value_ (Any): the value to write; will then be stored as the value attribute of the returned Result instance
  • **kwargs (optional): if provided, will be used to format the location template to determine the location to write to
Returns:
  • Result: a new result object with the appropriately formatted location destination



This documentation was auto-generated from commit n/a
on July 1, 2021 at 18:35 UTC