Skip to content

Commit

Permalink
[Workflows] Fix some docstrings (ray-project#35808)
Browse files Browse the repository at this point in the history
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: matthewdeng <[email protected]>
Co-authored-by: matthewdeng <[email protected]>
  • Loading branch information
bveeramani and matthewdeng authored May 26, 2023
1 parent b71a04c commit 75759cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
27 changes: 15 additions & 12 deletions python/ray/workflow/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,18 +734,21 @@ class options:
"""This class serves both as a decorator and options for workflow.
Examples:
>>> import ray
>>> from ray import workflow
>>>
>>> # specify workflow options with a decorator
>>> @workflow.options(catch_exceptions=True):
>>> @ray.remote
>>> def foo():
>>> return 1
>>>
>>> # speficy workflow options in ".options"
>>> foo_new = foo.options(**workflow.options(catch_exceptions=False))
"""
.. code-block:: python
import ray
from ray import workflow
# specify workflow options with a decorator
@workflow.options(catch_exceptions=True)
@ray.remote
def foo():
return 1
# specify workflow options in ".options"
foo_new = foo.options(**workflow.options(catch_exceptions=False))
""" # noqa: E501

def __init__(self, **workflow_options: Dict[str, Any]):
# TODO(suquark): More rigid arguments check like @ray.remote arguments. This is
Expand Down
18 changes: 10 additions & 8 deletions python/ray/workflow/http_event_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,17 @@ async def event_checkpointed(self, event) -> None:
Example Usage
=============
>>> from ray.workflow.http_event_provider import HTTPEventProvider, HTTPListener
>>> ray.init(address='auto', namespace='serve')
>>> serve.start(detached=True)
>>> event_node = workflow.wait_for_event( # doctest: +SKIP
... HTTPListener, event_key='')
>>> handle_event = ... # doctest: +SKIP
>>> workflow.run(handle_event.bind(event_node)) # doctest: +SKIP
>>>
.. code-block:: python
from ray.workflow.http_event_provider import HTTPEventProvider, HTTPListener
ray.init(address='auto', namespace='serve')
serve.start(detached=True)
event_node = workflow.wait_for_event(HTTPListener, event_key='')
handle_event = ...
workflow.run(handle_event.bind(event_node))
"""

def __init__(self):
Expand Down

0 comments on commit 75759cf

Please sign in to comment.