# tracker

Python API: `luxonis_train.utils.tracker`

The experiment tracker for PyTorch Lightning, over TensorBoard, Weights and Biases, and MLFlow.

## Classes

### LuxonisTrackerPL

Lightning logger built on `luxonis_ml.tracker.LuxonisTracker`.

The class adds the `Logger` interface of Lightning to the tracker of `luxonis_ml`. A `Trainer` can then log to TensorBoard,
Weights and Biases, and MLFlow through it.
[LuxonisModel](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/core/core.md)
creates one tracker for each run.

#### Methods

##### init

```python
def __init__(*, _auto_finalize: bool = True, **kwargs):
```

Initialize the tracker and the Lightning logger.

Parameters

 * `_auto_finalize` (`bool`): Whether the `Trainer` closes the run. With `True`, the instance replaces `finalize` with
   `_finalize`. The `Trainer` calls `finalize("success")` at the end of each `fit`, `validate`, `test`, or `predict` call. It
   calls `finalize("failed")` on an exception. With `False`, `finalize` of Lightning stays, and the caller must call `_finalize`.
   [LuxonisModel.finalize_run](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/core/core.md)
   does this.
 * `**kwargs`: Keyword arguments for `luxonis_ml.tracker.LuxonisTracker`, such as `project_name`, `run_name`, `save_directory`,
   and `is_mlflow`.

#### Attributes

##### finalize

## Functions

### get_tracker_init_params

```python
def get_tracker_init_params(cfg_tracker: Any) -> dict[str, Any]:
```

Build the keyword arguments of the tracker from its config.

`model_dump` of
[TrackerConfig](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/config/config.md)
leaves out `save_directory`, so the function adds it back.

> **Example**
> ```pycon
>>> from luxonis_train.config.config import TrackerConfig
>>> from luxonis_train.utils import get_tracker_init_params
>>> config = TrackerConfig(run_name="baseline")
>>> "save_directory" in config.model_dump()
False
>>> params = get_tracker_init_params(config)
>>> params["run_name"], str(params["save_directory"])
('baseline', 'output')
```

Parameters

 * `cfg_tracker` (`Any`): The tracker config, a [TrackerConfig](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/config/config.md). The function calls its `model_dump` and reads its `save_directory`.

Returns

 * `dict[str, Any]`: The fields of `cfg_tracker`, with `save_directory`. [LuxonisModel](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/core/core.md) passes them to [LuxonisTrackerPL](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/utils/tracker.md).
