class_docstr: Base class for testing Profet tasks.
class_docstr_tok: ["Base","class","for","testing","Profet","tasks","."]
docstr: Tests that when instantiating multiple tasks with the same arguments, the
  meta-model is trained only once.
docstr_tok: ["Tests","that","when","instantiating","multiple","tasks","with","the","same","arguments",",","the","meta-model","is","trained","only","once","."]
code: def test_instantiating_task(
      self,
      profet_train_config: MetaModelConfig,
      profet_input_dir: Path,
      tmp_path_factory: TempPathFactory,
      checkpoint_dir: Path,
      mocker: MockerFixture,
  ):
      """Tests that when instantiating multiple tasks with the same arguments, the
      meta-model is trained only once.
      """
      # Directory should be empty.
      assert len(list(checkpoint_dir.iterdir())) == 0
  
      mocked_get_task_network = mocker.spy(
          profet_train_config, "get_task_network"
      )
      mocked_load_task_network = mocker.spy(
          profet_train_config, "load_task_network"
      )
      assert mocked_get_task_network.call_count == 0
      assert mocked_load_task_network.call_count == 0
  
      task_a = self.Task(
          model_config=profet_train_config,
          input_dir=profet_input_dir,
          checkpoint_dir=checkpoint_dir,
      )
      assert mocked_get_task_network.call_count == 1
      mocked_get_task_network.assert_called_once_with(
          input_path=task_a.input_dir
      )
      assert mocked_load_task_network.call_count == 0
  
      # Directory should have one file (the trained model checkpoint).
      assert len(list(checkpoint_dir.iterdir())) == 1
  
      task_b = self.Task(
          model_config=profet_train_config,
          input_dir=profet_input_dir,
          checkpoint_dir=checkpoint_dir,
      )
      assert task_a.configuration == task_b.configuration
      assert task_a.checkpoint_file == task_b.checkpoint_file
  
      assert mocked_get_task_network.call_count == 1
      assert mocked_load_task_network.call_count == 1
      mocked_load_task_network.assert_called_once_with(
          task_b.checkpoint_file
      )
  
      # Directory should *still* only have one file (the trained model checkpoint).
      assert len(list(checkpoint_dir.iterdir())) == 1
  
imports: from dataclasses import asdict, replace
  from logging import getLogger
  from pathlib import Path
  from typing import ClassVar, Type
  import numpy
  import pytest
  from _pytest.tmpdir import TempPathFactory
  from orion.algo.space import Space
  from typing import List, Union, overload
  from pytest_mock import MockerFixture
  from orion.benchmark.task.profet.profet_task import MetaModelConfig, ProfetTask
  from orion.core.worker.trial import Trial
  from .conftest import REAL_PROFET_DATA_DIR, is_nonempty_dir
label_desc: Use image node_id 5 for calling the ProfetTaskTests obj's underlying member method code with example usage: obj.test_instantiating_task(profet_train_config, profet_input_dir, tmp_path_factory, checkpoint_dir, mocker) without return types