Skip to content

Commit

Permalink
[CI] Deflake doctest CI (ray-project#35999)
Browse files Browse the repository at this point in the history
  • Loading branch information
bveeramani authored Jun 2, 2023
1 parent ce7171e commit 55d6e62
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 0 additions & 1 deletion bazel/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def doctest(files, gpu = False, name="doctest", deps=[], srcs=[], data=[], args=
size = size,
args = [
"--doctest-modules",
"--capture=no",
"-c=$(location //bazel:conftest.py)",
"-v"
] + args + ["$(location :%s)" % file for file in files],
Expand Down
6 changes: 5 additions & 1 deletion doc/source/data/loading-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ Generating Synthetic Data
Create a dataset from a range of integers, packing this integer range into
ndarrays of the provided shape.

.. doctest::
..
FIXME: The following code snippets is failing. See
https://buildkite.com/ray-project/oss-ci-build-pr/builds/24240#0188797d-4416-4a34-ada6-2917d1fa9b19
.. code-block:: python
>>> import ray
>>> ds = ray.data.range_tensor(1, shape=(64, 64))
Expand Down
12 changes: 12 additions & 0 deletions doc/source/ray-core/actors/async_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ async frameworks like aiohttp, aioredis, etc.
(AsyncActor pid=40293) finished
(AsyncActor pid=40293) finished

.. testcode::
:hide:

# NOTE: The outputs from the previous code block can show up in subsequent tests.
# To prevent flakiness, we wait for the async calls finish.
import time
time.sleep(3)

.. testoutput::

...

ObjectRefs as asyncio.Futures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ObjectRefs can be translated to asyncio.Futures. This feature
Expand Down
16 changes: 14 additions & 2 deletions doc/source/ray-core/tips-for-first-time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ The output of a program execution is below. As expected, the program takes aroun

Now, let’s parallelize the above program with Ray. Some first-time users will do this by just making the function remote, i.e.,

.. testcode::
:hide:

import ray
ray.shutdown()

.. testcode::

import time
import ray

ray.init(num_cpus = 4) # Specify this system has 4 CPUs.
ray.init(num_cpus=4) # Specify this system has 4 CPUs.

@ray.remote
def do_some_work(x):
Expand Down Expand Up @@ -279,13 +285,19 @@ This running time is quite large for a program that calls just 10 remote tasks t

To avoid copying array ``a`` every time ``no_work()`` is invoked, one simple solution is to explicitly call ``ray.put(a)``, and then pass ``a``’s ID to ``no_work()``, as illustrated below:

.. testcode::
:hide:

import ray
ray.shutdown()

.. testcode::

import time
import numpy as np
import ray

ray.init(num_cpus = 4)
ray.init(num_cpus=4)

@ray.remote
def no_work(a):
Expand Down

0 comments on commit 55d6e62

Please sign in to comment.