> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-weave-byob-note.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LaunchAgent

<Card title="소스 코드 보기" href="https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L164-L924" icon="github" />

주어진 run 큐를 폴링하고 wandb launch용 run을 실행하는 Launch 에이전트 클래스입니다.

```python theme={null}
LaunchAgent(
    api: Api,
    config: Dict[str, Any]
)
```

| 인수       | 설명                            |
| :------- | :---------------------------- |
| `api`    | 백엔드에 요청을 보내는 데 사용할 API 객체입니다. |
| `config` | 에이전트용 설정 딕셔너리입니다.             |

| 속성                       | 설명                               |
| :----------------------- | :------------------------------- |
| `num_running_jobs`       | 스케줄러를 제외한 작업 수를 반환합니다.           |
| `num_running_schedulers` | 스케줄러 수만 반환합니다.                   |
| `thread_ids`             | 에이전트에서 실행 중인 스레드 ID 키 목록을 반환합니다. |

<div id="methods">
  ## 방법
</div>

<div id="check_sweep_state">
  ### `check_sweep_state`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L786-L803)

```python theme={null}
check_sweep_state(
    launch_spec, api
)
```

sweep의 run을 시작하기 전에 해당 sweep의 상태를 확인합니다.

<div id="fail_run_queue_item">
  ### `fail_run_queue_item`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L295-L304)

```python theme={null}
fail_run_queue_item(
    run_queue_item_id, message, phase, files=None
)
```

<div id="finish_thread_id">
  ### `finish_thread_id`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L416-L509)

```python theme={null}
finish_thread_id(
    thread_id, exception=None
)
```

일단 목록에서 작업을 제거합니다.

<div id="get_job_and_queue">
  ### `get_job_and_queue`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L908-L915)

```python theme={null}
get_job_and_queue()
```

<div id="initialized">
  ### `initialized`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L190-L193)

```python theme={null}
@classmethod
initialized() -> bool
```

에이전트가 초기화되었는지 반환합니다.

<div id="loop">
  ### `loop`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L572-L653)

```python theme={null}
loop()
```

작업을 폴링하고 실행하기 위해 무한 루프로 반복합니다.

| 예외                  | 설명                      |
| :------------------ | :---------------------- |
| `KeyboardInterrupt` | 에이전트가 중지 요청을 받으면 발생합니다. |

<div id="name">
  ### `name`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L180-L188)

```python theme={null}
@classmethod
name() -> str
```

에이전트의 이름을 반환합니다.

<div id="pop_from_queue">
  ### `pop_from_queue`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L340-L363)

```python theme={null}
pop_from_queue(
    queue
)
```

작업으로 실행할 항목을 runqueue에서 꺼냅니다.

| 인수      | 설명           |
| :------ | :----------- |
| `queue` | 항목을 꺼낼 큐입니다. |

| 반환값           | 설명 |
| :------------ | :- |
| 큐에서 꺼낸 항목입니다. |    |

| 예외          | 설명                           |
| :---------- | :--------------------------- |
| `Exception` | 큐에서 항목을 꺼내는 중 오류가 발생한 경우입니다. |

<div id="print_status">
  ### `print_status`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L365-L381)

```python theme={null}
print_status() -> None
```

현재 에이전트 상태를 출력합니다.

<div id="run_job">
  ### `run_job`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L511-L541)

```python theme={null}
run_job(
    job, queue, file_saver
)
```

프로젝트를 설정하고 작업을 실행합니다.

| 인수    | 설명         |
| :---- | :--------- |
| `job` | 실행할 작업입니다. |

<div id="task_run_job">
  ### `task_run_job`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L656-L688)

```python theme={null}
task_run_job(
    launch_spec, job, default_config, api, job_tracker
)
```

<div id="update_status">
  ### `update_status`
</div>

[소스 보기](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L383-L394)

```python theme={null}
update_status(
    status
)
```

에이전트의 상태를 업데이트합니다.

| 인수       | 설명               |
| :------- | :--------------- |
| `status` | 에이전트에 설정할 상태입니다. |
