# Review recipe error: dataset field required

**URL:** <https://support.prodi.gy/t/review-recipe-error-dataset-field-required/6729>\
**Category:** Uncategorized\
**Tags:** usage, ner\
**Created:** [August 9, 2023, 4:31pm UTC](https://support.prodi.gy/t/review-recipe-error-dataset-field-required/6729 "2023-08-09T16:31:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheyanneb](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/cheyanneb/32/2409_2.png) [@cheyanneb](https://support.prodi.gy/u/cheyanneb)\
**Post date:** [August 9, 2023, 4:31pm UTC](https://support.prodi.gy/t/review-recipe-error-dataset-field-required/6729/1 "2023-08-09T16:31:10Z")

</div>

Hi,

I'm trying to run a custom `review.py` recipe with a notes text field, and I'm getting this error:

Command:

```python
PRODIGY_ALLOWED_SESSIONS=cheyanne prodigy review dataset_review_test_v1 ner_task_v1_c-katrina,ner_task_v1_c-linnea -F /Users/cheyannebaird/posh/annotation-service/src/annotator/recipes/review.py --label ACCOUNT,ACTIVITY,AMOUNT,BANK,CARDINAL,DATE,FAC,FREQUENCY,GPE,LANGUAGE,ORDINAL,ORG,PERCENT,PERSON,STT_ERROR,TIME,VEHICLE

```

Error:

```python
✘ Invalid components returned by recipe 'review'
dataset field required

{'stream': <prodigy.components.stream.Stream object at 0x1302fea00>, 'view_id': 'blocks', 'config': {'blocks': [{'view_id': 'spans_manual'}, {'view_id': 'text_input', 'field_label': 'Notes'}], 'labels': ['ACCOUNT', 'ACTIVITY', 'AMOUNT', 'BANK', 'CARDINAL', 'DATE', 'FAC', 'FREQUENCY', 'GPE', 'LANGUAGE', 'ORDINAL', 'ORG', 'PERCENT', 'PERSON', 'STT_ERROR', 'TIME', 'VEHICLE'], 'exclude_by': 'input', 'ner_manual_highlight_chars': False, 'auto_count_stream': True}}

```

The only changes I made to the built-in `review.py` include this at the end of the recipe:

```python
   result = {}
    result.update(
        stream=stream,
        view_id="blocks",
        config={
            "blocks": [
                {"view_id": "spans_manual"},
                {"view_id": "text_input", "field_label": "Notes"}
            ],
            "labels": label,
# "dataset": dataset,
            "exclude_by": "input",
            "ner_manual_highlight_chars": False,
            "auto_count_stream": True
        }
    )

    return result

```

And imports at the top:

```python
import copy
from collections import defaultdict
from typing import Any, Dict, Iterator, List, Optional, Tuple

import json
import prodigy
from typing import Dict, Generator, Iterable, List, Optional, Union

import spacy
from prodigy.components.loaders import get_stream
from prodigy.components.loaders import JSONL
from prodigy.components.preprocess import add_tokens
from prodigy.core import recipe
from prodigy.recipes.spans import manual as prodigy_spans_manual
#from prodigy.types import RecipeSettingsType
#from prodigy.util import get_labels

from prodigy.components.db import Database, connect
from prodigy.components.decorators import support_both_streams
from prodigy.components.preprocess import fetch_media as fetch_media_preprocessor
from prodigy.components.stream import get_stream
from prodigy.core import recipe
from prodigy.types import RecipeSettingsType, StreamType, TaskType
from prodigy.util import (
    IGNORE_HASH_KEYS,
    INPUT_HASH_ATTR,
    SESSION_ID_ATTR,
    TASK_HASH_ATTR,
    VIEW_ID_ATTR,
    get_labels,
    log,
    msg,
    set_hashes,
    split_string,
)

```

I've provided the dataset in the command, so any idea why it's asking me for a dataset?

When I run this command just use the built-in as is, I get what I am looking for: two datasets annotated with spans to review (no errors):

```python
PRODIGY_ALLOWED_SESSIONS=cheyanne prodigy review review_ner_validation_test_v1_c ner_task_v1_c-katrina,ner_task_v1_c-linnea --label ACCOUNT,ACTIVITY,AMOUNT,BANK,CARDINAL,DATE,FAC,FREQUENCY,GPE,LANGUAGE,ORDINAL,ORG,PERCENT,PERSON,STT_ERROR,TIME,VEHICLE --view-id spans_manual

```

Result:

 ![Screen Shot 2023-08-09 at 12.33.07 PM](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/1/11e2a5be8ca3a9081a13f5ddfdc75fe7560c2d59.jpeg)

Thanks,  
Cheyanne

---

<div class="post-metadata">

**Author:** ![koaning](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/koaning/32/230_2.png) [@koaning](https://support.prodi.gy/u/koaning)\
**Post date:** [August 10, 2023, 8:05am UTC](https://support.prodi.gy/t/review-recipe-error-dataset-field-required/6729/2 "2023-08-10T08:05:31Z")

</div>

> [@cheyanneb](#):
>
> ```python
> result = {}
> result.update(
> stream=stream,
> view_id="blocks",
> config={
> "blocks": [
> {"view_id": "spans_manual"},
> {"view_id": "text_input", "field_label": "Notes"}
> ],
> "labels": label,
> # "dataset": dataset,
> "exclude_by": "input",
> "ner_manual_highlight_chars": False,
> "auto_count_stream": True
> }
> )
> 
> return result
> 
> ```

When I look at the code it seems like the dataset is commented out, but it also seems like it's under the `config` key. I think it should be at the top level. Maybe something like this:

```python
    result = {}
    result.update(
        stream=stream,
        view_id="blocks",
        dataset=dataset,
        config={
            "blocks": [
                {"view_id": "spans_manual"},
                {"view_id": "text_input", "field_label": "Notes"}
            ],
            "labels": label,
            "exclude_by": "input",
            "ner_manual_highlight_chars": False,
            "auto_count_stream": True
        }
    )

    return result

```

Does this help?

---

<div class="post-metadata">

**Author:** ![cheyanneb](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/cheyanneb/32/2409_2.png) [@cheyanneb](https://support.prodi.gy/u/cheyanneb)\
**Post date:** [August 10, 2023, 12:08pm UTC](https://support.prodi.gy/t/review-recipe-error-dataset-field-required/6729/3 "2023-08-10T12:08:08Z")

</div>

With the revised code above, I get the following results:

Command without `--view-id spans_manual` flag because I'm trying to handle it in the recipe:

```python
PRODIGY_ALLOWED_SESSIONS=cheyanne prodigy review dataset_review_test_v1 ner_task_v1_c-katrina,ner_task_v1_c-linnea -F /Users/cheyannebaird/posh/annotation-service/src/annotator/recipes/review_spans.py --label ACCOUNT,ACTIVITY,AMOUNT,BANK,CARDINAL,DATE,FAC,FREQUENCY,GPE,LANGUAGE,ORDINAL,ORG,PERCENT,PERSON,STT_ERROR,TIME,VEHICLE

```

 ![Screen Shot 2023-08-10 at 8.04.58 AM](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/d/d9eb09da18221675bd5aaed610fbc424a6df8552.png)

This shows "no blocks available", and my text input field is not present.

With this command with the `--view-id spans_manual` flag:

```python
PRODIGY_ALLOWED_SESSIONS=cheyanne prodigy review dataset_review_test_v1 ner_task_v1_c-katrina,ner_task_v1_c-linnea -F /Users/cheyannebaird/posh/annotation-service/src/annotator/recipes/review_spans.py --label ACCOUNT,ACTIVITY,AMOUNT,BANK,CARDINAL,DATE,FAC,FREQUENCY,GPE,LANGUAGE,ORDINAL,ORG,PERCENT,PERSON,STT_ERROR,TIME,VEHICLE --view-id spans_manual

```

 ![Screen Shot 2023-08-10 at 8.07.12 AM](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/0/03ce52816bde2eeab68f4e3c51a9c948b1abd59e.jpeg)

Here, I get what I am looking for, except the text input field is still not present, so I think this final block of code is not recognizing the "blocks" `view-id`.

---

<div class="post-metadata">

**Author:** ![koaning](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/koaning/32/230_2.png) [@koaning](https://support.prodi.gy/u/koaning)\
**Post date:** [August 10, 2023, 3:00pm UTC](https://support.prodi.gy/t/review-recipe-error-dataset-field-required/6729/4 "2023-08-10T15:00:06Z")

</div>

I figured I might have a proper go at this. So I start by annotating this dataset:

```python
{"text": "Vincent, a great name."}
{"text": "Kevin, also a great name."}

```

I use this recipe call:

```python
PRODIGY_ALLOWED_SESSIONS="vincent,foobar" PRODIGY_CONFIG_OVERRIDES='{"feed_overlap": true}' python -m prodigy spans.manual spans-annot blank:en examples.jsonl --label NAME

```

And that gives me this interface.

 ![CleanShot 2023-08-10 at 16.53.17](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/e/ecba90e72b9096fa69a5e35f17658d36974b6b9d.png)

I have annotations that disagree, so I'll confirm by using the normal review recipe.

```python
python -m prodigy review reviewed-spans spans-annot --view-id spans_manual

```

 ![CleanShot 2023-08-10 at 16.55.56](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/7/77ce8cc21456d97580c05d86e28962d6d87fe231.png)

Sofar, so good. But let's now try to customise this a bit with a text field. To do that, I only change the output dictionary.

## Before

```python
    return {
        "view_id": "review",
        "dataset": dataset,
        "stream": stream,
        "before_db": before_db,
        "config": config,
    }

```

## After

```python
    return {
        "view_id": "blocks",
        "dataset": dataset,
        "stream": stream,
        "before_db": before_db,
        "config": {
            **config,
            "blocks": [
                {"view_id": "review"},
                {"view_id": "text_input", "field_label": "Notes"}
            ],
        }
    }

```

When I now run this recipe ...

```python
python -m prodigy review.custom reviewed-spans spans-annot --view-id spans_manual -F myreview.py --label NAME

```

... I see this:

 ![CleanShot 2023-08-10 at 16.58.28](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/0/001226fe36e453fe5d129df90b7f5b943f30abed.png)

I think the original issue was that the `view_id` should mention `"blocks"`, but the definition of the blocks themselves should go in the `config` key.

@cheyanneb let me know if this didn't work for you.
