Skip to content

Commit 0460d1d

Browse files
authored
Use PIP instead of Conda in Read the Docs build to speed up (#1387)
For a bit of background: Currently documentation generation is being failed in Read the Docs due to timeout. The largest portion of time is being consumed for Conda installation, and seems like Read the Docs maintainers also encourage people to just use PIP instead (see also `https://github.com/readthedocs/readthedocs.org/issues/6254#issuecomment-542288316`). We use Conda installation in order to install JDK 8 because Read the Docs has JDK 11 by default, and Spark 2.x does not support JDK 11. For what this PR proposes: This PR switches Conda to PIP to install Java 8 via using `install-jdk` package. Seems like they use AdoptOpenJDK instead but the jobs looks passing see https://readthedocs.org/projects/koalas/builds/10741596/. Once Spark 3.0 is released, we can remove all related codes as Spark 3.0 supports JDK 11, and we don't need to install JDK 8 manually. This PR decreases build time 1000 seconds (timeout) to around 900 seconds.
1 parent 04deb86 commit 0460d1d

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

.github/workflows/master.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ jobs:
6868
# as Black only works with Python 3.6+. This is hacky but we will drop
6969
# Python 3.5 soon so it's fine.
7070
sed -i '/black/d' requirements-dev.txt
71+
# 'install-jdk' does not support Python 3.5. This is hacky but we will remove
72+
# once Spark 3.0 is released. See also https://github.com/databricks/koalas/pull/1387
73+
sed -i '/install-jdk/d' requirements-dev.txt
7174
pip install -r requirements-dev.txt
7275
pip install pandas==$PANDAS_VERSION pyarrow==$PYARROW_VERSION
7376
pip list
@@ -142,6 +145,9 @@ jobs:
142145
conda config --env --add pinned_packages pandas==$PANDAS_VERSION
143146
conda config --env --add pinned_packages pyarrow==$PYARROW_VERSION
144147
conda install -c conda-forge --yes pandas==$PANDAS_VERSION pyarrow==$PYARROW_VERSION
148+
# 'install-jdk' does not exist in Conda. This is hacky but we will remove
149+
# once Spark 3.0 is released. See also https://github.com/databricks/koalas/pull/1387
150+
sed -i '/install-jdk/d' requirements-dev.txt
145151
conda install -c conda-forge --yes --freeze-installed --file requirements-dev.txt
146152
conda list
147153
- name: Run tests

.readthedocs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,4 @@ python:
3636
path: .
3737
extra_requirements:
3838
- spark
39-
conda:
40-
environment: dev/readthedocs-environment.yml
4139

dev/readthedocs-environment.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/source/conf.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import errno
1818

1919
from databricks import koalas
20+
from databricks.koalas import utils
2021
sys.path.insert(0, os.path.abspath('.'))
2122

2223
# Remove previously generated rst files. Ignore errors just in case it stops generating whole docs.
@@ -28,6 +29,22 @@
2829
raise
2930

3031

32+
if "READTHEDOCS" in os.environ:
33+
# For Read the Docs, it has JDK 11 by default. Spark 2.x only supports JDK 8 at most.
34+
# Once Spark 3.0 is released, we can remove this as Spark 3.0 supports JDK 11.
35+
# For now, we should manually install JDK 8.
36+
import jdk
37+
if not os.path.isdir(jdk._JRE_DIR):
38+
jdk.install("8", jre=True)
39+
java_home = "%s/%s" % (jdk._JRE_DIR, os.listdir(jdk._JRE_DIR)[0])
40+
os.environ["JAVA_HOME"] = java_home
41+
os.environ["PATH"] = "%s/bin:%s" % (java_home, os.environ["PATH"])
42+
43+
44+
# Lower the number of partitions to speed up documentation build
45+
utils.default_session({"spark.sql.shuffle.partitions": "4"})
46+
47+
3148
def gendoc():
3249
"""Get releases from Github and generate reStructuredText files for release notes."""
3350
dev_dir = "%s/../../dev" % os.path.dirname(os.path.abspath(__file__))

requirements-dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ pytest-cov
3030
scikit-learn
3131
openpyxl
3232
xlrd
33+
34+
# For Read the docs
35+
install-jdk

0 commit comments

Comments
 (0)