[data][train] Create a deepcopy of the data context on the split coordinator process#56211
Merged
justinvyu merged 7 commits intoray-project:masterfrom Sep 4, 2025
Merged
Conversation
… from runconfig Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a key fix to prevent state leakage in DataContext by using a deep copy. It also includes several nice refactorings, such as simplifying DatasetsSetupCallback's initialization by using TrainRunContext, and centralizing StorageContext creation within RunConfig.
I have a few suggestions:
- A critical issue where a test is broken due to the refactoring of
DatasetsSetupCallback. - A high-severity suggestion to improve the performance of the new
storage_contextproperty by caching its result. - A medium-severity suggestion to restore a helpful note in a docstring for better code maintainability.
Overall, the changes are well-structured and improve the codebase. Addressing the identified issues will make this PR even better.
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
matthewdeng
approved these changes
Sep 3, 2025
| self._scaling_config = scaling_config | ||
| def __init__(self, train_run_context: TrainRunContext): | ||
| self._datasets = train_run_context.datasets | ||
| self._data_config = copy.deepcopy(train_run_context.dataset_config) |
Contributor
There was a problem hiding this comment.
Does this need to be deepcopied?
Contributor
Author
There was a problem hiding this comment.
I want to deepcopy to avoid modifying the user's configs in place
…allback_run_context Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
sampan-s-nayak
pushed a commit
to sampan-s-nayak/ray
that referenced
this pull request
Sep 8, 2025
…dinator process (ray-project#56211) The main change of this PR is to create a deepcopy of the base dataset's context before setting the process-global context. Otherwise, mutations to the base dataset's context during the planning phase are also propagated to the global context, which can affect future dataset executions launched from the same process. Misc. drive-by changes: * Utility to create a `StorageContext` from the `RunConfig` directly * Pipe the `DatasetShardMetadata` from the outermost level among other changes, for easier patching --------- Signed-off-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: sampan <sampan@anyscale.com>
jugalshah291
pushed a commit
to jugalshah291/ray_fork
that referenced
this pull request
Sep 11, 2025
…dinator process (ray-project#56211) The main change of this PR is to create a deepcopy of the base dataset's context before setting the process-global context. Otherwise, mutations to the base dataset's context during the planning phase are also propagated to the global context, which can affect future dataset executions launched from the same process. Misc. drive-by changes: * Utility to create a `StorageContext` from the `RunConfig` directly * Pipe the `DatasetShardMetadata` from the outermost level among other changes, for easier patching --------- Signed-off-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: jugalshah291 <shah.jugal291@gmail.com>
wyhong3103
pushed a commit
to wyhong3103/ray
that referenced
this pull request
Sep 12, 2025
…dinator process (ray-project#56211) The main change of this PR is to create a deepcopy of the base dataset's context before setting the process-global context. Otherwise, mutations to the base dataset's context during the planning phase are also propagated to the global context, which can affect future dataset executions launched from the same process. Misc. drive-by changes: * Utility to create a `StorageContext` from the `RunConfig` directly * Pipe the `DatasetShardMetadata` from the outermost level among other changes, for easier patching --------- Signed-off-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: yenhong.wong <yenhong.wong@grabtaxi.com>
dstrodtman
pushed a commit
that referenced
this pull request
Oct 6, 2025
…dinator process (#56211) The main change of this PR is to create a deepcopy of the base dataset's context before setting the process-global context. Otherwise, mutations to the base dataset's context during the planning phase are also propagated to the global context, which can affect future dataset executions launched from the same process. Misc. drive-by changes: * Utility to create a `StorageContext` from the `RunConfig` directly * Pipe the `DatasetShardMetadata` from the outermost level among other changes, for easier patching --------- Signed-off-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: Douglas Strodtman <douglas@anyscale.com>
landscapepainter
pushed a commit
to landscapepainter/ray
that referenced
this pull request
Nov 17, 2025
…dinator process (ray-project#56211) The main change of this PR is to create a deepcopy of the base dataset's context before setting the process-global context. Otherwise, mutations to the base dataset's context during the planning phase are also propagated to the global context, which can affect future dataset executions launched from the same process. Misc. drive-by changes: * Utility to create a `StorageContext` from the `RunConfig` directly * Pipe the `DatasetShardMetadata` from the outermost level among other changes, for easier patching --------- Signed-off-by: Justin Yu <justinvyu@anyscale.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The main change of this PR is to create a deepcopy of the base dataset's context before setting the process-global context.
Otherwise, mutations to the base dataset's context during the planning phase are also propagated to the global context, which can affect future dataset executions launched from the same process.
Misc. drive-by changes
StorageContextfrom theRunConfigdirectlyDatasetShardMetadatafrom the outermost level among other changes, for easier patching