Custom recipe with custom html

Hi there,

I am trying to show a dynamic html page. When opening the web app on a browser, I am getting the following message:

✘ Invalid task format for view ID 'html'
html field required
{'Unnamed: 0': 49373, 'title': 'My Song', 'name': 'John', 'match': -1, '_input_hash': 1434188556, '_task_hash': 836244794, '_session_id': None, '_view_id': 'html'}

Any idea? Here is my recipe.py file:

import prodigy
from prodigy.components.loaders import JSONL
import pandas as pd

@prodigy.recipe('custom-recipe')
def custom_recipe(dataset, source):
        
    def stream():
        df = pd.read_csv(source, sep='\t')
        for index, row in df.iterrows():
            yield dict(row)


    def html_template():
        return '''<table border="1">
          <tr>
            <th>Info</th>            
          </tr>
          <tr>
            <td>{{ title }}</td>            
          </tr>
          <tr>
            <td>{{ name }}</td>            
          </tr></table>'''

    return {
        'view_id': 'html',
        'dataset': dataset, 
        'stream': stream(),
        'config': {
            'html_template': html_template(),
            'custom_theme':{'cardMaxWidth': 1675}
        }
    }

Ahh, looks like this is another case of our new data validation being too strict :woman_facepalming: Sorry about that.

The format is correct and if you have a "html_template", you shouldn't need a "html" value in your task. You can set "validate": False in the "config" returned by your recipe, or just add an empty string for "html" as a workaround for now. Already fixed this for the next release!

Edit: Just released v1.9.2, which should fix the underlying problem :slightly_smiling_face:

Hi Ines,

Thanks for the quick response. It worked like a charm!

1 Like