# html\_template doesn't work

**URL:** <https://support.prodi.gy/t/html-template-doesnt-work/6559>\
**Category:** Uncategorized\
**Tags:** front-end, usage\
**Created:** [May 25, 2023, 2:43pm UTC](https://support.prodi.gy/t/html-template-doesnt-work/6559 "2023-05-25T14:43:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zparcheta](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/zparcheta/32/3789_2.png) [@zparcheta](https://support.prodi.gy/u/zparcheta)\
**Post date:** [May 25, 2023, 2:43pm UTC](https://support.prodi.gy/t/html-template-doesnt-work/6559/1 "2023-05-25T14:43:54Z")

</div>

Hi all,  
I am not able to apply custom HTML template to my recipe. It doesn't show anything apart from metadata.  
Please help

```python
from typing import List, Optional
import prodigy
from prodigy.components.loaders import JSONL
from prodigy.util import split_string

# Helper functions for adding user provided labels to annotation tasks.
def add_label_options_to_stream(stream, labels):
    options = [{"id": label, "text": label} for label in labels]
    for task in stream:
        task["options"] = options
        yield task

# Recipe decorator with argument annotations: (description, argument type,
# shortcut, type / converter function called on value before it's passed to
# the function). Descriptions are also shown when typing --help.
@prodigy.recipe(
    "memt.manual",
    dataset=("The dataset to use", "positional", None, str),
    source=("The source data as a JSONL file", "positional", None, str),
    label=("One or more comma-separated labels", "option", "l", split_string),
    exclusive=("Treat classes as mutually exclusive", "flag", "E", bool),
    exclude=("Names of datasets to exclude", "option", "e", split_string),
)
def memt_manual(
    dataset: str,
    source: str,
    label: Optional[List[str]] = None,
    exclusive: bool = False,
    exclude: Optional[List[str]] = None,
):
    """
    Manually annotate categories that apply to a text. If more than one label
    is specified, categories are added as multiple choice options. If the
    --exclusive flag is set, categories become mutually exclusive, meaning that
    only one can be selected during annotation.
    """

    # Load the stream from a JSONL file and return a generator that yields a
    # dictionary for each example in the data.
    stream = JSONL(source)

    #Add labels to each task in stream
    stream = add_label_options_to_stream(stream, label)

    return {
        "view_id": "html", # Annotation interface to use
        "dataset": dataset, # Name of dataset to save annotations
        "stream": stream, # Incoming stream of examples
        "config": { # Additional config settings, mostly for app UI
            "exclude_by": "task", # Hash value used to filter out already seen examples
            "choice_style": "single",
            "force_stream_order": True,
            "validate": False,
            "batch_size": 10,
            "html_template": "<h2>{{ text }}</h2><strong>{{ meta.source }}</strong>"
        },
    }

```

data.jsonl:  
`{"text": "target 1, s1", "meta": {"source": "source 1"}}`

`prodigy memt.manual eval_user data.jsonl --label FPE+LPE,"LPE only",None -F memt_recipe.py`

What I get:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/7/7e327ec231757b9c8fc250c00d50c4f08824c5cf.png)

---

<div class="post-metadata">

**Author:** ![ryanwesslen](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ryanwesslen/32/2969_2.png) [@ryanwesslen](https://support.prodi.gy/u/ryanwesslen)\
**Post date:** [May 25, 2023, 4:42pm UTC](https://support.prodi.gy/t/html-template-doesnt-work/6559/2 "2023-05-25T16:42:10Z")

</div>

hi @zparcheta!

Thanks for your question (and your extremely helpful reproducible example! 🙏)

That's interesting.

I was able to run it fine 🤔

```python
python -m prodigy memt.manual eval_user data/data.jsonl --label FPE+LPE,"LPE only",None -F scripts/memt_recipe.py

```

 ![localhost_8080_ (27)](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/6/63981a99a80e48c041f396f93801b136e8fce569.png)

Can you right click your browser (if you're using Chrome), select "Inspect", then go to the Console tab to look for any [errors](https://support.awesome-table.com/hc/en-us/articles/115003787169-Using-the-Debug-Console-in-Google-Chrome-to-identify-errors)?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/5/5af16d7ab9bb2ea230fee90a9dc0b850b9daec08.png)

By the way, unrelated to `html_template`, I'd recommend you replace `stream = JSONL(source)` with `stream = get_stream( source, rehash=True, dedup=True, input_key="text" )` (you'll also need to replace the `JSONL` call with `from prodigy.components.loaders import get_stream` at the top too).

Our built-in recipes use `get_stream` (see the [docs](https://prodi.gy/docs/api-components#get_stream)) which provide the hashing/deduplication. Since you added `"exclude_by": "task"` (which is the default), you may be getting a console warning message because without it (or `set_hashes`, which `get_stream` uses), it can't do any of the dedup that you'd expect. We'll work on improving this as I suspect you saw this in our `prodigy-recipes` repo.

---

<div class="post-metadata">

**Author:** ![zparcheta](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/zparcheta/32/3789_2.png) [@zparcheta](https://support.prodi.gy/u/zparcheta)\
**Post date:** [May 25, 2023, 5:19pm UTC](https://support.prodi.gy/t/html-template-doesnt-work/6559/3 "2023-05-25T17:19:28Z")

</div>

Thank you for the hints. I will change it. I also confirm that in the console there are no errors. May it be some problem with prodigy.json?

````python
{
  "theme": "basic",
  "custom_theme": {},
  "buttons": ["undo"],
  "batch_size": 10,
  "history_size": 10,
  "port": 8880,
  "host": "xxxxxxxxx",
  "cors": true,
  "db": "postgresql",
  "db_settings": {
    "postgresql": {
      "dbname": "prodigy",
      "user": "prodigy",
      "password": "xxxxxxxxxxxx"
    }
  },
  "validate": true,
  "auto_exclude_current": false,
  "choice_auto_accept": true,
  "feed_overlap": false,
  "auto_exclude_current": false,
  "instant_submit": false,
  "feed_overlap": false,
  "auto_count_stream": false,
  "total_examples_target": 0,
  "ui_lang": "en",
  "project_info": ["dataset", "session", "lang", "recipe_name", "view_id", "label"],
  "show_stats": true,
  "hide_meta": false,
  "show_flag": false,
  "instructions": false,
  "swipe": false,
  "swipe_gestures": { "left": "accept", "right": "reject" },
  "split_sents_threshold": false,
  "html_template": false,
  "global_css": null,
  "javascript": null,
  "writing_dir": "ltr",
  "show_whitespace": false,
  "exclude_by": "task"
}```
````

---

<div class="post-metadata">

**Author:** ![zparcheta](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/zparcheta/32/3789_2.png) [@zparcheta](https://support.prodi.gy/u/zparcheta)\
**Post date:** [May 25, 2023, 5:22pm UTC](https://support.prodi.gy/t/html-template-doesnt-work/6559/4 "2023-05-25T17:22:48Z")

</div>

Ok, definitely it was a problem of the config 😅  
I just put all default parameters and it worked.  
Thank you for trying the code!

---

<div class="post-metadata">

**Author:** ![ryanwesslen](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ryanwesslen/32/2969_2.png) [@ryanwesslen](https://support.prodi.gy/u/ryanwesslen)\
**Post date:** [May 25, 2023, 5:32pm UTC](https://support.prodi.gy/t/html-template-doesnt-work/6559/5 "2023-05-25T17:32:38Z")

</div>

Excellent! By the way, I edited your earlier post to remove what may have been sensitive info in your config 🙂
