class_docstr: The e2e test for hparam tuning using Tuner API.
class_docstr_tok: ["The","e2e","test","for","hparam","tuning","using","Tuner","API","."]
docstr: Test a successful run.
docstr_tok: ["Test","a","successful","run","."]
code: def test_tuner_with_xgboost_trainer(self):
      """Test a successful run."""
      trainer = XGBoostTrainer(
          label_column="target",
          params={},
          datasets={"train": gen_dataset_func_eager()},
      )
      # prep_v1 = StandardScaler(["worst radius", "worst area"])
      # prep_v2 = StandardScaler(["worst concavity", "worst smoothness"])
      param_space = {
          "scaling_config": ScalingConfig(
              num_workers=tune.grid_search([1, 2])
          ),
          # "preprocessor": tune.grid_search([prep_v1, prep_v2]),
          "datasets": {
              "train": tune.grid_search(
                  [
                      gen_dataset_func(),
                      gen_dataset_func(do_shuffle=True),
                  ]
              ),
          },
          "params": {
              "objective": "binary:logistic",
              "tree_method": "approx",
              "eval_metric": ["logloss", "error"],
              "eta": tune.loguniform(1e-4, 1e-1),
              "subsample": tune.uniform(0.5, 1.0),
              "max_depth": tune.randint(1, 9),
          },
      }
      tuner = Tuner(
          trainable=trainer,
          run_config=RunConfig(name="test_tuner"),
          param_space=param_space,
          tune_config=TuneConfig(mode="min", metric="train-error"),
          # limiting the number of trials running at one time.
          # As the unit test only has access to 4 CPUs on Buildkite.
          _tuner_kwargs={"max_concurrent_trials": 1},
      )
      results = tuner.fit()
      assert len(results) == 4
  
imports: import os
  from pathlib import Path
  from unittest.mock import patch
  import pytest
  import unittest
  from typing import Optional
  from sklearn.datasets import load_breast_cancer
  from sklearn.utils import shuffle
  import ray
  from ray import train, tune
  from ray.train import CheckpointConfig, RunConfig, ScalingConfig
  from ray.train.constants import RAY_CHDIR_TO_TRIAL_DIR
  from ray.train.examples.pytorch.torch_linear_example import train_func
  from ray.data import Dataset, Datasource, ReadTask, from_pandas, read_datasource
  from ray.data.block import BlockMetadata
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.train.torch import TorchTrainer
  from ray.train.trainer import BaseTrainer
  from ray.train.xgboost import XGBoostTrainer
  from ray.tune import Callback, CLIReporter
  from ray.tune.tune_config import TuneConfig
  from ray.tune.tuner import Tuner
label_desc: Use image node_id 4 for calling the TunerTest obj's underlying member method code with example usage: obj.test_tuner_with_xgboost_trainer() without return types