code: def test_agent_restart_exp_container_failure(
      restartable_managed_cluster: ManagedCluster,
  ) -> None:
      restartable_managed_cluster.ensure_agent_ok()
      try:
          exp_id = exp.create_experiment(
              conf.fixtures_path("no_op/single-medium-train-step.yaml"),
              conf.fixtures_path("no_op"),
              None,
          )
          exp.wait_for_experiment_workload_progress(exp_id)
          container_ids = list(
              _local_container_ids_for_experiment(exp_id)
          )
          if len(container_ids) != 1:
              pytest.fail(
                  f"unexpected number of local containers for the experiment: {len(container_ids)}"
              )
          # Get task id / allocation id
          tasks_data = _task_list_json(conf.make_master_url())
          assert len(tasks_data) == 1
          exp_task_before = list(tasks_data.values())[0]
  
          restartable_managed_cluster.kill_agent()
          subprocess.run(
              ["docker", "kill", container_ids[0]],
              check=True,
              stdout=subprocess.PIPE,
          )
      except Exception:
          restartable_managed_cluster.restart_agent()
          raise
      else:
          restartable_managed_cluster.restart_agent()
          # As soon as the agent is back, the original allocation should be considered dead,
          # but the new one should be allocated.
          state = exp.experiment_state(exp_id)
          # old STATE_ACTIVE got divided into three states
          assert state in [
              EXP_STATE.ACTIVE,
              EXP_STATE.QUEUED,
              EXP_STATE.PULLING,
              EXP_STATE.STARTING,
              EXP_STATE.RUNNING,
          ]
          exp.wait_for_experiment_state(exp_id, EXP_STATE.RUNNING)
          tasks_data = _task_list_json(conf.make_master_url())
          assert len(tasks_data) == 1
          exp_task_after = list(tasks_data.values())[0]
  
          assert exp_task_before["taskId"] == exp_task_after["taskId"]
          assert (
              exp_task_before["allocationId"]
              != exp_task_after["allocationId"]
          )
  
          exp.wait_for_experiment_state(exp_id, EXP_STATE.COMPLETED)
  
imports: import json
  import subprocess
  import time
  import uuid
  from pathlib import Path
  from typing import Any, Dict, Iterator, Tuple
  import pytest
  from determined.common.api.bindings import experimentv1State
  from tests import config
  from tests import experiment
  from .managed_cluster import ManagedCluster
  from .utils import assert_command_succeeded, get_command_info, run_command, wait_for_command_state
label_desc: Use image node_id 6 for calling a global function with example usage: test_agent_restart_exp_container_failure(restartable_managed_cluster) without return types