@@ -124,10 +124,18 @@ def try_fetch_jvm_doc(branch: str) -> bool:
124
124
"""
125
125
try :
126
126
local_jvm_docs = os .environ .get ("XGBOOST_JVM_DOCS" , None )
127
+ url = f"{ S3_BUCKET } /{ branch } /{ commit } /{ branch } .tar.bz2"
127
128
if local_jvm_docs is not None :
128
- filename = os .path .expanduser (local_jvm_docs )
129
+ local_jvm_docs = os .path .expanduser (local_jvm_docs )
130
+
131
+ if local_jvm_docs is not None and os .path .exists (local_jvm_docs ):
132
+ # Reuse an existing tarball.
133
+ filename = local_jvm_docs
134
+ elif local_jvm_docs is not None :
135
+ # Download to local_jvm_docs for future reuse.
136
+ filename , _ = urllib .request .urlretrieve (url , filename = local_jvm_docs )
137
+ print (f"Finished: { url } -> { filename } " )
129
138
else :
130
- url = f"{ S3_BUCKET } /{ branch } /{ commit } /{ branch } .tar.bz2"
131
139
filename , _ = urllib .request .urlretrieve (url )
132
140
print (f"Finished: { url } -> { filename } " )
133
141
if not os .path .exists (TMP_DIR ):
@@ -161,10 +169,17 @@ def download_r_docs() -> None:
161
169
def try_fetch_r_doc (branch : str ) -> bool :
162
170
try :
163
171
local_r_docs = os .environ .get ("XGBOOST_R_DOCS" , None )
172
+ url = f"{ S3_BUCKET } /{ branch } /{ commit } /r-docs-{ branch } .tar.bz2"
164
173
if local_r_docs is not None :
165
- filename = os .path .expanduser (local_r_docs )
174
+ local_r_docs = os .path .expanduser (local_r_docs )
175
+
176
+ if local_r_docs is not None and os .path .exists (local_r_docs ):
177
+ # Reuse an existing tarball.
178
+ filename = local_r_docs
179
+ elif local_r_docs is not None :
180
+ filename , _ = urllib .request .urlretrieve (url , filename = local_r_docs )
181
+ print (f"Finished: { url } -> { filename } " )
166
182
else :
167
- url = f"{ S3_BUCKET } /{ branch } /{ commit } /r-docs-{ branch } .tar.bz2"
168
183
filename , _ = urllib .request .urlretrieve (url )
169
184
print (f"Finished: { url } -> { filename } " )
170
185
0 commit comments