Skip to content

Commit

Permalink
[AIR] Optimize computer vision example code (ray-project#38712)
Browse files Browse the repository at this point in the history
The computer_vision.py example test previously took more than 15 minutes to run. With limit pushdown and the changes in this PR, this test now only takes ~6 minutes to run.

Signed-off-by: Balaji Veeramani <[email protected]>
  • Loading branch information
bveeramani authored Aug 22, 2023
1 parent f55508e commit 0f4a685
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
13 changes: 1 addition & 12 deletions doc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,11 @@ py_test_run_all_subdirectory(
py_test_run_all_subdirectory(
size = "large",
include = ["source/ray-air/doc_code/*.py"],
exclude = [
# Too large. Use a custom test below.
"source/ray-air/doc_code/computer_vision.py",
],
exclude = [],
extra_srcs = [],
tags = ["exclusive", "team:ml"],
)

py_test(
size = "enormous",
name = "computer_vision_test",
main = "source/ray-air/doc_code/computer_vision.py",
srcs = ["source/ray-air/doc_code/computer_vision.py"],
tags = ["exclusive", "team:ml"],
)

# --------------------------------------------------------------------
# Test all doc/source/train/doc_code code included in rst/md files.
# --------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion doc/source/ray-air/doc_code/computer_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def read_images():
dataset = ray.data.read_images(root, partitioning=partitioning)
# __read_images1_stop__

dataset = dataset.limit(32)
# The autodetected parallelism is low. As a result, blocks are large and we
# unnecessarily read more than a thousand images (even though we limit the dataset
# to 32 rows!) To avoid this issue, we manually set the parallelism.
dataset = ray.data.read_images(root, partitioning=partitioning, parallelism=1875)

# __read_images2_start__
from typing import Dict
Expand Down

0 comments on commit 0f4a685

Please sign in to comment.