small python ray
This commit is contained in:
commit
e02e80708a
15 changed files with 1261 additions and 0 deletions
34
python/example_client.py
Normal file
34
python/example_client.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import cloudpickle
|
||||
import logging
|
||||
from concurrent import futures
|
||||
import grpc
|
||||
import ray
|
||||
|
||||
ray.connect("localhost:50051")
|
||||
|
||||
|
||||
@ray.remote
|
||||
def fact(x):
|
||||
out = 1
|
||||
for i in range(1, x+1):
|
||||
out = i * out
|
||||
return out
|
||||
|
||||
|
||||
@ray.remote
|
||||
def fib(x):
|
||||
if x <= 1:
|
||||
return 1
|
||||
return ray.get(fib.remote(x - 1)) + ray.get(fib.remote(x - 2))
|
||||
|
||||
|
||||
def run():
|
||||
# out = fact.remote(5)
|
||||
# out2 = fact.remote(out)
|
||||
# print("Got fact: ", ray.get(out2))
|
||||
fib_out = fib.remote(6)
|
||||
# print("Fib out:", ray.get(fib_out))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
Loading…
Add table
Add a link
Reference in a new issue