forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[train] Fix local storage path for windows (ray-project#39951)
This PR fixes setting `storage_path` on windows by using `Path(...).as_posix()` to join paths, so that it's always of the format `C:/a/b/c/exp_dir/trial_dir` rather than a combination of `/` and `\`. This PR also adds a minimal windows test to make sure it works and doesn't give this error anymore. Ray Tune/Train support for windows is not very comprehensive, since no train/tune CI is ported to windows CI. Signed-off-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: Victor <vctr.y.m@example.com>
- Loading branch information
Showing
5 changed files
with
75 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""This is a very minimal set of windows tests for Train/Tune.""" | ||
|
||
import os | ||
|
||
import pytest | ||
|
||
import ray | ||
from ray import train, tune | ||
from ray.train.data_parallel_trainer import DataParallelTrainer | ||
|
||
from ray.train.tests.util import create_dict_checkpoint | ||
|
||
|
||
@pytest.fixture | ||
def ray_start_4_cpus(): | ||
address_info = ray.init(num_cpus=4) | ||
yield address_info | ||
# The code after the yield will run as teardown code. | ||
ray.shutdown() | ||
|
||
|
||
@pytest.fixture | ||
def chdir_tmpdir(tmp_path): | ||
original_path = os.getcwd() | ||
os.chdir(tmp_path) | ||
yield | ||
os.chdir(original_path) | ||
|
||
|
||
def test_storage_path(ray_start_4_cpus, chdir_tmpdir): | ||
"""Tests that Train/Tune with a local storage path works on Windows.""" | ||
|
||
def train_fn(config): | ||
for i in range(5): | ||
if train.get_context().get_world_rank() == 0: | ||
with create_dict_checkpoint({"dummy": "data"}) as checkpoint: | ||
train.report({"loss": i}, checkpoint=checkpoint) | ||
else: | ||
train.report({"loss": i}) | ||
|
||
tuner = tune.Tuner(train_fn, run_config=train.RunConfig(storage_path=os.getcwd())) | ||
results = tuner.fit() | ||
assert not results.errors | ||
|
||
trainer = DataParallelTrainer( | ||
train_fn, | ||
scaling_config=train.ScalingConfig(num_workers=2), | ||
run_config=train.RunConfig(storage_path=os.getcwd()), | ||
) | ||
trainer.fit() | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
|
||
sys.exit(pytest.main(["-v", "-x", __file__])) |