Skip to content

Instantly share code, notes, and snippets.

@simon-mo
Created August 6, 2021 19:01
Show Gist options
  • Select an option

  • Save simon-mo/3311e405606b7f2fd619fd33d53bb945 to your computer and use it in GitHub Desktop.

Select an option

Save simon-mo/3311e405606b7f2fd619fd33d53bb945 to your computer and use it in GitHub Desktop.
  • Run ray start --head in another directory (simulating remote environment in K8s)
  • Run python app.py, it will sync the current directory, including my_module.py to the remote cluster
  • curl localhost:8000/f returns this from my_module.py::my_func
import ray
from ray import serve
ray.init("ray://localhost:10001", runtime_env={"working_dir": "."}, namespace="serve")
@serve.deployment
def f(_):
from my_module import my_func
return my_func()
serve.start(detached=True)
f.deploy()
def my_func():
return "this from my_module.py::my_func"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment