Bugfix: Support returning json serializable objects from an orchestrator function #490
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.
Currently you can send an arbitrary json-serializable to a sub orchestrator, but that sub orchestrator cannot return the same object.
This because the input param's serializer falls back to using a generic custom obj serializer, but the orchestrator return value doesn't get the same special treatment.
Fixes in this PR
json.dumps()
. This let's custom objects get correctly returned.OrchestratorState.to_json()
since it can set the value of the dictionary toself._output
andself._error
, both of which are typehinted as being ofAny
typeI suspect (but haven't verified) that this also fixes a similar bug that prevents the custom_status from being set to a custom json-serializable object
Missing from this PR
Tests. Sorry for not adding them in but I didn't feel like learning the new test framework for this PR. I tested this manually, and if you guys want unit tests for this then I'm hoping it's trivial for you folks to add.
More context
Without this fix, returning a custom JSON-serializable method results in this error: