Files
kuberay/tests/scripts/test_detached_actor_1.py
e2a6ae8a76 [Bug] Misuse of Docker API and misunderstanding of Ray HA cause test_detached_actor flaky (#619)
* 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]>
2022-10-12 17:44:38 -07:00

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)