ray-project / ray

Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
34.23k stars 5.81k forks source link

[workflows] Better message when not init'ed #18121

Open wuisawesome opened 3 years ago

wuisawesome commented 3 years ago

What is the problem?

We have a great error message when workflow.init isn't called, but unfortunately it isn't called if ray.init also isn't called.

Ray version and other system information (Python version, TensorFlow version, OS):

Reproduction (REQUIRED)

import ray
from ray import workflow

@workflow.step
def foo(input_arg):
    print(input_arg)
    return "done"

print(foo.step("hello").run())
(base) Alexs-MacBook-Pro:ray alex$ python test.py 
Traceback (most recent call last):
  File "test.py", line 12, in <module>
    print(foo.step("hello").run())
  File "/Users/alex/anyscale/ray/python/ray/experimental/workflow/step_function.py", line 34, in _build_workflow
    flattened_args)
  File "/Users/alex/anyscale/ray/python/ray/experimental/workflow/serialization_context.py", line 207, in make_workflow_inputs
    workflow_refs):
  File "/Users/alex/miniconda3/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/Users/alex/anyscale/ray/python/ray/experimental/workflow/serialization_context.py", line 70, in workflow_args_serialization_context
    deserializer=_resolve_workflow_outputs)
  File "/Users/alex/anyscale/ray/python/ray/util/serialization.py", line 18, in register_serializer
    context = ray.worker.global_worker.get_serialization_context()
  File "/Users/alex/anyscale/ray/python/ray/worker.py", line 213, in get_serialization_context
    with self.lock:
AttributeError: 'Worker' object has no attribute 'lock'

Please provide a short code snippet (less than 50 lines if possible) that can be copy-pasted to reproduce the issue. The snippet should have no external library dependencies (i.e., use fake or mock data / environments):

If the code snippet cannot be run by itself, the issue will be closed with "needs-repro-script".

wuisawesome commented 3 years ago

cc @iycheng probably not sure if we should just wait until the beta to do this