Skip to content

Commit

Permalink
Docs update (751774b)
Browse files Browse the repository at this point in the history
  • Loading branch information
promptless[bot] authored Nov 5, 2024
1 parent 231bfc2 commit 3c6fe26
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
21 changes: 7 additions & 14 deletions docs/3.0/develop/results.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ See [settings](/3.0/manage/settings-and-profiles) for more information on how se

There are four categories of configuration for result persistence:
- [whether to persist results at all](/3.0/develop/results#enabling-result-persistence): this is configured through
various keyword arguments and the `PREFECT_RESULTS_PERSIST_BY_DEFAULT` setting.
various keyword arguments, the `PREFECT_RESULTS_PERSIST_BY_DEFAULT` setting, and the `PREFECT_TASKS_DEFAULT_PERSIST_RESULT` setting for tasks specifically.
- [what filesystem to persist results to](/3.0/develop/results#result-storage): this is configured through the `result_storage`
keyword and the `PREFECT_DEFAULT_RESULT_STORAGE_BLOCK` setting.
- [how to serialize and deserialize results](/3.0/develop/results#result-serialization): this is configured through
the `result_serializer` keyword and the `PREFECT_RESULTS_DEFAULT_SERIALIZER` setting.
- [what filename to use](/3.0/develop/results#result-filenames): this is configured through one of
`result_storage_key`, `cache_policy`, or `cache_key_fn`.

### Default persistence configuration

Once result persistence is enabled - whether through the `PREFECT_RESULTS_PERSIST_BY_DEFAULT` setting or
Expand All @@ -51,31 +50,25 @@ prefect config set PREFECT_LOCAL_STORAGE_PATH='~/.my-results/'

### Enabling result persistence

In addition to the `PREFECT_RESULTS_PERSIST_BY_DEFAULT` setting, result persistence can also be
enabled or disabled on both individual flows and individual tasks.
Specifying a non-null value for any of the following keywords on the task decorator will enable result
persistence for that task:
In addition to the `PREFECT_RESULTS_PERSIST_BY_DEFAULT` and `PREFECT_TASKS_DEFAULT_PERSIST_RESULT` settings, result persistence can also be enabled or disabled on both individual flows and individual tasks. Specifying a non-null value for any of the following keywords on the task decorator will enable result persistence for that task:
- `persist_result`: a boolean that allows you to explicitly enable or disable result persistence.
- `result_storage`: accepts either a string reference to a storage block or a storage block class that
specifies where results should be stored.
- `result_storage`: accepts either a string reference to a storage block or a storage block class that specifies where results should be stored.
- `result_storage_key`: a string that specifies the filename of the result within the task's result storage.
- `result_serializer`: a string or serializer that configures how the data should be serialized and deserialized.
- `cache_policy`: a [cache policy](/3.0/develop/task-caching#cache-policies) specifying the behavior of the task's cache.
- `cache_key_fn`: [a function](/3.0/develop/task-caching#cache-key-functions) that configures a custom cache policy.

Similarly, setting `persist_result=True`, `result_storage`, or `result_serializer` on a flow will enable
persistence for that flow.
Similarly, setting `persist_result=True`, `result_storage`, or `result_serializer` on a flow will enable persistence for that flow.

<Note>
**Enabling persistence on a flow enables persistence by default for its tasks**

Enabling result persistence on a flow through any of the above keywords will also enable it for all
tasks called within that flow by default.
Enabling result persistence on a flow through any of the above keywords will also enable it for all tasks called within that flow by default.

Any settings _explicitly_ set on a task take precedence over the flow settings.

Additionally, the `PREFECT_TASKS_DEFAULT_PERSIST_RESULT` environment variable can be used to globally control the default persistence behavior for tasks, overriding the default behavior set by a parent flow or task.
</Note>

### Result storage

You can configure the system of record for your results through the `result_storage` keyword argument.
Expand All @@ -84,6 +77,7 @@ Note that if you want your tasks to share a common cache, your result storage sh
the infrastructure in which those tasks run. [Integrations](/integrations/integrations) have cloud-specific storage blocks.
For example, a common distributed filesystem for result storage is AWS S3.

Additionally, you can control the default persistence behavior for task results using the `default_persist_result` setting. This setting allows you to specify whether results should be persisted by default for all tasks. You can set this to `True` to enable persistence by default, or `False` to disable it. This setting can be overridden at the individual task or flow level.

{/* pmd-metadata: fixture:cleanup_s3_bucket_block */}
```python
Expand Down Expand Up @@ -168,7 +162,6 @@ def my_flow():

If a result exists at a given storage key in the storage location, the task will load it without running.
To learn more about caching mechanics in Prefect, see the [caching documentation](/3.0/develop/task-caching).

### Result serialization

You can configure how results are serialized to storage using result serializers.
Expand Down
52 changes: 32 additions & 20 deletions docs/3.0/develop/settings-ref.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Settings reference
description: Reference for all available settings for Prefect.
---
{/* This page is generated by `scripts/generate_settings_ref.py`. Update the generation script to update this page. */}
## Root Settings
## Root Settings
### `home`
The path to the Prefect home directory. Defaults to ~/.prefect

Expand Down Expand Up @@ -176,27 +176,17 @@ If `True`, warn on usage of experimental features.
**Supported environment variables**:
`PREFECT_EXPERIMENTAL_WARN`

### `async_fetch_state_result`
### `default_persist_result`
If `True`, results will be persisted by default for all tasks. Set to `False` to disable persistence by default. Note that setting to `False` will override the behavior set by a parent flow or task.

Determines whether `State.result()` fetches results automatically or not.
In Prefect 2.6.0, the `State.result()` method was updated to be async
to facilitate automatic retrieval of results from storage which means when
writing async code you must `await` the call. For backwards compatibility,
the result is not retrieved by default for async users. You may opt into this
per call by passing `fetch=True` or toggle this setting to change the behavior
globally.


**Type**: `boolean`
**Type**: `boolean | None`

**Default**: `False`
**Default**: `None`

**TOML dotted key path**: `async_fetch_state_result`
**TOML dotted key path**: `tasks.default_persist_result`

**Supported environment variables**:
`PREFECT_ASYNC_FETCH_STATE_RESULT`

---
`PREFECT_TASKS_DEFAULT_PERSIST_RESULT`
## APISettings
Settings for interacting with the Prefect API
### `url`
Expand Down Expand Up @@ -708,6 +698,7 @@ The maximum size in bytes for a single log.
---
## ResultsSettings
Settings for controlling result storage behavior

### `default_serializer`
The default serializer to use when not otherwise specified.

Expand Down Expand Up @@ -756,7 +747,17 @@ The path to a directory to store results in.
**Supported environment variables**:
`PREFECT_RESULTS_LOCAL_STORAGE_PATH`, `PREFECT_LOCAL_STORAGE_PATH`

---
### `default_persist_result`
If `True`, results will be persisted by default for all tasks. Set to `False` to disable persistence by default. Note that setting to `False` will override the behavior set by a parent flow or task.

**Type**: `boolean | None`

**Default**: `None`

**TOML dotted key path**: `tasks.default_persist_result`

**Supported environment variables**:
`PREFECT_TASKS_DEFAULT_PERSIST_RESULT`
## RunnerServerSettings
Settings for controlling runner server behavior
### `enable`
Expand Down Expand Up @@ -2197,6 +2198,7 @@ Whether or not to delete failed task submissions from the database.

---
## TasksSettings

### `refresh_cache`
If `True`, enables a refresh of cached results: re-executing the task will refresh the cached results.

Expand Down Expand Up @@ -2236,6 +2238,18 @@ This value sets the default retry delay seconds for all tasks.
**Supported environment variables**:
`PREFECT_TASKS_DEFAULT_RETRY_DELAY_SECONDS`, `PREFECT_TASK_DEFAULT_RETRY_DELAY_SECONDS`

### `default_persist_result`
If `True`, results will be persisted by default for all tasks. Set to `False` to disable persistence by default. Note that setting to `False` will override the behavior set by a parent flow or task.

**Type**: `boolean | None`

**Default**: `None`

**TOML dotted key path**: `tasks.default_persist_result`

**Supported environment variables**:
`PREFECT_TASKS_DEFAULT_PERSIST_RESULT`

### `runner`
Settings for controlling task runner behavior

Expand All @@ -2249,8 +2263,6 @@ Settings for controlling client-side task scheduling behavior
**Type**: [TasksSchedulingSettings](#tasksschedulingsettings)

**TOML dotted key path**: `tasks.scheduling`

---
## TestingSettings
### `test_mode`
If `True`, places the API in test mode. This may modify behavior to facilitate testing.
Expand Down

0 comments on commit 3c6fe26

Please sign in to comment.