> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LaunchAgent

<Card title="Voir le code source" href="https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L164-L924" icon="code" />

Classe d’agent Launch qui interroge les files d’attente de run indiquées et lance des runs pour wandb launch.

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

| Arguments | Description |
| :- | :- |
| `api` | Objet Api à utiliser pour envoyer des requêtes au backend. |
| `config` | Dictionnaire de configuration de l’agent. |

| Attributs | Description |
| :- | :- |
| `num_running_jobs` | Renvoie le nombre de jobs, hors schedulers. |
| `num_running_schedulers` | Renvoie uniquement le nombre de schedulers. |
| `thread_ids` | Renvoie une liste de clés correspondant aux ID des threads en cours d’exécution de l’agent. |

<h2 id="methods">
  Méthodes
</h2>

<h3 id="check_sweep_state">
  `check_sweep_state`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L786-L803)

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

Vérifie l’état d’un sweep avant de lancer un run de ce sweep.

<h3 id="fail_run_queue_item">
  `fail_run_queue_item`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L295-L304)

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

<h3 id="finish_thread_id">
  `finish_thread_id`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L416-L509)

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

Retire temporairement le job de notre liste.

<h3 id="get_job_and_queue">
  `get_job_and_queue`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L908-L915)

```python theme={"system"}
get_job_and_queue()
```

<h3 id="initialized">
  `initialized`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L190-L193)

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

Renvoie une valeur indiquant si l’agent est initialisé.

<h3 id="loop">
  `loop`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L572-L653)

```python theme={"system"}
loop()
```

Boucle indéfiniment pour interroger les files d’attente à la recherche de jobs, puis les exécuter.

| Exceptions levées | Description |
| :- | :- |
| `KeyboardInterrupt` | si l’arrêt de l’agent est demandé. |

<h3 id="name">
  `name`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L180-L188)

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

Renvoie le nom de l’agent.

<h3 id="pop_from_queue">
  `pop_from_queue`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L340-L363)

```python theme={"system"}
pop_from_queue(
    queue
)
```

Retire un élément de la file d'attente de runs pour l'exécuter en tant que job.

| Arguments | Description |
| :- | :- |
| `queue` | File d'attente dont retirer l'élément. |

| Renvoie | Description |
| :- | :- |
| Élément retiré de la file d'attente. | |

| Exceptions levées | Description |
| :- | :- |
| `Exception` | si une erreur survient lors du retrait d'un élément de la file d'attente. |

<h3 id="print_status">
  `print_status`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L365-L381)

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

Affiche le statut actuel de l’agent.

<h3 id="run_job">
  `run_job`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L511-L541)

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

Configure le projet et exécute le job.

| Arguments | Description |
| :- | :- |
| `job` | Job à exécuter. |

<h3 id="task_run_job">
  `task_run_job`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L656-L688)

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

<h3 id="update_status">
  `update_status`
</h3>

[Voir la source](https://www.github.com/wandb/wandb/tree/v0.20.1/wandb/sdk/launch/agent/agent.py#L383-L394)

```python theme={"system"}
update_status(
    status
)
```

Met à jour le statut de l’agent.

| Arguments | Description |
| :- | :- |
| `status` | Nouveau statut à attribuer à l’agent. |


## Related topics

- [Configurer Launch](/fr/products/wandb/platform/launch/set-up-launch.md)
