class_docstr: Launch agent class which polls run given run queues and launches runs for wandb launch.
docstr: Checks the stateof the run to ensure it has been inited. Note this will not behave well with resuming.
docstr_tok: ["Checks","the","stateof","the","run","to","ensure","it","has","been","inited",".","Note","this","will","not","behave","well","with","resuming","."]
code: def _check_run_exists_and_inited(
      self, entity: str, project: str, run_id: str, rqi_id: str
  ) -> bool:
      """Checks the stateof the run to ensure it has been inited. Note this will not behave well with resuming."""
      # Checks the _wandb key in the run config for the run queue item id. If it exists, the
      # submitted run definitely called init. Falls back to checking state of run.
      # TODO: handle resuming runs
  
      # Sweep runs exist but are in pending state, normal launch runs won't exist
      # so will raise a CommError.
      try:
          run_state = self._api.get_run_state(entity, project, run_id)
          if run_state.lower() != "pending":
              return True
      except CommError:
          _logger.info(
              f"Run {entity}/{project}/{run_id} with rqi id: {rqi_id} did not have associated run"
          )
      return False
  
imports: import asyncio
  import logging
  import os
  import pprint
  import threading
  import time
  import traceback
  from dataclasses import dataclass
  from multiprocessing import Event
  from typing import Any, Dict, List, Optional, Union
  import wandb
  from wandb.apis.internal import Api
  from wandb.errors import CommError
  from wandb.sdk.launch._launch_add import launch_add
  from wandb.sdk.launch.runner.local_container import LocalSubmittedRun
  from wandb.sdk.launch.runner.local_process import LocalProcessRunner
  from wandb.sdk.launch.sweeps.scheduler import Scheduler
  from wandb.sdk.lib import runid
  from ..None import loader
  from .._project_spec import LaunchProject, create_project_from_spec, fetch_and_validate_project
  from ..builder.build import construct_agent_configs
  from ..errors import LaunchDockerError, LaunchError
  from ..utils import LAUNCH_DEFAULT_PROJECT, LOG_PREFIX, PROJECT_SYNCHRONOUS, event_loop_thread_exec
  from .job_status_tracker import JobAndRunStatusTracker
  from .run_queue_item_file_saver import RunQueueItemFileSaver
label_desc: Use image node_id 10 for calling the LaunchAgent obj's underlying member method code with example usage: obj._check_run_exists_and_inited(entity, project, run_id, rqi_id) and returns: False, True