-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #587 from PrefectHQ/output-caching
Output caching
- Loading branch information
Showing
16 changed files
with
574 additions
and
61 deletions.
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
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. | ||
""" | ||
|
||
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) |
Oops, something went wrong.