mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
* fix test_detached_actor * update * Update tests/compatibility-test.py Co-authored-by: Dmitri Gekhtman <[email protected]> Signed-off-by: Kai-Hsun Chen <[email protected]> * update * add link * update comments Signed-off-by: Kai-Hsun Chen <[email protected]> Co-authored-by: Dmitri Gekhtman <[email protected]>
22 lines
486 B
Python
22 lines
486 B
Python
import ray
|
|
import sys
|
|
|
|
ray.init(address='ray://127.0.0.1:10001', namespace=sys.argv[1])
|
|
|
|
@ray.remote
|
|
class TestCounter:
|
|
def __init__(self):
|
|
self.value = 0
|
|
|
|
def increment(self):
|
|
self.value += 1
|
|
return self.value
|
|
|
|
tc = TestCounter.options(name="testCounter", lifetime="detached", max_restarts=-1).remote()
|
|
val1 = ray.get(tc.increment.remote())
|
|
val2 = ray.get(tc.increment.remote())
|
|
print(f"val1: {val1}, val2: {val2}")
|
|
|
|
assert(val1 == 1)
|
|
assert(val2 == 2)
|