-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixed hyperopt trial syncing to remote filesystems for Ray 2.0 #2617
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c2f505a
tests: Added test to verify s3 artifact upload and download
tgaddair a02eee6
Added more tests
tgaddair 130be06
Fixed upload
tgaddair f04d223
Added ray backend
tgaddair 1d05d33
Moved to utils
tgaddair adce9f0
WrapSyncer
tgaddair 5c5acec
Merge
tgaddair 0a71bf1
Added syncer
tgaddair a4be13f
Merge branch 'master' into wrap-syncer
tgaddair a4d7e84
Fixed RemoteSyncer
tgaddair 4fa404b
Fixed ray 1.13 tests
tgaddair 2ab6b68
Update syncer.py
tgaddair 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,82 @@ | ||
from typing import Any, Callable, Dict, List, Optional, Tuple | ||
|
||
from ray import tune | ||
from ray.tune.syncer import _BackgroundSyncer, get_node_to_storage_syncer, Syncer | ||
|
||
from ludwig.utils.data_utils import use_credentials | ||
from ludwig.utils.fs_utils import delete, download, upload | ||
from ludwig.utils.misc_utils import memoized_method | ||
|
||
|
||
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 | ||
|
||
|
||
class LazyFsspecSyncer(Syncer): | ||
def __init__(self, upload_dir: str, creds: Optional[Dict[str, Any]] = None): | ||
super().__init__() | ||
self.upload_dir = upload_dir | ||
self.creds = creds | ||
self._syncer = None | ||
|
||
def sync_up(self, *args, **kwargs) -> bool: | ||
with use_credentials(self.creds): | ||
return self.syncer().sync_up(*args, **kwargs) | ||
|
||
def sync_down(self, *args, **kwargs) -> bool: | ||
with use_credentials(self.creds): | ||
return self.syncer().sync_down(*args, **kwargs) | ||
|
||
def delete(self, *args, **kwargs) -> bool: | ||
with use_credentials(self.creds): | ||
return self.syncer().delete(*args, **kwargs) | ||
|
||
@memoized_method(maxsize=1) | ||
def syncer(self): | ||
if self._syncer is None: | ||
sync_config = tune.SyncConfig(upload_dir=self.upload_dir) | ||
self._syncer = get_node_to_storage_syncer(sync_config) | ||
return self._syncer | ||
|
||
|
||
class WrappedSyncer(Syncer): | ||
def __init__(self, syncer: Syncer, creds: Optional[Dict[str, Any]] = None): | ||
super().__init__() | ||
self.syncer = syncer | ||
self.creds = creds | ||
|
||
def sync_up(self, *args, **kwargs) -> bool: | ||
with use_credentials(self.creds): | ||
return self.syncer.sync_up(*args, **kwargs) | ||
|
||
def sync_down(self, *args, **kwargs) -> bool: | ||
with use_credentials(self.creds): | ||
return self.syncer.sync_down(*args, **kwargs) | ||
|
||
def delete(self, *args, **kwargs) -> bool: | ||
with use_credentials(self.creds): | ||
return self.syncer.delete(*args, **kwargs) |
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
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.
@tgaddair Is there a reason to set max_concurrent_trials to 1?
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.
Yeah, when you run multiple trials on these runners / locally it often ends up making them compete for resources, which slows everything down. Limiting to 1 trial at a time helps to avoid this resource contention.
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.
Got it, that makes sense! Similar to the problem I was seeing as well - personally I even noticed this happening on my local at times even when not using a RayBackend.
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's a good indicator that 1 CPU per trial is probably too low. In practice, we may want to bump this up.