From bc08e0c9d10cab1164e75a0cc903e6c73f78105f Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Wed, 27 Jan 2021 17:44:49 +0800 Subject: [PATCH] Remove `experimental_json_serialization` from tests. (#6640) --- src/learner.cc | 8 ++------ tests/cpp/test_serialization.cc | 1 - tests/python-gpu/test_gpu_prediction.py | 7 ++++--- tests/python-gpu/test_gpu_training_continuation.py | 11 ++--------- tests/python-gpu/test_gpu_updaters.py | 4 +--- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/learner.cc b/src/learner.cc index 2465f72a4..40af4e715 100644 --- a/src/learner.cc +++ b/src/learner.cc @@ -632,8 +632,7 @@ class LearnerIO : public LearnerConfiguration { private: std::set saved_configs_ = {"num_round"}; // Used to identify the offset of JSON string when - // `enable_experimental_json_serialization' is set to false. Will be removed once JSON - // takes over. + // Will be removed once JSON takes over. Right now we still loads some RDS files from R. std::string const serialisation_header_ { u8"CONFIG-offset:" }; public: @@ -816,10 +815,7 @@ class LearnerIO : public LearnerConfiguration { } // Save model into binary format. The code is about to be deprecated by more robust - // JSON serialization format. This function is uneffected by - // `enable_experimental_json_serialization` as user might enable this flag for pickle - // while still want a binary output. As we are progressing at replacing the binary - // format, there's no need to put too much effort on it. + // JSON serialization format. void SaveModel(dmlc::Stream* fo) const override { LearnerModelParamLegacy mparam = mparam_; // make a copy to potentially modify std::vector > extra_attr; diff --git a/tests/cpp/test_serialization.cc b/tests/cpp/test_serialization.cc index ed1a5d998..7df5d9ab2 100644 --- a/tests/cpp/test_serialization.cc +++ b/tests/cpp/test_serialization.cc @@ -339,7 +339,6 @@ TEST_F(SerializationTest, ConfigurationCount) { auto learner = std::unique_ptr(Learner::Create(mat)); learner->SetParam("tree_method", "gpu_hist"); - learner->SetParam("enable_experimental_json_serialization", "1"); for (size_t i = 0; i < 10; ++i) { learner->UpdateOneIter(i, p_dmat); diff --git a/tests/python-gpu/test_gpu_prediction.py b/tests/python-gpu/test_gpu_prediction.py index e2c2afff9..7b16cb15d 100644 --- a/tests/python-gpu/test_gpu_prediction.py +++ b/tests/python-gpu/test_gpu_prediction.py @@ -283,9 +283,10 @@ class TestGPUPredict: y = (x0 * 10 - 20) + (x1 - 2) dtrain = xgb.DMatrix(df, label=y, enable_categorical=True) - params = {'tree_method': 'gpu_hist', 'predictor': 'gpu_predictor', - 'enable_experimental_json_serialization': True, - 'max_depth': 3, 'learning_rate': 1.0, 'base_score': 0.0, 'eval_metric': 'rmse'} + params = { + 'tree_method': 'gpu_hist', 'predictor': 'gpu_predictor', + 'max_depth': 3, 'learning_rate': 1.0, 'base_score': 0.0, 'eval_metric': 'rmse' + } eval_history = {} bst = xgb.train(params, dtrain, num_boost_round=5, evals=[(dtrain, 'train')], diff --git a/tests/python-gpu/test_gpu_training_continuation.py b/tests/python-gpu/test_gpu_training_continuation.py index e1b38580c..7fa17d4be 100644 --- a/tests/python-gpu/test_gpu_training_continuation.py +++ b/tests/python-gpu/test_gpu_training_continuation.py @@ -6,15 +6,14 @@ rng = np.random.RandomState(1994) class TestGPUTrainingContinuation: - def run_training_continuation(self, use_json): + def test_training_continuation(self): kRows = 64 kCols = 32 X = np.random.randn(kRows, kCols) y = np.random.randn(kRows) dtrain = xgb.DMatrix(X, y) params = {'tree_method': 'gpu_hist', 'max_depth': '2', - 'gamma': '0.1', 'alpha': '0.01', - 'enable_experimental_json_serialization': use_json} + 'gamma': '0.1', 'alpha': '0.01'} bst_0 = xgb.train(params, dtrain, num_boost_round=64) dump_0 = bst_0.get_dump(dump_format='json') @@ -48,9 +47,3 @@ class TestGPUTrainingContinuation: obj_0 = json.loads(dump_0[i]) obj_1 = json.loads(dump_1[i]) recursive_compare(obj_0, obj_1) - - def test_gpu_training_continuation_binary(self): - self.run_training_continuation(False) - - def test_gpu_training_continuation_json(self): - self.run_training_continuation(True) diff --git a/tests/python-gpu/test_gpu_updaters.py b/tests/python-gpu/test_gpu_updaters.py index 016faf656..9e96b7c21 100644 --- a/tests/python-gpu/test_gpu_updaters.py +++ b/tests/python-gpu/test_gpu_updaters.py @@ -63,9 +63,7 @@ class TestGPUUpdaters: by_etl_results = {} by_builtin_results = {} - parameters = {'tree_method': 'gpu_hist', - 'predictor': 'gpu_predictor', - 'enable_experimental_json_serialization': True} + parameters = {'tree_method': 'gpu_hist', 'predictor': 'gpu_predictor'} m = xgb.DMatrix(onehot, label, enable_categorical=True) xgb.train(parameters, m,