forked from ray-project/rayfed
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Be compatible with lower versions of ray. (ray-project#72)
We make that RayFed is able to be compatible with the lower versions of Ray. In this PR, we tested it on Ray1.13.0, that means RayFed is able to be run on Ray1.13.0 officially.
- Loading branch information
1 parent
42c2e18
commit af6df70
Showing
8 changed files
with
131 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: test-on-ray1.13.0 | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
run-unit-tests: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
container: docker.io/library/ubuntu:latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install bazel | ||
run: | | ||
apt-get update | ||
apt-get install -yq wget gcc g++ python3.9 zlib1g-dev zip libuv1.dev | ||
apt-get install -yq pip | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install virtualenv | ||
python3 -m virtualenv -p python3 py3 | ||
. py3/bin/activate | ||
which python | ||
pip install pytest torch cloudpickle cryptography | ||
pip install ray==1.13.0 | ||
- name: Build and test | ||
run: | | ||
. py3/bin/activate | ||
python3 setup.py install | ||
sh test.sh |
2 changes: 1 addition & 1 deletion
2
.github/workflows/ubuntu_basic.yml → .github/workflows/test_on_ray2.0.0.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: ubuntu-basic | ||
name: test-on-ray2.0.0 | ||
|
||
on: | ||
push: | ||
|
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 @@ | ||
# Copyright 2022 The RayFed Team | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import ray | ||
import fed._private.constants as fed_constants | ||
|
||
|
||
def _compare_version_strings(version1, version2): | ||
""" | ||
This utility function compares two version strings and returns | ||
True if version1 is greater, and False if they're equal, and | ||
False if version2 is greater. | ||
""" | ||
v1_list = version1.split('.') | ||
v2_list = version2.split('.') | ||
len1 = len(v1_list) | ||
len2 = len(v2_list) | ||
|
||
for i in range(min(len1, len2)): | ||
if v1_list[i] == v2_list[i]: | ||
continue | ||
else: | ||
break | ||
|
||
return int(v1_list[i]) > int(v2_list[i]) | ||
|
||
|
||
def _ray_version_less_than_2_0_0(): | ||
""" Whther the current ray version is less 2.0.0. | ||
""" | ||
return _compare_version_strings( | ||
fed_constants.RAY_VERSION_2_0_0_STR, ray.__version__) | ||
|
||
|
||
def init_ray(address: str = None, **kwargs): | ||
"""A compatible API to init Ray. | ||
""" | ||
if address == 'local' and _ray_version_less_than_2_0_0(): | ||
# Ignore the `local` when ray < 2.0.0 | ||
ray.init(**kwargs) | ||
else: | ||
ray.init(address=address, **kwargs) | ||
|
||
|
||
def get_gcs_address_from_ray_worker(): | ||
"""A compatible API to get the gcs address from the ray worker module. | ||
""" | ||
try: | ||
return ray._private.worker._global_node.gcs_address | ||
except AttributeError: | ||
return ray.worker._global_node.gcs_address |
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