2016-07-16 14:42:58 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2016-06-27 16:33:12 -07:00
|
|
|
import os
|
2016-07-16 14:42:58 -07:00
|
|
|
import sys
|
2016-06-14 15:42:28 -07:00
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
import ray
|
|
|
|
|
2016-06-27 11:35:31 -07:00
|
|
|
import ray.array.remote as ra
|
|
|
|
import ray.array.distributed as da
|
2016-07-05 14:39:42 -07:00
|
|
|
import example_functions
|
2016-06-14 15:42:28 -07:00
|
|
|
|
2016-07-16 14:42:58 -07:00
|
|
|
def main(argv):
|
|
|
|
DEFAULT_NUM_WORKERS = 1
|
|
|
|
DEFAULT_WORKER_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "default_worker.py")
|
2016-06-27 16:33:12 -07:00
|
|
|
|
2016-07-16 14:42:58 -07:00
|
|
|
import argparse # No need for this to be global
|
|
|
|
parser = argparse.ArgumentParser(description="Parse shell options")
|
|
|
|
parser.add_argument("--scheduler-address", default="127.0.0.1:10001", type=str, help="the scheduler's address")
|
|
|
|
parser.add_argument("--objstore-address", default="127.0.0.1:20001", type=str, help="the objstore's address")
|
|
|
|
parser.add_argument("--worker-address", default="127.0.0.1:30001", type=str, help="the worker's address")
|
|
|
|
parser.add_argument("--attach", action="store_true", help="If true, attach the shell to an already running cluster. If false, start a new cluster.")
|
|
|
|
parser.add_argument("--worker-path", type=str, help="Path to the worker script")
|
|
|
|
parser.add_argument("--num-workers", type=int, help="Number of workers to start")
|
2016-06-14 15:42:28 -07:00
|
|
|
|
2016-07-16 14:42:58 -07:00
|
|
|
args, unknown_args = parser.parse_known_args(argv)
|
2016-06-27 16:33:12 -07:00
|
|
|
if args.attach:
|
|
|
|
assert args.worker_path is None, "when attaching, no new worker can be started"
|
|
|
|
assert args.num_workers is None, "when attaching, no new worker can be started"
|
2016-07-08 12:46:47 -07:00
|
|
|
ray.worker.connect(args.scheduler_address, args.objstore_address, args.worker_address, is_driver=True, mode=ray.SHELL_MODE)
|
2016-06-27 16:33:12 -07:00
|
|
|
else:
|
2016-07-08 12:46:47 -07:00
|
|
|
ray.services.start_ray_local(num_workers=args.num_workers if not args.num_workers is None else DEFAULT_NUM_WORKERS,
|
|
|
|
worker_path=args.worker_path if not args.worker_path is None else DEFAULT_WORKER_PATH,
|
|
|
|
driver_mode=ray.SHELL_MODE)
|
2016-07-16 14:42:58 -07:00
|
|
|
return unknown_args
|
2016-06-14 15:42:28 -07:00
|
|
|
|
2016-07-16 14:42:58 -07:00
|
|
|
if __name__ == "__main__":
|
2016-06-14 15:42:28 -07:00
|
|
|
import IPython
|
2016-07-16 14:42:58 -07:00
|
|
|
IPython.terminal.ipapp.launch_new_instance(argv=main(sys.argv[1:]), user_ns=globals())
|