This PR tries to make templates (i.e. what is rendered as code) completely independent from the core app (i.e. the website, buttons, logic behind the rendering). This will enable contributors to more easily create templates for new tasks/frameworks, without having to understand or modify the app itself.
Details
Each template is now one directory under ./templates with 3 files:
code-template.py.jinja: The template for the code that will be rendered (as before, as a jinja template)
sidebar.py: Needs to contain a method show(), which renders all template-specific streamlit components into the sidebar
test-inputs.yml: A yml file that defines some input values for the code template (used by pytest to check that the template runs w/o errors)
Existing templates in ./templates are automatically detected by the app. Contributing a new template does not require a single change in ./app nor in any other template. Also, pytest will automatically pick up the new template and its test-inputs.yml file and make sure that the template renders and runs without errors (i.e. the user doesn't have to add any specific code for testing).
This PR also changes the ordering of components in the sidebar slightly and fixes a few minor bugs in the code templates that I found during refactoring.
Summary (2-3 sentences)
This PR tries to make templates (i.e. what is rendered as code) completely independent from the core app (i.e. the website, buttons, logic behind the rendering). This will enable contributors to more easily create templates for new tasks/frameworks, without having to understand or modify the app itself.
Details
Each template is now one directory under
./templates
with 3 files:code-template.py.jinja
: The template for the code that will be rendered (as before, as a jinja template)sidebar.py
: Needs to contain a methodshow()
, which renders all template-specific streamlit components into the sidebartest-inputs.yml
: A yml file that defines some input values for the code template (used by pytest to check that the template runs w/o errors)Existing templates in
./templates
are automatically detected by the app. Contributing a new template does not require a single change in./app
nor in any other template. Also, pytest will automatically pick up the new template and itstest-inputs.yml
file and make sure that the template renders and runs without errors (i.e. the user doesn't have to add any specific code for testing).This PR also changes the ordering of components in the sidebar slightly and fixes a few minor bugs in the code templates that I found during refactoring.