-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed hyperopt trial syncing to remote filesystems for Ray 2.0 (#2617)
- Loading branch information
Showing
6 changed files
with
109 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Any, Callable, Dict, List, Optional, Tuple | ||
|
||
from ray.tune.syncer import _BackgroundSyncer | ||
|
||
from ludwig.utils.data_utils import use_credentials | ||
from ludwig.utils.fs_utils import delete, download, upload | ||
|
||
|
||
class RemoteSyncer(_BackgroundSyncer): | ||
def __init__(self, sync_period: float = 300.0, creds: Optional[Dict[str, Any]] = None): | ||
super().__init__(sync_period=sync_period) | ||
self.creds = creds | ||
|
||
def _sync_up_command(self, local_path: str, uri: str, exclude: Optional[List] = None) -> Tuple[Callable, Dict]: | ||
with use_credentials(self.creds): | ||
return upload, dict(lpath=local_path, rpath=uri) | ||
|
||
def _sync_down_command(self, uri: str, local_path: str) -> Tuple[Callable, Dict]: | ||
with use_credentials(self.creds): | ||
return download, dict(rpath=uri, lpath=local_path) | ||
|
||
def _delete_command(self, uri: str) -> Tuple[Callable, Dict]: | ||
with use_credentials(self.creds): | ||
return delete, dict(url=uri, recursive=True) | ||
|
||
def __reduce__(self): | ||
"""We need this custom serialization because we can't pickle thread.lock objects that are used by the | ||
use_credentials context manager. | ||
https://docs.ray.io/en/latest/ray-core/objects/serialization.html#customized-serialization | ||
""" | ||
deserializer = RemoteSyncer | ||
serialized_data = (self.sync_period, self.creds) | ||
return deserializer, serialized_data |
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