11#! /usr/bin/env bash
2+ #
3+ # This file is responsible for installing any dependencies needed by the various
4+ # DFFML plugins, the docs, and DFFML itself.
5+
6+ # set -e to exit this script if any programs run by this script fail
7+ # set -x to echo everything we do before we do it
28set -ex
39
410export PLUGIN=" ${1} "
@@ -7,14 +13,27 @@ if [ "x${PIP_CACHE_DIR}" != "x" ]; then
713 mkdir -p " ${PIP_CACHE_DIR} "
814fi
915
16+ # Get the python version in the format of pyMajorMinor, example: py37
1017python_version=" py$( python -c ' import sys; print(f"{sys.version_info.major}{sys.version_info.minor}")' ) "
1118
1219export PATH=" ${PIP_CACHE_DIR} /miniconda${python_version} /bin:$PATH "
1320
21+ # True or False for if `conda` is in the PATH
1422has_conda=$( python -c ' import pathlib, os; print(any(map(lambda path: pathlib.Path(path, "conda").is_file(), os.environ.get("PATH", "").split(":"))))' )
1523
1624mkdir -p " ${HOME} /.local/bin"
1725
26+
27+ # ========================== BEGIN GLOBAL DEPENDENCIES =========================
28+ #
29+ # Dependencies that are applicable to the main package and plugins, or just must
30+ # be installed first.
31+
32+ # Install conda because some plugins have dependencies which are only available
33+ # on conda (those listed first). Also because we need to install those packages
34+ # for the integration tests for the main package (.) and when generating the
35+ # docs. Has to be installed first because other packages will be installed into
36+ # the environment that we set up using it (essentially a virtualenv)
1837if [[ " x${PLUGIN} " == " xmodel/daal4py" ]] || \
1938 [[ " x${PLUGIN} " == " xmodel/vowpalWabbit" ]] || \
2039 [[ " x${PLUGIN} " == " x." ]] || \
@@ -49,10 +68,21 @@ if [[ "x${PLUGIN}" == "xmodel/daal4py" ]] || \
4968 fi
5069fi
5170
71+ # Install and upgrade
72+ # pip and setuptools, which are used to install other packages
73+ # twine, which is used to upload released packages to PyPi
5274python -m pip install --upgrade pip setuptools twine
5375
54- # Install main package
55- pip install -U -e .[dev]
76+ # Install main package so that other packages have access to it
77+ python -m pip install -U -e .[dev]
78+
79+ # ========================== END GLOBAL DEPENDENCIES =========================
80+
81+
82+ # =========================== BEGIN TEST DEPENDENCIES ==========================
83+ #
84+ # Dependencies for specific plugins only used when running the tests for those
85+ # plugins. Not when generating docs or running main package integration tests
5686
5787if [[ " x${PLUGIN} " == " xfeature/git" ]] || \
5888 [[ " x${PLUGIN} " == " xoperations/deploy" ]]; then
@@ -67,11 +97,30 @@ if [ "${PLUGIN}" == "source/mysql" ]; then
6797 docker pull mariadb:10
6898fi
6999
100+ # =========================== END TEST DEPENDENCIES ==========================
101+
102+
103+ # ========================== BEGIN INSTALL DEPENDENCIES ========================
104+ #
105+ # Dependencies which must be installed prior to installing a plugin. If a plugin
106+ # requires something be installed, it must also ensure that those dependencies
107+ # get installed when we are running the tests for the main package (.) or the
108+ # docs (docs). Each if statement seen here will check if we are running tests
109+ # for the plugin, main package, or docs, and install if any of those conditions
110+ # are true.
111+
70112if [[ " x${PLUGIN} " == " xmodel/vowpalWabbit" ]] || \
71113 [[ " x${PLUGIN} " == " x." ]] || \
72114 [[ " x${PLUGIN} " == " xdocs" ]]; then
73115 set +e
116+ # conda sometimes is a bash function, which does not abide by strict error
117+ # checking, so we have to turn off exit on error and only exit if the return
118+ # code of the conda bash function is non-zero
74119 conda install -y -c conda-forge vowpalwabbit
120+ exit_code=$?
121+ if [[ " x${exit_code} " != " x0" ]]; then
122+ exit " ${exit_code} "
123+ fi
75124 set -e
76125fi
77126
@@ -81,31 +130,53 @@ if ([[ "x${PLUGIN}" == "xmodel/daal4py" ]] || \
81130 [[ " ${python_version} " != " py38" ]]; then
82131 # daal4py only supports ^ Python 3.7
83132 set +e
133+ # See comment in vowpalWabbit about conda exit codes
84134 conda install -y -c intel daal4py
85- echo " conda install -y -c intel daal4py, exit code: $? "
135+ exit_code=$?
136+ if [[ " x${exit_code} " != " x0" ]]; then
137+ exit " ${exit_code} "
138+ fi
86139 set -e
87140fi
88141
89- if [ " x${PLUGIN} " == " xmodel/tensorflow_hub" ]; then
90- python -m pip install -U -e " ./model/tensorflow"
142+ if [[ " x${PLUGIN} " == " xoperations/nlp" ]]; then
143+ # See comment in vowpalWabbit about conda exit codes
144+ set +e
145+ conda install -y -c conda-forge spacy
146+ exit_code=$?
147+ if [[ " x${exit_code} " != " x0" ]]; then
148+ exit " ${exit_code} "
149+ fi
150+ set -e
151+ python -m spacy download en_core_web_sm
91152fi
92153
93154if [[ " x${PLUGIN} " == " xmodel/autosklearn" ]] || \
94155 [[ " x${PLUGIN} " == " x." ]] || \
95156 [[ " x${PLUGIN} " == " xdocs" ]]; then
96157 sudo apt-get install -y build-essential swig
97- curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install
158+ curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt |
159+ xargs -n 1 -L 1 pip install
98160fi
99161
100- if [[ " x${PLUGIN} " == " xoperations/deploy" ]]; then
101- python -m pip install -U -e " ./feature/git"
162+ # ========================== END INSTALL DEPENDENCIES ========================
163+
164+
165+ # =========================== BEGIN INTER DEPENDENCIES =========================
166+ #
167+ # Core plugins which depend on other code plugins should install those core
168+ # plugins that they depend on here
169+
170+ if [ " x${PLUGIN} " == " xmodel/tensorflow_hub" ]; then
171+ python -m pip install -U -e " ./model/tensorflow"
102172fi
103173
104- if [[ " x${PLUGIN} " == " xoperations/nlp" ]]; then
105- conda install -y -c conda-forge spacy
106- python -m spacy download en_core_web_sm
174+ if [[ " x${PLUGIN} " == " xoperations/deploy" ]]; then
175+ python -m pip install -U -e " ./feature/git"
107176fi
108177
109178if [ " x${PLUGIN} " = " xexamples/shouldi" ]; then
110179 python -m pip install -U -e " ./feature/git"
111180fi
181+
182+ # =========================== END INTER DEPENDENCIES =========================
0 commit comments