class_docstr: Tests for the multi-task wrapper.
class_docstr_tok: ["Tests","for","the","multi-task","wrapper","."]
docstr: Test that when using a warm-starteable algorithm, the multi-task wrapper is not used,
  and the `warm_start` method receives all the related trials from the KB.
code: def test_with_warmstarteable_algo(
      self, knowledge_base: DummyKnowledgeBase
  ):
      """Test that when using a warm-starteable algorithm, the multi-task wrapper is not used,
      and the `warm_start` method receives all the related trials from the KB.
      """
      experiment = build_experiment(
          name="target_2",
          space=target_space,
          knowledge_base=knowledge_base,
          algorithm=DummyWarmStarteableAlgo,
          max_trials=100,
          debug=True,
      )
      assert isinstance(
          experiment._experiment.knowledge_base, KnowledgeBase
      )
      algo = experiment.algorithm
      assert algo is not None
      assert isinstance(algo.unwrapped, DummyWarmStarteableAlgo)
      assert not algo.unwrapped.warm_start_trials
  
      while not experiment.is_done:
          trial = experiment.suggest()
          objective = random.random()
          trial_with_result = _add_result(trial, objective)
          experiment.observe(trial_with_result, [])
  
      algo = experiment.algorithm
  
      # IDEA: Add type hints to the `Experiment` class, and make it generic in terms of the
      # algorithms, so that we could get the `algorithms` to be `Random` here.
  
      assert isinstance(algo, InsistSuggest)
      assert isinstance(algo.algorithm, SpaceTransform)
      assert isinstance(
          algo.algorithm.algorithm, DummyWarmStarteableAlgo
      )
  
      unwrapped_algo = algo.unwrapped
      assert isinstance(unwrapped_algo, DummyWarmStarteableAlgo)
      # Check that the algo received the transformed trials from the KB.
      assert len(unwrapped_algo.warm_start_trials) == len(
          knowledge_base.related_trials
      )
      for (algo_exp_config, algo_trials), (
          kb_exp_config,
          kb_trials,
      ) in zip(
          unwrapped_algo.warm_start_trials,
          knowledge_base.related_trials,
      ):
          assert algo_exp_config == kb_exp_config
          # NOTE: Trials aren't identical, because some transformations might have been done
          # on the trials from the KB before the algo observes them.
          # assert algo_trials == kb_trials
          assert len(algo_trials) == len(kb_trials)
  
imports: from __future__ import annotations
  import copy
  import random
  from typing import Any, Callable, Sequence
  import numpy
  import pytest
  from orion.algo.base import BaseAlgorithm
  from orion.algo.gridsearch import GridSearch
  from orion.algo.space import Space
  from orion.algo.tpe import TPE
  from orion.client import build_experiment
  from orion.client.experiment import ExperimentClient
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.worker.algo_wrappers.insist_suggest import InsistSuggest
  from orion.core.worker.algo_wrappers.space_transform import SpaceTransform
  from orion.core.worker.experiment import Experiment
  from orion.core.worker.experiment_config import ExperimentConfig
  from orion.core.worker.primary_algo import create_algo
  from orion.core.worker.trial import Trial
  from orion.core.worker.warm_start.knowledge_base import KnowledgeBase
  from orion.core.worker.warm_start.multi_task_wrapper import MultiTaskWrapper
  from orion.storage.base import BaseStorageProtocol
  from orion.testing.dummy_algo import FixedSuggestionAlgo
  from orion.algo.random import Random
  from orion.core.worker.warm_start import WarmStarteable
label_desc: Use image node_id 4 for calling the TestMultiTaskWrapper obj's underlying member method code with example usage: obj.test_with_warmstarteable_algo(knowledge_base) without return types