MCPcopy Create free account
hub / github.com/dmlc/xgboost / run_test

Method run_test

tests/python-gpu/test_gpu_pickling.py:115–145  ·  view source on GitHub ↗
(param: Dict[str, Any])

Source from the content-addressed store, hash-verified

113 train_x = xgb.DMatrix(x, label=y)
114
115 def run_test(param: Dict[str, Any]) -> None:
116 bst = xgb.train(param, train_x)
117
118 save_pickle(bst, model_path)
119
120 args = self.args_template.copy()
121 root = tm.project_root(__file__)
122 path = os.path.join(root, "tests", "python-gpu", "load_pickle.py")
123 args.append(path + "::TestLoadPickle::test_context_is_removed")
124
125 cuda_environment = {"CUDA_VISIBLE_DEVICES": "-1"}
126 env = os.environ.copy()
127 env.update(cuda_environment)
128
129 # Load model in a CPU only environment.
130 status = subprocess.call(args, env=env)
131 assert status == 0
132
133 args = self.args_template.copy()
134 args.append(
135 "./tests/python-gpu/"
136 "load_pickle.py::TestLoadPickle::test_context_is_preserved"
137 )
138
139 # Load in environment that has GPU.
140 env = os.environ.copy()
141 assert "CUDA_VISIBLE_DEVICES" not in env.keys()
142 status = subprocess.call(args, env=env)
143 assert status == 0
144
145 os.remove(model_path)
146
147 param = {"tree_method": "hist", "verbosity": 1, "device": "cuda"}
148 run_test(param)

Callers

nothing calls this directly

Calls 5

save_pickleFunction · 0.85
copyMethod · 0.80
removeMethod · 0.80
trainMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected