

# Monitor an ontology induction

After you start an induction, it runs in the background until it succeeds, fails, or you cancel it. This topic explains what happens during the run, how to check the status, and what to do if the induction fails.

## What happens while an induction runs
<a name="ontology-induce-track-run"></a>

While an induction runs, AWS Context does the following:
+ Reads the text of each document.
+ Drafts classes, attributes, and relationships from each document.
+ Combines the results from all the documents, and the template ontology if you gave one, into one draft.
+ Keeps the draft within size limits, and removes induced terms if it needs to. For more information, see [What an induced draft contains](ontology-draft-contents.md).
+ Checks the draft with the same checks that it runs on every ontology. For information about the checks, see [Fix validation issues](ontology-fix-validation-errors.md).
+ Saves the draft and creates the new ontology with the status `DRAFT`.

The status doesn’t show progress while the induction runs. An induction that doesn’t finish within 6 hours fails. On the AWS Context console, the message **Generation is taking longer than expected** appears after 30 minutes. For information about what to do, see [An induction takes a long time](ontology-induce-troubleshoot.md#ontology-induce-troubleshoot-slow).

If you induce an ontology again from the same documents, you can get a different draft.

## Induction statuses
<a name="ontology-induce-track-status"></a>

An induction has one of the following statuses.


| Status | Console label | What it means | 
| --- | --- | --- | 
|  `INDUCING`  |  **Inducing**  | The induction is running. The new ontology doesn’t exist yet. | 
|  `DRAFT`  |  **Draft**  | The induction succeeded and created a new ontology with the status `DRAFT`. | 
|  `FAILED`  |  **Failed**  | The induction stopped with an error. It didn’t create an ontology. | 
|  `CANCELLED`  |  **Cancelled**  | You canceled the induction. It didn’t create an ontology. | 

 `DRAFT`, `FAILED`, and `CANCELLED` are final. The induction stays `DRAFT` after you publish its ontology. The console then shows the ontology as **Published**. For information about how to publish, see [Publish a draft ontology](ontology-draft-publish.md).

## Check the status of an induction
<a name="ontology-induce-track-check"></a>

To check an induction on the console, open it from the **Ontologies** page. The induction’s page shows its status.

To check an induction with the API, call [`GetOntologyInduction`](https://docs.aws.amazon.com/context/latest/APIReference/API_GetOntologyInduction.html) with the induction’s ID or ARN. The response has the status. When the status is `DRAFT`, it also has the new ontology’s ID and ARN (`ontologyId` and `ontologyArn`). When the status is `FAILED`, it has a `failure` with a code and a message. For information about the codes, see [Failure codes](#ontology-induce-track-codes).

The following example shows the input for checking an induction with `GetOntologyInduction`.

```
GetOntologyInduction
  ontologyInductionId: <the ID or ARN that StartOntologyInduction returned>
```

To list the inductions in your account, call [`ListOntologyInductions`](https://docs.aws.amazon.com/context/latest/APIReference/API_ListOntologyInductions.html). The results come in pages. Keep calling with the `nextToken` from each response until a response has no `nextToken`. A page can have fewer results than you asked for, or none, even when more results follow.

## If an induction fails
<a name="ontology-induce-track-failed"></a>

A failed induction doesn’t create an ontology. On the console, the induction’s page shows **Generation failed** with a message that says what went wrong. The console shows the message but not the failure code. With the API, `GetOntologyInduction` returns both the code and the message.

To try again, start a new induction. For some failure codes, you first change the inputs that the table names, such as the documents or the template ontology. For others, you start a new induction with the same inputs. If you use the API, use a new client token. The following table lists each failure code and what to do.

## Failure codes
<a name="ontology-induce-track-codes"></a>

The following table lists the failure codes that an induction can return. In the codes, a *fragment* is the part of the draft that AWS Context drafts from one document.


| Code | Meaning | What to do | 
| --- | --- | --- | 
|  `INPUT_UNREADABLE`  |  AWS Context couldn’t find or read an uploaded document. | Start a new induction. If the message names a document, check that document first. | 
|  `TOO_MANY_DOCUMENTS`  | The request had more documents than one induction accepts. | Send fewer documents. For information about the limits, see [Input limits](ontology-induce-inputs.md#ontology-induce-inputs-limits). | 
|  `SEED_INVALID`  | The template ontology’s source no longer exists or is too large, or AWS Context can’t parse it. | Choose another template ontology, or start without one. For information about the rules for a template ontology, see [Choose a template ontology (optional)](ontology-induce-inputs.md#ontology-induce-inputs-seed). | 
|  `FRAGMENT_EMPTY`  |  AWS Context induced nothing from the documents, and there is no template ontology. | Check that the documents contain readable text. For information about the text that AWS Context reads, see [Choose documents](ontology-induce-inputs.md#ontology-induce-inputs-documents). | 
|  `DOCUMENT_FILTERED`  | The language model refused a document. | Remove or change that document. | 
|  `INDUCED_TOO_LARGE`  | The draft is too large to save, even after AWS Context removes induced terms to fit the size limits. This happens when the template ontology alone is larger than a draft can be, because AWS Context doesn’t remove terms of the template ontology. It also happens when the draft and its warnings together are too large to save with the induction. | Send fewer or shorter documents, or use the prompt to ask for a narrower ontology. If the template ontology alone is too large, use a smaller template ontology or none. For information about the size limits, see [Size limits and removed terms](ontology-draft-contents.md#ontology-draft-contents-limits). | 
|  `FRAGMENT_FAILED`  | Inducing from a document failed after retries. | If the message says to split a document, split it into smaller documents first. Then start a new induction. | 
|  `MERGE_FAILED`  | Combining the results from the documents failed after retries. | Start a new induction with the same inputs. | 
|  `DRAFT_WRITE_FAILED`  |  AWS Context couldn’t save the draft. | Start a new induction with the same inputs. If the ontology’s tags were refused, fix `ontologyTags` first. For information about the tag fields, see [`StartOntologyInduction` request fields](ontology-induce-start.md#ontology-induce-start-reference). | 
|  `TIMED_OUT`  | The induction didn’t finish within its time limit. | Start a new induction with the same inputs. | 
|  `RUN_STOPPED`  | The run stopped before it finished. | Start a new induction with the same inputs. | 

 AWS Context also runs the checks for an uploaded ontology on the draft. If the draft fails these checks, the induction fails with the code of the first error that the checks found, such as `NO_CLASSES` or `UNMAPPABLE_CLASS`. For information about these codes, see [Errors and warnings after an upload](ontology-byo-issues.md). The message says what the checks found. Start a new induction. You can change the documents or the prompt.