hello, I want call many different method in sequence of a synchronous, single-threaded actor,and these method could take a lot of time,I want watch the progress,is ray has interface to get so?
like ray.get_actor_running_task(actor)?
some code like below
import ray
import os
import time
import random
import sys
from string import ascii_lowercase
ray.init()
def mock_crash(threshold=0.01):
rr = random.random()
if rr < threshold:
print("mock crash now")
sys.exit(-1)
@ray.remote
class ReentrantCounter:
def __init__(self, value, checkpoint_metadata=None):
print("actor pid is {}".format(os.getpid()))
if checkpoint_metadata is None:
self.value = value
else:
self.value = checkpoint_metadata['value']
def increment(self, i=1):
print("actor pid is {}".format(os.getpid()))
self.value += i
# do something take a lot of time
time.sleep(random.random()*3)
# mock_crash()
return self.value
def make_name(n=10):
return ''.join([random.choice(ascii_lowercase) for _ in range(n)])
actor_name = make_name()
print("create actor with name {} now".format(actor_name))
actor = ReentrantCounter.options(name=actor_name).remote(1)
async_reses = [actor.increment.remote(i) for i in range(10)]
# maybe has some interface like this?
ray.get_actor_running_task(actor)