mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 17:45:08 +08:00
[Tune] Parametrize Cloud Syncing Frequency (#8771)
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -151,6 +152,38 @@ class TestSyncFunctionality(unittest.TestCase):
|
||||
shutil.rmtree(tmpdir)
|
||||
shutil.rmtree(tmpdir2)
|
||||
|
||||
@patch("ray.tune.sync_client.S3_PREFIX", "test")
|
||||
def testCloudSyncPeriod(self):
|
||||
"""Tests that changing CLOUD_SYNC_PERIOD affects syncing frequency."""
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
|
||||
def trainable(config):
|
||||
for i in range(10):
|
||||
time.sleep(1)
|
||||
tune.report(score=i)
|
||||
|
||||
mock = unittest.mock.Mock()
|
||||
|
||||
def counter(local, remote):
|
||||
mock()
|
||||
|
||||
tune.syncer.CLOUD_SYNC_PERIOD = 1
|
||||
[trial] = tune.run(
|
||||
trainable,
|
||||
name="foo",
|
||||
max_failures=0,
|
||||
local_dir=tmpdir,
|
||||
upload_dir="test",
|
||||
sync_to_cloud=counter,
|
||||
stop={
|
||||
"training_iteration": 10
|
||||
},
|
||||
global_checkpoint_period=0.5,
|
||||
).trials
|
||||
|
||||
self.assertEqual(mock.call_count, 12)
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
def testClusterSyncFunction(self):
|
||||
def sync_func_driver(source, target):
|
||||
assert ":" in source, "Source {} not a remote path.".format(source)
|
||||
|
||||
Reference in New Issue
Block a user