Beispiel #1
0
def test_no_init(shutdown_only):
    @workflow.step
    def f():
        pass

    fail_wf_init_error_msg = re.escape(
        "`workflow.init()` must be called prior to using "
        "the workflows API.")

    with pytest.raises(RuntimeError, match=fail_wf_init_error_msg):
        f.step().run()
    with pytest.raises(RuntimeError, match=fail_wf_init_error_msg):
        workflow.list_all()
    with pytest.raises(RuntimeError, match=fail_wf_init_error_msg):
        workflow.resume_all()
    with pytest.raises(RuntimeError, match=fail_wf_init_error_msg):
        workflow.cancel("wf")
    with pytest.raises(RuntimeError, match=fail_wf_init_error_msg):
        workflow.get_actor("wf")
Beispiel #2
0
def test_readonly_actor(workflow_start_regular):
    actor = Counter.get_or_create("Counter", 42)
    ray.get(actor.ready())
    assert actor.readonly_get.run() == 42
    assert actor.readonly_incr.run() == 43
    assert actor.readonly_get.run() == 42

    # test get actor
    readonly_actor = workflow.get_actor("Counter")
    # test concurrency
    assert ray.get([
        readonly_actor.readonly_get.run_async() for _ in range(10)
    ]) == [42] * 10
    assert ray.get([
        readonly_actor.readonly_incr.run_async() for _ in range(10)
    ]) == [43] * 10
    assert ray.get([
        readonly_actor.readonly_get.run_async() for _ in range(10)
    ]) == [42] * 10
    start = time.time()
    ray.get([readonly_actor.readonly_workload.run_async() for _ in range(10)])
    end = time.time()
    assert end - start < 5
Beispiel #3
0
 def add(self, y):
     actor = workflow.get_actor("counter")
     return actor.add.run(y)
Beispiel #4
0
 def readonly_incr(self):
     actor = workflow.get_actor("counter")
     return actor.readonly_incr.run()