From 7ac7e8778fbf52d26cb34370b21171541c049e40 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Fri, 21 Feb 2020 13:13:21 -0800 Subject: [PATCH] Port patches from 1.0.0 branch (#5336) * Remove f-string, since it's not supported by Python 3.5 (#5330) * Remove f-string, since it's not supported by Python 3.5 * Add Python 3.5 to CI, to ensure compatibility * Remove duplicated matplotlib * Show deprecation notice for Python 3.5 * Fix lint * Fix lint * Fix a unit test that mistook MINOR ver for PATCH ver * Enforce only major version in JSON model schema * Bump version to 1.1.0-SNAPSHOT --- CMakeLists.txt | 2 +- Jenkinsfile | 1 + R-package/DESCRIPTION | 4 +-- doc/model.schema | 20 +++++++++--- include/xgboost/version_config.h | 2 +- jvm-packages/pom.xml | 2 +- jvm-packages/xgboost4j-example/pom.xml | 8 ++--- jvm-packages/xgboost4j-flink/pom.xml | 6 ++-- jvm-packages/xgboost4j-spark/pom.xml | 4 +-- jvm-packages/xgboost4j/pom.xml | 4 +-- python-package/xgboost/VERSION | 2 +- python-package/xgboost/__init__.py | 8 +++++ python-package/xgboost/sklearn.py | 4 +-- tests/ci_build/Dockerfile.cpu | 11 +++++-- tests/ci_build/test_python.sh | 44 ++++++++++++++++---------- tests/cpp/common/test_version.cc | 2 +- 16 files changed, 81 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12f6f06e6421..348e7e69f578 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.12) -project(xgboost LANGUAGES CXX C VERSION 1.0.0) +project(xgboost LANGUAGES CXX C VERSION 1.1.0) include(cmake/Utils.cmake) list(APPEND CMAKE_MODULE_PATH "${xgboost_SOURCE_DIR}/cmake/modules") cmake_policy(SET CMP0022 NEW) diff --git a/Jenkinsfile b/Jenkinsfile index ddbb7339dcc8..1128f7dfeb82 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -273,6 +273,7 @@ def TestPythonCPU() { def docker_binary = "docker" sh """ ${dockerRun} ${container_type} ${docker_binary} tests/ci_build/test_python.sh cpu + ${dockerRun} ${container_type} ${docker_binary} tests/ci_build/test_python.sh cpu-py35 """ deleteDir() } diff --git a/R-package/DESCRIPTION b/R-package/DESCRIPTION index b99b130e11b0..23e64c22a545 100644 --- a/R-package/DESCRIPTION +++ b/R-package/DESCRIPTION @@ -1,8 +1,8 @@ Package: xgboost Type: Package Title: Extreme Gradient Boosting -Version: 1.0.0.1 -Date: 2019-07-23 +Version: 1.1.0.1 +Date: 2020-02-21 Authors@R: c( person("Tianqi", "Chen", role = c("aut"), email = "tianqi.tchen@gmail.com"), diff --git a/doc/model.schema b/doc/model.schema index dfa94b4f67e4..322e610c213d 100644 --- a/doc/model.schema +++ b/doc/model.schema @@ -195,12 +195,22 @@ "properties": { "version": { "type": "array", - "const": [ - 1, - 0, - 0 + "items": [ + { + "type": "number", + "const": 1 + }, + { + "type": "number", + "minimum": 0 + }, + { + "type": "number", + "minimum": 0 + } ], - "additionalItems": false + "minItems": 3, + "maxItems": 3 }, "learner": { "type": "object", diff --git a/include/xgboost/version_config.h b/include/xgboost/version_config.h index 98b83cc68ee0..56492bca96c0 100644 --- a/include/xgboost/version_config.h +++ b/include/xgboost/version_config.h @@ -5,7 +5,7 @@ #define XGBOOST_VERSION_CONFIG_H_ #define XGBOOST_VER_MAJOR 1 -#define XGBOOST_VER_MINOR 0 +#define XGBOOST_VER_MINOR 1 #define XGBOOST_VER_PATCH 0 #endif // XGBOOST_VERSION_CONFIG_H_ diff --git a/jvm-packages/pom.xml b/jvm-packages/pom.xml index a0c4689a7017..aac20a41802a 100644 --- a/jvm-packages/pom.xml +++ b/jvm-packages/pom.xml @@ -6,7 +6,7 @@ ml.dmlc xgboost-jvm_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT pom XGBoost JVM Package JVM Package for XGBoost diff --git a/jvm-packages/xgboost4j-example/pom.xml b/jvm-packages/xgboost4j-example/pom.xml index dfb25611f9d7..8f44f44a0ab5 100644 --- a/jvm-packages/xgboost4j-example/pom.xml +++ b/jvm-packages/xgboost4j-example/pom.xml @@ -6,10 +6,10 @@ ml.dmlc xgboost-jvm_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT xgboost4j-example_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT jar @@ -26,7 +26,7 @@ ml.dmlc xgboost4j-spark_${scala.binary.version} - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT org.apache.spark @@ -37,7 +37,7 @@ ml.dmlc xgboost4j-flink_${scala.binary.version} - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT org.apache.commons diff --git a/jvm-packages/xgboost4j-flink/pom.xml b/jvm-packages/xgboost4j-flink/pom.xml index 5d6615db7c9f..0409e7a758bc 100644 --- a/jvm-packages/xgboost4j-flink/pom.xml +++ b/jvm-packages/xgboost4j-flink/pom.xml @@ -6,10 +6,10 @@ ml.dmlc xgboost-jvm_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT xgboost4j-flink_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT @@ -26,7 +26,7 @@ ml.dmlc xgboost4j_${scala.binary.version} - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT org.apache.commons diff --git a/jvm-packages/xgboost4j-spark/pom.xml b/jvm-packages/xgboost4j-spark/pom.xml index cf4f00445bc0..f4203900c059 100644 --- a/jvm-packages/xgboost4j-spark/pom.xml +++ b/jvm-packages/xgboost4j-spark/pom.xml @@ -6,7 +6,7 @@ ml.dmlc xgboost-jvm_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT xgboost4j-spark_2.12 @@ -24,7 +24,7 @@ ml.dmlc xgboost4j_${scala.binary.version} - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT org.apache.spark diff --git a/jvm-packages/xgboost4j/pom.xml b/jvm-packages/xgboost4j/pom.xml index cc1e81075fba..31264f5882c1 100644 --- a/jvm-packages/xgboost4j/pom.xml +++ b/jvm-packages/xgboost4j/pom.xml @@ -6,10 +6,10 @@ ml.dmlc xgboost-jvm_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT xgboost4j_2.12 - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT jar diff --git a/python-package/xgboost/VERSION b/python-package/xgboost/VERSION index f755149315cb..5902d52cce53 100644 --- a/python-package/xgboost/VERSION +++ b/python-package/xgboost/VERSION @@ -1 +1 @@ -1.0.0-SNAPSHOT +1.1.0-SNAPSHOT diff --git a/python-package/xgboost/__init__.py b/python-package/xgboost/__init__.py index 54a25195de44..a079fe0e7a63 100644 --- a/python-package/xgboost/__init__.py +++ b/python-package/xgboost/__init__.py @@ -5,6 +5,8 @@ """ import os +import sys +import warnings from .core import DMatrix, Booster from .training import train, cv @@ -19,6 +21,12 @@ except ImportError: pass +if sys.version_info[:2] == (3, 5): + warnings.warn( + 'Python 3.5 support is deprecated; XGBoost will require Python 3.6+ in the near future. ' + + 'Consider upgrading to Python 3.6+.', + FutureWarning) + VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION') with open(VERSION_FILE) as f: __version__ = f.read().strip() diff --git a/python-package/xgboost/sklearn.py b/python-package/xgboost/sklearn.py index 9f6016e962c2..25ba27ee48bd 100644 --- a/python-package/xgboost/sklearn.py +++ b/python-package/xgboost/sklearn.py @@ -423,8 +423,8 @@ def load_model(self, fname): self.classes_ = np.array(v) continue if k == 'type' and type(self).__name__ != v: - msg = f'Current model type: {type(self).__name__}, ' + \ - f'type of model in file: {v}' + msg = 'Current model type: {}, '.format(type(self).__name__) + \ + 'type of model in file: {}'.format(v) raise TypeError(msg) if k == 'type': continue diff --git a/tests/ci_build/Dockerfile.cpu b/tests/ci_build/Dockerfile.cpu index 39b209c8e4b1..02b6024bc25e 100644 --- a/tests/ci_build/Dockerfile.cpu +++ b/tests/ci_build/Dockerfile.cpu @@ -3,6 +3,7 @@ ARG CMAKE_VERSION=3.12 # Environment ENV DEBIAN_FRONTEND noninteractive +SHELL ["/bin/bash", "-c"] # Use Bash as shell # Install all basic requirements RUN \ @@ -19,10 +20,16 @@ ENV PATH=/opt/python/bin:$PATH ENV GOSU_VERSION 1.10 -# Install Python packages +# Create new Conda environment with Python 3.5 +RUN conda create -n py35 python=3.5 && \ + source activate py35 && \ + pip install numpy pytest scipy scikit-learn pandas matplotlib wheel kubernetes urllib3 graphviz && \ + source deactivate + +# Install Python packages in default env RUN \ pip install pyyaml cpplint pylint astroid sphinx numpy scipy pandas matplotlib sh \ - recommonmark guzzle_sphinx_theme mock breathe matplotlib graphviz \ + recommonmark guzzle_sphinx_theme mock breathe graphviz \ pytest scikit-learn wheel kubernetes urllib3 jsonschema boto3 && \ pip install https://h2o-release.s3.amazonaws.com/datatable/stable/datatable-0.7.0/datatable-0.7.0-cp37-cp37m-linux_x86_64.whl && \ pip install "dask[complete]" diff --git a/tests/ci_build/test_python.sh b/tests/ci_build/test_python.sh index 44882104055e..702f4cea605b 100755 --- a/tests/ci_build/test_python.sh +++ b/tests/ci_build/test_python.sh @@ -5,31 +5,35 @@ set -x suite=$1 # Install XGBoost Python package -wheel_found=0 -for file in python-package/dist/*.whl -do - if [ -e "${file}" ] +function install_xgboost { + wheel_found=0 + for file in python-package/dist/*.whl + do + if [ -e "${file}" ] + then + pip install --user "${file}" + wheel_found=1 + break # need just one + fi + done + if [ "$wheel_found" -eq 0 ] then - pip install --user "${file}" - wheel_found=1 - break # need just one + pushd . + cd python-package + python setup.py install --user + popd fi -done -if [ "$wheel_found" -eq 0 ] -then - pushd . - cd python-package - python setup.py install --user - popd -fi +} # Run specified test suite case "$suite" in gpu) + install_xgboost pytest -v -s --fulltrace -m "not mgpu" tests/python-gpu ;; mgpu) + install_xgboost pytest -v -s --fulltrace -m "mgpu" tests/python-gpu cd tests/distributed ./runtests-gpu.sh @@ -39,17 +43,25 @@ case "$suite" in cudf) source activate cudf_test + install_xgboost pytest -v -s --fulltrace -m "not mgpu" tests/python-gpu/test_from_columnar.py tests/python-gpu/test_from_cupy.py ;; cpu) + install_xgboost pytest -v -s --fulltrace tests/python cd tests/distributed ./runtests.sh ;; + cpu-py35) + source activate py35 + install_xgboost + pytest -v -s --fulltrace tests/python + ;; + *) - echo "Usage: $0 {gpu|mgpu|cudf|cpu}" + echo "Usage: $0 {gpu|mgpu|cudf|cpu|cpu-py35}" exit 1 ;; esac diff --git a/tests/cpp/common/test_version.cc b/tests/cpp/common/test_version.cc index a2b7ed36c6a8..e6ee030f7b8c 100644 --- a/tests/cpp/common/test_version.cc +++ b/tests/cpp/common/test_version.cc @@ -54,7 +54,7 @@ TEST(Version, Basic) { ptr = 0; v = std::stoi(str, &ptr); - ASSERT_EQ(v, XGBOOST_VER_MINOR) << "patch: " << v;; + ASSERT_EQ(v, XGBOOST_VER_PATCH) << "patch: " << v;; str = str.substr(ptr); ASSERT_EQ(str.size(), 0);