Template Library¶
What it is¶
Templates define the available test functions for a grading context (input/output, API, web development, etc.).
The TemplateLibraryService loads and caches template instances from a registry.
Why it matters¶
- Keeps grading logic reusable across assignments
- Prevents assignment configs from referencing unknown tests
- Decouples rubric configuration from concrete test implementation
Built-in template identifiers¶
Current registry keys:
input_outputapiwebdev
Each key resolves to a template class with:
template_nametemplate_descriptionrequires_sandboxtestsmap of availableTestFunctionobjects
How it integrates with the pipeline¶
- Load Template resolves the chosen template.
- Build Tree validates and binds test names from criteria config to concrete test functions.
- Grade executes bound tests with parameters from the criteria tree.
This means template validation is front-loaded, not deferred to scoring time.
Extending templates¶
To add a new template:
- Implement template and test functions under
autograder/template_library/. - Register it in
TemplateLibraryService._TEMPLATE_REGISTRY. - Add docs for available tests and parameters.
Current limitation¶
load_custom_template() exists but currently raises NotImplementedError. Built-in templates are the supported path today.
Common mistakes¶
- Reusing test names with different semantics across templates
- Skipping documentation for template parameters
- Assuming sandbox availability in templates that declare
requires_sandbox = False