Add utilities to serialize context to a dictionary and hydrate context from a dictionary #13529
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.
When running tasks on remote infrastructure like Dask and Ray with the task engine, we lose some of the context surrounding the current task run. This makes it difficult to link the task run back to its parent run. This can also make it difficult to ensure the correct settings are propagated to the remote infrastructure.
This PR introduces two mirror utilities:
serialize_context
andhydrated_context
. When used in conjunction, we can serialize the current context to a pickleable dictionary, send it to the remote infrastructure, and recreate it. This helps to make the task engine highly portable and helps us maintain consistent dependency tracking.The task run engine has been updated to accept a
context
kwargs, which consumes the output ofserialize_context
.Example
Submit a task to Dask with the current context:
Checklist
<link to issue>
"maintenance
,fix
,feature
,enhancement
,docs
.For documentation changes:
netlify.toml
for files that are removed or renamed.For new functions or classes in the Python SDK:
mkdocs.yml
navigation.