-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output caching #587
Merged
Merged
Output caching #587
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
de06c72
Refactor where result handlers live and the hierarchy of result handlers
cicdw 8e8b352
Pass result handlers down the line
cicdw de0ad58
Begin modifying the _metadata attribute of states within the task runner
cicdw 59d5acf
Add new ensure_raw state method for unpacking non-raw results and data
cicdw 8509cf2
Ensure all states coming into task runners are raw
cicdw ba3a327
Move raw logic to Cloud Runner
cicdw f493376
Implement finalize_run which handles any data that needs handling
cicdw 5f68559
Add some basic unit tests for the new state methods
cicdw b34edae
Resolve merge conflicts with master
cicdw 1e6409b
Polish up finalize_run and add tests
cicdw dc97186
Address feedback and give metadata attribute more structure
cicdw d7b0e81
Remove unnecessary gets() now that metadata is stricter
cicdw bc3a0cb
Fix mypy failures and update changelog
cicdw cce9ea3
Change names per feedback and ensure metadata stays dotdict after des…
cicdw 9ce92f5
Merge branch 'master' into output-caching
cicdw 01aa3be
Fix failing test caused by overwriting metadata dictionary
cicdw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Licensed under LICENSE.md; also available at https://www.prefect.io/licenses/alpha-eula | ||
|
||
from prefect.engine.result_handlers.result_handler import ResultHandler | ||
from prefect.engine.result_handlers.json_result_handler import JSONResultHandler | ||
from prefect.engine.result_handlers.local_result_handler import LocalResultHandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Licensed under LICENSE.md; also available at https://www.prefect.io/licenses/alpha-eula | ||
|
||
import json | ||
from typing import Any | ||
|
||
from prefect.engine.result_handlers import ResultHandler | ||
|
||
|
||
class JSONResultHandler(ResultHandler): | ||
""" | ||
Hook for storing and retrieving task results to / from JSON. Only intended to be used | ||
for small data loads. | ||
joshmeek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
|
||
def deserialize(self, jblob: str) -> Any: | ||
""" | ||
Deserialize a result from a string JSON blob. | ||
|
||
Args: | ||
- jblob (str): the JSON representation of the result | ||
|
||
Returns: | ||
- the deserialized result | ||
""" | ||
return json.loads(jblob) | ||
|
||
def serialize(self, result: Any) -> str: | ||
""" | ||
Serialize the provided result to JSON. | ||
|
||
Args: | ||
- result (Any): the result to serialize | ||
|
||
Returns: | ||
- str: the JSON representation of the result | ||
""" | ||
return json.dumps(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than checking for the attribute, I suggest checking
if state.is_pending() and state.cached_inputs is not None:
, since onlyPending
states will qualifyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually that's not entirely correct -->
TimedOut
states store inputs as wellThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIR
ealized