specify 'html_template' in recipe ?

Hi,

If I’m right, one can set the html_template either in the prodigy.json file or directly in each task using the field html. It could be nice to simply specify it in the recipe parameter, so that one can have several recipes file with different html template.

@recipe(...)
def my_recipe(...)
    ...
    return {
         ...,
         "html_template": my_template 
    }

Yes, your code is almost correct – the html_template needs to be part of a dictionary config, which can take the same parameters as the prodigy.json. So for example:

return {
    'config': {
        'html_template': '<strong>{text}</strong>'
    }
}

The config specified in a recipe has the highest priority, followed by a prodigy.json in your current working directory, followed by the global prodigy.json. This lets you overwrite the more general config settings with recipe-specific settings.

Edit: Okay, I got confused here. The local config overwrites the global config, and the combined result overwrites the recipe config. See my comment below for more details.

Ah great thanks !

This is good to know. Though I tested this and it seems like the local prodigy.json takes precedence over the return config. The following worked when I removed "port": 8080 from the local prodigy.json.

return {
    'config': {
        'port': 8081,
    }
}

Version 0.4.0

Ah, damn, you’re correct. Sorry. The local config overwrites the global config, and the combined result overwrites the recipe config.

I actually remember now that I was going back and forth on this and I think we ended up deciding on this solution, because otherwise, the user wouldn’t easily be able to overwrite the config defined in built-in recipes. Even custom recipes are supposed to be reusable across projects, so letting their config have the final word seems counterproductive. Instead, the local config file can add project-specific settings.

I think this makes sense, right?

1 Like

Cool, thanks.

A post was merged into an existing topic: Custom HTML