Skip to content
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

[release] update torch_tune_serve_test to use anyscale connect #16754

Merged
merged 4 commits into from
Jul 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
clean up code to support both OSS and Anyscale
  • Loading branch information
matthewdeng committed Jul 7, 2021
commit 9942402c66611ab1aa38ca3b4d4d14313d54778a
17 changes: 13 additions & 4 deletions release/golden_notebook_tests/workloads/torch_tune_serve_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
from torchvision.datasets import MNIST


def _is_anyscale_connect():
address = os.environ.get("RAY_ADDRESS")
is_anyscale_connect = address is not None and address.startswith(
"anyscale:https://")
return is_anyscale_connect


def load_mnist_data(train: bool, download: bool):
transform = transforms.Compose(
[transforms.ToTensor(),
Expand Down Expand Up @@ -86,8 +93,7 @@ def train_mnist(test_mode=False, num_workers=1, use_gpu=False):


def get_remote_model(remote_model_checkpoint_path):
address = os.environ.get("RAY_ADDRESS")
if address is not None and address.startswith("anyscale:https://"):
if _is_anyscale_connect():
# Download training results to local client.
local_dir = "~/ray_results"
# TODO(matt): remove the following line when Anyscale Connect
Expand Down Expand Up @@ -210,8 +216,11 @@ def test_predictions(test_mode=False):

start = time.time()

job_name = os.environ.get("RAY_JOB_NAME", "torch_tune_serve_test")
ray.client().job_name(job_name).connect()
client_builder = ray.client()
if (_is_anyscale_connect()):
job_name = os.environ.get("RAY_JOB_NAME", "torch_tune_serve_test")
client_builder.job_name(job_name)
client_builder.connect()

num_workers = 2
use_gpu = True
Expand Down