## Launch document preprocessing

`datasets.launch_preprocessing(strdataset_id, DatasetLaunchPreprocessingParams**kwargs)  -> DatasetLaunchPreprocessingResponse`

**post** `/api/v1/datasets/{dataset_id}/launch-preprocessing`

Extracts the text, tables and figures of an uploaded document dataset (pdf, docx, pptx, xlsx, html, or a zip of them) into rows. After the upload completes, such a dataset reports `awaiting_input` until this is called. Reserves credits from the page count of the selected documents — quote them first with GET /datasets/{dataset_id}/preprocessing-credits — then starts extraction. Poll GET /datasets/{dataset_id}/status: it reports `pending` while extracting and `awaiting_input` once the rows are ready, at which point call POST /datasets/{dataset_id}/adapt.

### Parameters

- `dataset_id: str`

- `pages_to_process: Optional[float]`

  Maximum number of pages to process. Documents are included until this budget is reached. If omitted, all pages are processed.

- `documents_to_process: Optional[float]`

  Maximum number of documents to process. If omitted, all documents are processed.

- `preprocessing_mode: Optional[Literal["per_document", "per_page"]]`

  How extracted content becomes rows: `per_document` (default) makes one row per document, `per_page` one row per page. Omit to keep the mode already set on the dataset.

  - `"per_document"`

  - `"per_page"`

### Returns

- `class DatasetLaunchPreprocessingResponse: …`

  - `dataset_id: str`

    ID of the dataset

  - `status: str`

    Dataset status after the launch. Poll GET /datasets/{dataset_id}/status until it reports `awaiting_input`, then call POST /datasets/{dataset_id}/adapt.

  - `credits_escrowed: Optional[float]`

    Credits reserved for extracting the selected documents

  - `pages_to_process: Optional[float]`

    Total pages across the documents selected for extraction

  - `documents_selected: Optional[float]`

    Number of documents selected for extraction

  - `documents_total: Optional[float]`

    Number of documents in the dataset

### Example

```python
import os
from adaption import Adaption

client = Adaption(
    api_key=os.environ.get("ADAPTION_API_KEY"),  # This is the default and can be omitted
)
response = client.datasets.launch_preprocessing(
    dataset_id="dataset_id",
)
print(response.dataset_id)
```

#### Response

```json
{
  "dataset_id": "dataset_id",
  "status": "pending",
  "credits_escrowed": 0,
  "pages_to_process": 0,
  "documents_selected": 0,
  "documents_total": 0
}
```
