Skip to content

Commit 918e292

Browse files
committed
[ci] doc check: remove dependency on ray_ci
this makes it possible to run on a different python version than the CI wrapper code. Signed-off-by: Lonnie Liu <[email protected]>
1 parent 6de012f commit 918e292

File tree

4 files changed

+33
-47
lines changed

4 files changed

+33
-47
lines changed

ci/ray_ci/doc/BUILD.bazel

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ py_binary(
1111
name = "cmd_build",
1212
srcs = ["cmd_build.py"],
1313
exec_compatible_with = ["//:hermetic_python"],
14-
deps = [":doc"],
14+
deps = [
15+
ci_require("click"),
16+
":doc",
17+
],
1518
)
1619

1720
py_library(
@@ -23,9 +26,8 @@ py_library(
2326
"cmd_*.py",
2427
],
2528
),
26-
visibility = ["//ci/ray_ci/doc:__subpackages__"],
2729
deps = [
28-
"//ci/ray_ci:ray_ci_lib",
30+
ci_require("boto3"),
2931
ci_require("sphinx"),
3032
ci_require("myst_parser"),
3133
ci_require("myst-nb"),

ci/ray_ci/doc/build_cache.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import os
22
import pickle
33
import subprocess
4+
import sys
45
import tempfile
56
from typing import Set
67

78
import boto3
89

9-
from ci.ray_ci.utils import logger
1010

11-
from ray_release.util import get_write_state_machine_aws_bucket
12-
13-
AWS_CACHE_KEY = "doc_build"
1411
ENVIRONMENT_PICKLE = "_build/doctrees/environment.pickle"
1512

13+
_BUILD_CACHE_S3_BUCKET = "ray-ci-results"
14+
_BUILD_CACHE_PATH_PREFIX = "doc_build/"
15+
1616

1717
class BuildCache:
1818
"""
@@ -28,27 +28,17 @@ def __init__(self, cache_dir: str):
2828
self._cache_dir = cache_dir
2929

3030
def upload(self, dry_run: bool) -> None:
31-
"""
32-
Upload the build artifacts to S3
33-
"""
34-
logger.info("Massage the build artifacts to be used as a cache.")
31+
"""Upload the build artifacts to S3."""
3532
self._massage_cache(ENVIRONMENT_PICKLE)
36-
37-
logger.info("Obtaining the list of cache files.")
3833
cache_files = self._get_cache()
39-
40-
logger.info("Creating a tarball of the cache files.")
4134
doc_tarball = self._zip_cache(cache_files)
4235

4336
if dry_run:
44-
logger.info(f"Skipping upload of {doc_tarball} to S3.")
37+
print(f"Skipping upload of {doc_tarball} to S3.", file=sys.stderr)
4538
return
4639

47-
logger.info("Upload the tarball to S3.")
4840
self._upload_cache(doc_tarball)
4941

50-
logger.info(f"Successfully uploaded {doc_tarball} to S3.")
51-
5242
def _massage_cache(self, environment_cache_file: str) -> None:
5343
"""
5444
Massage the build artifacts, remove the unnecessary files so that they can
@@ -102,6 +92,6 @@ def _zip_cache(self, cache_files: Set[str]) -> str:
10292
def _upload_cache(self, doc_tarball: str) -> None:
10393
boto3.client("s3").upload_file(
10494
os.path.join(self._cache_dir, doc_tarball),
105-
get_write_state_machine_aws_bucket(),
106-
f"{AWS_CACHE_KEY}/{doc_tarball}",
95+
_BUILD_CACHE_S3_BUCKET,
96+
f"{_BUILD_CACHE_PATH_PREFIX}{doc_tarball}",
10797
)

ci/ray_ci/doc/cmd_build.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import os
22
import subprocess
3+
import sys
34

45
import click
56

67
from ci.ray_ci.doc.build_cache import BuildCache
7-
from ci.ray_ci.utils import ci_init, logger
8-
9-
from ray_release.configs.global_config import get_global_config
108

119

1210
@click.command()
@@ -18,37 +16,32 @@ def main(ray_checkout_dir: str) -> None:
1816
"""
1917
This script builds ray doc and upload build artifacts to S3.
2018
"""
21-
ci_init()
2219
# Add the safe.directory config to the global git config so that the doc build
2320
subprocess.run(
2421
["git", "config", "--global", "--add", "safe.directory", ray_checkout_dir],
2522
check=True,
2623
)
2724

28-
logger.info("Building ray doc.")
25+
print("--- Building ray doc.", file=sys.stderr)
2926
_build(ray_checkout_dir)
3027

3128
dry_run = False
32-
if (
33-
os.environ.get("BUILDKITE_PIPELINE_ID")
34-
not in get_global_config()["ci_pipeline_postmerge"]
35-
):
29+
if os.environ.get("RAYCI_STAGE", "") != "postmerge":
3630
dry_run = True
37-
logger.info(
38-
"Not uploading build artifacts because this is not a postmerge pipeline."
31+
print(
32+
"Not uploading build artifacts because this is not a postmerge pipeline.",
33+
file=sys.stderr,
3934
)
40-
41-
if os.environ.get("BUILDKITE_BRANCH") != "master":
35+
elif os.environ.get("BUILDKITE_BRANCH") != "master":
4236
dry_run = True
43-
logger.info(
44-
"Not uploading build artifacts because this is not the master branch."
37+
print(
38+
"Not uploading build artifacts because this is not the master branch.",
39+
file=sys.stderr,
4540
)
4641

47-
logger.info("Uploading build artifacts to S3.")
42+
print("--- Uploading build artifacts to S3.", file=sys.stderr)
4843
BuildCache(os.path.join(ray_checkout_dir, "doc")).upload(dry_run=dry_run)
4944

50-
return
51-
5245

5346
def _build(ray_checkout_dir):
5447
env = os.environ.copy()

ci/ray_ci/doc/cmd_check_api_discrepancy.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import click
2+
import sys
23

34
from ci.ray_ci.doc.api import API
45
from ci.ray_ci.doc.autodoc import Autodoc
56
from ci.ray_ci.doc.module import Module
6-
from ci.ray_ci.utils import logger
77

88
TEAM_API_CONFIGS = {
99
"data": {
@@ -102,24 +102,25 @@ def _check_team(ray_checkout_dir: str, team: str) -> bool:
102102
white_list_apis = TEAM_API_CONFIGS[team]["white_list_apis"]
103103

104104
# Policy 01: all public APIs should be documented
105-
logger.info(f"Validating that public {team} APIs should be documented...")
105+
print(f"--- Validating that public {team} APIs should be documented...", file=sys.stderr)
106106
good_apis, bad_apis = API.split_good_and_bad_apis(
107107
api_in_codes, api_in_docs, white_list_apis
108108
)
109109

110110
if good_apis:
111-
logger.info("Public APIs that are documented:")
111+
print("Public APIs that are documented:", file=sys.stderr)
112112
for api in good_apis:
113-
logger.info(f"\t{api}")
113+
print(f"\t{api}", file=sys.stderr)
114114

115115
if bad_apis:
116-
logger.info("Public APIs that are NOT documented:")
116+
print("Public APIs that are NOT documented:", file=sys.stderr)
117117
for api in bad_apis:
118-
logger.info(f"\t{api}")
118+
print(f"\t{api}", file=sys.stderr)
119119

120120
if bad_apis:
121-
logger.info(
122-
f"Some public {team} APIs are not documented. Please document them."
121+
print(
122+
f"Some public {team} APIs are not documented. Please document them.",
123+
file=sys.stderr,
123124
)
124125
return False
125126
return True

0 commit comments

Comments
 (0)