mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00

Currently, we are not running doc notebooks in CI due to a bazel misconfiguration - we are using `glob` in a top level package in order to get the paths for the notebooks, but those are contained inside subpackages, which glob purposefully ignores. Therefore, the lists of notebooks to run are empty. This PR fixes that by: * Running the `py_test_run_all_notebooks` macro inside the relevant subpackages * Editing the `test_myst_doc.py` script to allow for recursive search for the target file, allowing to deal with mismatches between `name` and `data` arguments in `py_test_run_all_notebooks` * Setting the `allow_empty=False` flag inside `glob` calls in our macros to ensure that this oversight is caught early * Enabling detection of changes in doc folder for `*.ipynb` and `BUILD` files This PR also adds a GPU runner for doc tests, allowing one of our examples to pass - and setting the infra for more to come. Finally, a misconfigured path for one set of doc tests is also fixed.
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
load("@bazel_skylib//lib:paths.bzl", "paths")
|
|
|
|
# py_test_module_list creates a py_test target for each
|
|
# Python file in `files`
|
|
def py_test_module_list(files, size, deps, extra_srcs, name_suffix="", **kwargs):
|
|
for file in files:
|
|
# remove .py
|
|
name = paths.split_extension(file)[0] + name_suffix
|
|
if name == file:
|
|
basename = basename + "_test"
|
|
native.py_test(
|
|
name = name,
|
|
size = size,
|
|
main = file,
|
|
srcs = extra_srcs + [file],
|
|
**kwargs
|
|
)
|
|
|
|
def py_test_run_all_subdirectory(include, exclude, extra_srcs, **kwargs):
|
|
for file in native.glob(include = include, exclude = exclude, allow_empty=False):
|
|
print(file)
|
|
basename = paths.split_extension(file)[0]
|
|
if basename == file:
|
|
basename = basename + "_test"
|
|
native.py_test(
|
|
name = basename,
|
|
srcs = extra_srcs + [file],
|
|
**kwargs
|
|
)
|
|
|
|
# Runs all included notebooks as py_test targets, by first converting them to .py files with "test_myst_doc.py".
|
|
def py_test_run_all_notebooks(include, exclude, **kwargs):
|
|
for file in native.glob(include = include, exclude = exclude, allow_empty=False):
|
|
print(file)
|
|
basename = paths.split_extension(file)[0]
|
|
if basename == file:
|
|
basename = basename + "_test"
|
|
native.py_test(
|
|
name = basename,
|
|
main = "test_myst_doc.py",
|
|
srcs = ["//doc:test_myst_doc.py"],
|
|
# --find-recursively will look for file in all
|
|
# directories inside cwd recursively if it cannot
|
|
# find it right away. This allows to deal with
|
|
# mismatches between `name` and `data` args.
|
|
args = ["--find-recursively", "--path", file],
|
|
**kwargs
|
|
)
|