mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
Signed-off-by: Future-Outlier <[email protected]> Co-authored-by: machichima <[email protected]> Co-authored-by: fscnick <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: kaihsun <[email protected]>
25 lines
499 B
Python
25 lines
499 B
Python
import ray
|
|
import os
|
|
|
|
ray.init()
|
|
|
|
@ray.remote
|
|
class Counter:
|
|
def __init__(self):
|
|
# Used to verify runtimeEnv
|
|
self.name = os.getenv("counter_name")
|
|
assert self.name == "test_counter"
|
|
self.counter = 0
|
|
|
|
def inc(self):
|
|
self.counter += 1
|
|
|
|
def get_counter(self):
|
|
return "{} got {}".format(self.name, self.counter)
|
|
|
|
counter = Counter.remote()
|
|
|
|
for _ in range(5):
|
|
ray.get(counter.inc.remote())
|
|
print(ray.get(counter.get_counter.remote()))
|