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

# Custom Neptune Callbacks

> systematica.portfolio.trackers.custom_neptune_callbacks

## `CustomCallback`

```python theme={null}
CustomCallback(
    run: neptune.metadata_containers.run.Run,
    **kwargs,
)
```

Custom Neptune callback for Optuna trials.

Initialize the Neptune custom callback.

**Parameters**:

| Name     | Type          | Default | Description                                          |
| -------- | ------------- | ------- | ---------------------------------------------------- |
| `run`    | `neptune.Run` | `--`    | Neptune run instance for logging.                    |
| `kwargs` | `tp.Kwargs`   | `--`    | Additional keyword arguments passed to parent class. |

### Ancestors

* `systematica.portfolio.trackers.base.BaseCustomNeptuneCallback`
* `abc.ABC`
* `systematica.portfolio.trackers.custom_neptune_ai.NeptuneCallback`

### Descendants

* `systematica.portfolio.trackers.custom_neptune_callbacks.CSVCallback`
* `systematica.portfolio.trackers.custom_neptune_callbacks.ChunkedJSONCallback`
* `systematica.portfolio.trackers.custom_neptune_callbacks.ChunkedParquetCallback`
* `systematica.portfolio.trackers.custom_neptune_callbacks.JSONCallback`
* `systematica.portfolio.trackers.custom_neptune_callbacks.ParquetCallback`

### Methods

#### `custom_upload`

```python theme={null}
custom_upload(
    self,
    study: optuna.study.study.Study,
    trial: optuna.trial._frozen.FrozenTrial,
)
```

Upload file placeholder.

**Parameters**:

| Name    | Type                       | Default | Description                 |
| ------- | -------------------------- | ------- | --------------------------- |
| `study` | `optuna.Study`             | `--`    | The Optuna study object.    |
| `trial` | `optuna.trial.FrozenTrial` | `--`    | The completed Optuna trial. |

## `JSONCallback`

```python theme={null}
JSONCallback(
    run: neptune.metadata_containers.run.Run,
    **kwargs,
)
```

Enhanced Neptune callback with efficient live logging and full trial
compression as JSON json.gz extension.

Logs both parameters and values in real-time while storing complete trial
data for compressed post-run upload.

Initialize the Neptune custom callback.

**Parameters**:

| Name     | Type          | Default | Description                                          |
| -------- | ------------- | ------- | ---------------------------------------------------- |
| `run`    | `neptune.Run` | `--`    | Neptune run instance for logging.                    |
| `kwargs` | `tp.Kwargs`   | `--`    | Additional keyword arguments passed to parent class. |

### Ancestors

* `systematica.portfolio.trackers.custom_neptune_callbacks.CustomCallback`
* `systematica.portfolio.trackers.base.BaseCustomNeptuneCallback`
* `abc.ABC`
* `systematica.portfolio.trackers.custom_neptune_ai.NeptuneCallback`

### Methods

#### `custom_upload`

```python theme={null}
custom_upload(
    self,
    study: optuna.study.study.Study,
    trial: optuna.trial._frozen.FrozenTrial,
)
```

Compress and upload trial data as json file.

**Parameters**:

| Name    | Type                       | Default | Description                 |
| ------- | -------------------------- | ------- | --------------------------- |
| `study` | `optuna.Study`             | `--`    | The Optuna study object.    |
| `trial` | `optuna.trial.FrozenTrial` | `--`    | The completed Optuna trial. |

**Raises**:

| Type        | Description                                                         |
| ----------- | ------------------------------------------------------------------- |
| `Exception` | If the upload fails, an error is logged with the exception details. |

## `ChunkedJSONCallback`

```python theme={null}
ChunkedJSONCallback(
    run: neptune.metadata_containers.run.Run,
    **kwargs,
)
```

Enhanced Neptune callback that logs trial data in real-time and uploads
full trial data in compressed JSON chunks at experiment end.

Splits the compressed data into chunks of specified size (e.g., 5 MB)
to handle large datasets efficiently.

Initialize the Neptune custom callback.

**Parameters**:

| Name     | Type          | Default | Description                                          |
| -------- | ------------- | ------- | ---------------------------------------------------- |
| `run`    | `neptune.Run` | `--`    | Neptune run instance for logging.                    |
| `kwargs` | `tp.Kwargs`   | `--`    | Additional keyword arguments passed to parent class. |

### Ancestors

* `systematica.portfolio.trackers.custom_neptune_callbacks.CustomCallback`
* `systematica.portfolio.trackers.base.BaseCustomNeptuneCallback`
* `abc.ABC`
* `systematica.portfolio.trackers.custom_neptune_ai.NeptuneCallback`

### Methods

#### `custom_upload`

```python theme={null}
custom_upload(
    self,
    study: optuna.study.study.Study,
    trial: optuna.trial._frozen.FrozenTrial,
)
```

Compress and upload trial data in chunks as json file.

**Parameters**:

| Name    | Type                       | Default | Description                 |
| ------- | -------------------------- | ------- | --------------------------- |
| `study` | `optuna.Study`             | `--`    | The Optuna study object.    |
| `trial` | `optuna.trial.FrozenTrial` | `--`    | The completed Optuna trial. |

**Raises**:

| Type        | Description                                                         |
| ----------- | ------------------------------------------------------------------- |
| `Exception` | If the upload fails, an error is logged with the exception details. |

## `ParquetCallback`

```python theme={null}
ParquetCallback(
    run: neptune.metadata_containers.run.Run,
    **kwargs,
)
```

Enhanced Neptune callback that logs trial data in real-time and uploads
full trial data as a compressed Parquet file at experiment end.

Splits the compressed data into chunks of specified size (e.g., 5 MB)
to handle large datasets efficiently.

Initialize the Neptune custom callback.

**Parameters**:

| Name     | Type          | Default | Description                                          |
| -------- | ------------- | ------- | ---------------------------------------------------- |
| `run`    | `neptune.Run` | `--`    | Neptune run instance for logging.                    |
| `kwargs` | `tp.Kwargs`   | `--`    | Additional keyword arguments passed to parent class. |

### Ancestors

* `systematica.portfolio.trackers.custom_neptune_callbacks.CustomCallback`
* `systematica.portfolio.trackers.base.BaseCustomNeptuneCallback`
* `abc.ABC`
* `systematica.portfolio.trackers.custom_neptune_ai.NeptuneCallback`

### Methods

#### `custom_upload`

```python theme={null}
custom_upload(
    self,
    study: optuna.study.study.Study,
    trial: optuna.trial._frozen.FrozenTrial,
)
```

Compress and upload trial data as parquet file.

**Parameters**:

| Name    | Type                       | Default | Description                 |
| ------- | -------------------------- | ------- | --------------------------- |
| `study` | `optuna.Study`             | `--`    | The Optuna study object.    |
| `trial` | `optuna.trial.FrozenTrial` | `--`    | The completed Optuna trial. |

**Raises**:

| Type        | Description                                                         |
| ----------- | ------------------------------------------------------------------- |
| `Exception` | If the upload fails, an error is logged with the exception details. |

## `ChunkedParquetCallback`

```python theme={null}
ChunkedParquetCallback(
    run: neptune.metadata_containers.run.Run,
    **kwargs,
)
```

Enhanced Neptune callback that logs trial data in real-time and uploads
full trial data as a compressed Parquet chunks at experiment end.

Uses Parquet format for efficient storage and handling of large datasets.

Initialize the Neptune custom callback.

**Parameters**:

| Name     | Type          | Default | Description                                          |
| -------- | ------------- | ------- | ---------------------------------------------------- |
| `run`    | `neptune.Run` | `--`    | Neptune run instance for logging.                    |
| `kwargs` | `tp.Kwargs`   | `--`    | Additional keyword arguments passed to parent class. |

### Ancestors

* `systematica.portfolio.trackers.custom_neptune_callbacks.CustomCallback`
* `systematica.portfolio.trackers.base.BaseCustomNeptuneCallback`
* `abc.ABC`
* `systematica.portfolio.trackers.custom_neptune_ai.NeptuneCallback`

### Methods

#### `custom_upload`

```python theme={null}
custom_upload(
    self,
    study: optuna.study.study.Study,
    trial: optuna.trial._frozen.FrozenTrial,
)
```

Compress and upload trial data in chunks as parquet file.

**Parameters**:

| Name    | Type                       | Default | Description                 |
| ------- | -------------------------- | ------- | --------------------------- |
| `study` | `optuna.Study`             | `--`    | The Optuna study object.    |
| `trial` | `optuna.trial.FrozenTrial` | `--`    | The completed Optuna trial. |

**Raises**:

| Type        | Description                                                         |
| ----------- | ------------------------------------------------------------------- |
| `Exception` | If the upload fails, an error is logged with the exception details. |

## `CSVCallback`

```python theme={null}
CSVCallback(
    run: neptune.metadata_containers.run.Run,
    **kwargs,
)
```

Enhanced Neptune callback with efficient live logging and full trial
data upload as CSV.

Logs both parameters and values in real-time while storing complete trial
data for post-run upload as a CSV file.

Initialize the Neptune custom callback.

**Parameters**:

| Name     | Type          | Default | Description                                          |
| -------- | ------------- | ------- | ---------------------------------------------------- |
| `run`    | `neptune.Run` | `--`    | Neptune run instance for logging.                    |
| `kwargs` | `tp.Kwargs`   | `--`    | Additional keyword arguments passed to parent class. |

### Ancestors

* `systematica.portfolio.trackers.custom_neptune_callbacks.CustomCallback`
* `systematica.portfolio.trackers.base.BaseCustomNeptuneCallback`
* `abc.ABC`
* `systematica.portfolio.trackers.custom_neptune_ai.NeptuneCallback`

### Static methods

#### `combine_trials`

```python theme={null}
combine_trials(
    trials: dict,
) ‑> pandas.core.frame.DataFrame
```

Combine trials into a pandas DataFrame.

**Parameters**:

| Name     | Type        | Default | Description                       |
| -------- | ----------- | ------- | --------------------------------- |
| `trials` | `tp.Kwargs` | `--`    | Dictionary containing trial data. |

**Returns**:

| Type           | Description                               |
| -------------- | ----------------------------------------- |
| `pd.DataFrame` | DataFrame containing combined trial data. |

### Methods

#### `custom_upload`

```python theme={null}
custom_upload(
    self,
    study: optuna.study.study.Study,
    trial: optuna.trial._frozen.FrozenTrial,
)
```

Upload trial data as CSV file.

**Parameters**:

| Name    | Type                       | Default | Description                 |
| ------- | -------------------------- | ------- | --------------------------- |
| `study` | `optuna.Study`             | `--`    | The Optuna study object.    |
| `trial` | `optuna.trial.FrozenTrial` | `--`    | The completed Optuna trial. |

**Raises**:

| Type        | Description                                                         |
| ----------- | ------------------------------------------------------------------- |
| `Exception` | If the upload fails, an error is logged with the exception details. |
