Skip to content

Commit

Permalink
[ci][doc/03] add a command to query and validate apis for ray packages (
Browse files Browse the repository at this point in the history
#45531)

As title, a command to:
- Query apis for a given ray package
- Print out the information for these APIs

Test:
- CI

---------

Signed-off-by: can <[email protected]>
  • Loading branch information
can-anyscale committed May 28, 2024
1 parent b54ee68 commit bc76b19
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 74 deletions.
73 changes: 0 additions & 73 deletions ci/lint/check_api_discrepancy.py

This file was deleted.

3 changes: 2 additions & 1 deletion ci/lint/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ api_annotations() {
api_discrepancy() {
# shellcheck disable=SC2102
RAY_DISABLE_EXTRA_CPP=1 pip install -e python/[all]
./ci/lint/check_api_discrepancy.py
# TODO(can): run this check with other ray packages
bazel run //ci/ray_ci/doc:cmd_check_api_discrepancy -- ray.data
}

documentation_style() {
Expand Down
6 changes: 6 additions & 0 deletions ci/ray_ci/doc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@py_deps_buildkite//:requirements.bzl", ci_require = "requirement")

py_binary(
name = "cmd_check_api_discrepancy",
srcs = ["cmd_check_api_discrepancy.py"],
deps = [":doc"],
)

py_library(
name = "doc",
srcs = glob(
Expand Down
23 changes: 23 additions & 0 deletions ci/ray_ci/doc/cmd_check_api_discrepancy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import click

from ci.ray_ci.doc.module import Module


@click.command()
@click.argument("module", required=True, type=str)
def main(module: str) -> None:
"""
This script checks for annotated classes and functions in a module, and finds
discrepancies between the annotations and the documentation.
"""
module = Module(module)
for api in module.get_apis():
print(
f"API: {api.name}, "
f"Annotation Type: {api.annotation_type}, "
f"Code Type: {api.code_type}"
)


if __name__ == "__main__":
main()

0 comments on commit bc76b19

Please sign in to comment.