-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[data][doc] Add DatasetConfig -> DataConfig migration guide #37278
Merged
raulchen
merged 10 commits into
ray-project:master
from
raulchen:dataconfig-migration-doc
Jul 13, 2023
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7e1ed3e
migration guide
raulchen bf5fe47
blank line
raulchen dc5caf8
link
raulchen f1a6b93
fix
raulchen 20ee0a5
package
raulchen c0601ad
revert doc
raulchen 36c6d66
fix
raulchen 67f0d87
move to _internal
raulchen 1892f5f
doc
raulchen 247b980
fix
raulchen 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# flake8: noqa | ||
# isort: skip_file | ||
|
||
# __legacy_api__ | ||
import random | ||
import ray | ||
|
||
from ray.air.config import ScalingConfig, DatasetConfig | ||
from ray.data.preprocessors.batch_mapper import BatchMapper | ||
from ray.train.torch import TorchTrainer | ||
|
||
train_ds = ray.data.range_tensor(1000) | ||
test_ds = ray.data.range_tensor(10) | ||
|
||
# A randomized preprocessor that adds a random float to all values. | ||
add_noise = BatchMapper(lambda df: df + random.random(), batch_format="pandas") | ||
|
||
my_trainer = TorchTrainer( | ||
lambda: None, | ||
scaling_config=ScalingConfig(num_workers=1), | ||
datasets={ | ||
"train": train_ds, | ||
"test": test_ds, | ||
}, | ||
dataset_config={ | ||
"train": DatasetConfig( | ||
split=True, | ||
# Apply the preprocessor for each epoch. | ||
per_epoch_preprocessor=add_noise, | ||
), | ||
"test": DatasetConfig( | ||
split=False, | ||
), | ||
}, | ||
) | ||
my_trainer.fit() | ||
# __legacy_api_end__ | ||
|
||
# __new_api__ | ||
from ray.train.data_config import DataConfig | ||
|
||
train_ds = ray.data.range_tensor(1000) | ||
test_ds = ray.data.range_tensor(10) | ||
|
||
# Apply the preprocessor before passing the Dataset to the Trainer. | ||
# This operation is lazy. It will be re-executed for each epoch. | ||
train_ds = add_noise.transform(train_ds) | ||
|
||
my_trainer = TorchTrainer( | ||
lambda: None, | ||
scaling_config=ScalingConfig(num_workers=1), | ||
datasets={ | ||
"train": train_ds, | ||
"test": test_ds, | ||
}, | ||
# Specify which datasets to split. | ||
dataset_config=DataConfig( | ||
datasets_to_split=["train"], | ||
), | ||
) | ||
my_trainer.fit() | ||
# __new_api_end__ |
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
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.
We should be clear here that
ray.train.data_config
is not a public API. All the configs should be included viaray.train
directly going forward. Also see the PR description of #36706 and the REP ray-project/enhancements#36 :)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.
@ericl maybe we should rename
data_config
to_data_config
so there are not two ways to do this and people get confused?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.
We should put it in a _internal folder then probably, to follow convention of other libraries.
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.
Ok, let's replace
ray.train.data_config
withray.train
everywhere in this PR before merging, and then we can do the_internal
refactor later as time permits (doesn't need to be part of 2.6).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.
So I assume nothing is needed in this PR, right?
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.
It is -- you need to replace
ray.train.data_config.DataConfig
withray.train.DataConfig
everywhere :)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.
oh, I didn't know it's already in
ray.train
. I think there may be other places usingray.train.data_config
as well. Will update all.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.
Thanks, that's awesome :)