Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 8, 2025

Addresses common user confusion around @flow and @task decorators when using result_storage with unsaved block instances, especially in pytest scenarios.

Changes

Documentation (docs/v3/advanced/results.mdx):

  • Added a Warning callout explaining the two options for specifying result_storage:
    • Block instances (must call .save() first)
    • String references (resolved at runtime, recommended for testing)
  • Includes code examples demonstrating both approaches

Docstrings (flows.py, tasks.py):

  • Updated result_storage parameter documentation in @flow and @task decorators to explain both patterns and when to use each

Error messages:

  • Improved TypeError message to suggest string reference alternative when users pass unsaved blocks

Closes #16641

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
  • If this pull request adds new functionality, it includes unit tests that cover the changes
    • N/A - documentation-only changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
    • N/A
  • If this pull request adds functions or classes, it includes helpful docstrings.
    • Updated existing docstrings

Review checklist

  • Verify the import path from prefect.filesystems import LocalFileSystem is correct in the documentation example
  • Confirm the documentation renders correctly

Link to Devin run: https://app.devin.ai/sessions/8a4d5455065443f2ac1d44b4bd4664fc
Requested by: [email protected] (@desertaxle)

- Add Warning callout to results.mdx explaining block instances vs string references
- Update @flow and @task decorator docstrings to document both patterns
- Improve error messages to suggest string reference alternative

Closes #16641

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 8, 2025

CodSpeed Performance Report

Merging #19671 will not alter performance

Comparing devin/1765206792-result-storage-docs (d51dc83) with main (51b566f)

Summary

✅ 2 untouched


When specifying `result_storage` in `@flow` or `@task` decorators, you have two options:

- **Block instances**: Must call `.save()` first, since decorators execute at import time before a server connection may be available
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- **Block instances**: Must call `.save()` first, since decorators execute at import time before a server connection may be available
- **Block instances**: The block instance must be saved server-side or loaded from a saved block instance before it is provided to the `@task` or `@flow` decorator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied both suggestions - thanks for the feedback!

- **Block instances**: Must call `.save()` first, since decorators execute at import time before a server connection may be available
- **String references**: Use the format `"block-type-slug/block-name"` for deferred resolution at runtime

For testing scenarios (especially with pytest), string references are recommended since they don't require server connectivity at import time.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
For testing scenarios (especially with pytest), string references are recommended since they don't require server connectivity at import time.
For testing scenarios, string references are recommended since they don't require server connectivity at import time.

@desertaxle desertaxle changed the title docs: clarify result_storage usage with decorators Clarify result_storage usage with @task and @flow decorators Dec 8, 2025
- Update block instances description to be clearer
- Remove pytest parenthetical from testing scenarios

Co-Authored-By: [email protected] <[email protected]>
other_storage_task()
```

<Warning>
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this an Info admonition instead of a Warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - changed to Info admonition.

@desertaxle desertaxle merged commit 54a14ac into main Dec 8, 2025
92 of 93 checks passed
@desertaxle desertaxle deleted the devin/1765206792-result-storage-docs branch December 8, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eager server-side existence check of Blocks is incompatible with flow decorators and pytest

2 participants