1- import boto3
2- import botocore
31import subprocess
42import tarfile
53import os
6- import click
7- from botocore import UNSIGNED
8- from botocore .client import Config
94import time
5+
6+ import click
107import requests
118
12- S3_BUCKET = "ray-ci-results"
13- DOC_BUILD_DIR_S3 = "doc_build"
149LAST_BUILD_CUTOFF = 3 # how many days ago to consider a build outdated
1510PENDING_FILES_PATH = "pending_files.txt"
1611ENVIRONMENT_PICKLE = "_build/doctrees/environment.pickle"
17- DOC_BUILD_S3_URL = "https://ray-ci-results.s3.us-west-2.amazonaws.com/doc_build"
12+ DOC_BUILD_CACHE_URL = "https://rayci.anyscale.dev/ray/doc/build-cache"
13+
14+
15+ def _build_cache_url (commit : str ):
16+ return f"{ DOC_BUILD_CACHE_URL } /{ commit } .tgz"
1817
1918
2019def find_latest_master_commit ():
@@ -34,33 +33,32 @@ def find_latest_master_commit():
3433 .split ("\n " )
3534 )
3635 for commit in latest_commits :
37- result = requests .head (f" { DOC_BUILD_S3_URL } / { commit } .tgz" )
38- if result .status_code == 200 :
39- return commit
36+ with requests .head (_build_cache_url ( commit ), allow_redirects = True ) as response :
37+ if response .status_code == 200 :
38+ return commit
4039 raise Exception (
41- "No cache found for latest master commit."
40+ "No cache found for latest master commit. "
4241 "Please merge with upstream master or use 'make develop'."
4342 )
4443
4544
46- def fetch_cache_from_s3 (commit , target_file_path ):
45+ def fetch_cache (commit , target_file_path ):
4746 """
48- Fetch doc cache archive from ray-ci-results S3 bucket
47+ Fetch doc cache archive from rayci.anyscale.dev
4948
5049 Args:
5150 commit: The commit hash of the doc cache to fetch
5251 target_file_path: The file path to save the doc cache archive
5352 """
54- # Create an S3 client
55- s3 = boto3 .client ("s3" , config = Config (signature_version = UNSIGNED ))
56- s3_file_path = f"{ DOC_BUILD_DIR_S3 } /{ commit } .tgz"
57- try :
58- print (f"Fetching doc cache from commit { commit } ..." )
59- s3 .download_file (S3_BUCKET , s3_file_path , target_file_path )
60- print (f"Successfully downloaded { s3_file_path } to { target_file_path } " )
61- except botocore .exceptions .ClientError as e :
62- print (f"Failed to download { s3_file_path } from S3: { str (e )} " )
63- raise e
53+
54+ with requests .get (
55+ _build_cache_url (commit ), allow_redirects = True , stream = True
56+ ) as response :
57+ response .raise_for_status ()
58+ with open (target_file_path , "wb" ) as f :
59+ for chunk in response .iter_content (chunk_size = 8192 ):
60+ f .write (chunk )
61+ print (f"Successfully downloaded { target_file_path } " )
6462
6563
6664def extract_cache (cache_path : str , doc_dir : str ):
@@ -149,8 +147,9 @@ def main(ray_dir: str) -> None:
149147 f .write ("\n " .join (filenames ))
150148
151149 cache_path = f"{ ray_dir } /doc.tgz"
152- # Fetch cache of that commit from S3 to cache_path
153- fetch_cache_from_s3 (latest_master_commit , cache_path )
150+ # Fetch cache of that commit from build cache archive to cache_path
151+ print (f"Use build cache for commit { latest_master_commit } " )
152+ fetch_cache (latest_master_commit , cache_path )
154153 # Extract cache to override ray/doc directory
155154 extract_cache (cache_path , f"{ ray_dir } /doc" )
156155 os .remove (cache_path )
0 commit comments