feat(annotation): configurable per-field markdown rendering#231
Closed
henrycgbaker wants to merge 1 commit into
Closed
Conversation
Adds AnnotationSettings.field_render_mode (deployment / workspace / task scopes, sparse-dict overlay) that controls use_markdown on each rg.TextField. Mirrors the constraint_severity pattern with the per-task scope extended (since each field name belongs to specific tasks). Defaults to "plain" everywhere; users opt fields into "markdown" via YAML to let Argilla render pipeline-emitted HTML (e.g. publikationsbot output) in the annotator UI. Schema (which fields exist) stays hardcoded per ADR-0009; rendering is an operational layer above it (see ADR addendum). Also flips the collapsible_field.html widget to use innerHTML for record-supplied content so embedded HTML renders there too. Trust assumption: record content comes from a first-party pipeline. TEXT_FIELDS registry in core/schemas/annotation_task.py is the source of truth for which fields can be configured; a unit test asserts it matches the rg.TextField names actually constructed in build_task_settings.
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
AnnotationSettings.field_render_mode(deployment / workspace / task scopes, sparse-dict overlay) controllinguse_markdownon eachrg.TextField. Lets a deployment opt selected fields into Argilla's markdown renderer — which also handles inline raw HTML — so content from pipelines that emit HTML (e.g. publikationsbot) displays as HTML in the annotator UI rather than escaping.Mirrors the
constraint_severitypattern from #216 very closely:constraint_severityfield_render_modedict[str, Severity]dict[str, FieldRenderMode]"plain"resolved_severity(ws, constraint_id)resolved_render_mode(ws, task, field_name)The one difference:
field_render_modeadds a per-task scope (TaskSettings.field_render_mode) since\"answer\"belongs to different tasks (grounding vs. generation) and a deployment might legitimately want them rendered differently.constraint_severityskips per-task because severity is per-constraint, not per-task — that reason doesn't apply here.Files changed
core/schemas/annotation_task.py— addsFieldRenderModetype +TEXT_FIELDSregistrycore/settings/annotation_settings.py— addsfield_render_modeto all 3 scope classes, plusresolved_render_mode(),_merge_field_render_mode_defaults,_validate_field_render_mode_keyscore/annotation/argilla_task_definitions.py— localmd()helper insidebuild_task_settings, wiresuse_markdown=md(task, name)into the 6rg.TextFieldcallscore/annotation/collapsible_field.html— flips record-content slot fromtextContenttoinnerHTMLso the widget renders pipeline HTML consistently with the main TextField (trust assumption: first-party content)docs/decisions/0009-annotation-schema-configurability.md— addendum: rendering is operational, not schema (in the same layer asmin_submitted,constraint_severity,locale); the hardcoded constraint on fields/questions/labels still holdstests/unit/core/settings/test_annotation_settings.py—TestFieldRenderModeDefaults,TestResolvedRenderMode,TestWorkspaceFieldRenderModeValidation,TestTaskFieldRenderModeValidationtests/unit/core/annotation/test_argilla_task_definitions.py—TestTextFieldsRegistryMatchesActualTextFields(drift check),TestUseMarkdownWireUp(propagation across 3 scopes)Example YAML
Dependency chain
Branched on
feat/annotation-logical-constraints/05-export-summary-by-id(#217 head). Depends on #213 → #214 → #215 → #216 → #217 landing first. The work itself is independent of those changes' content but uses:build_task_settings(settings)signature from refactor(annotation): DRY build_task_settings via assemble() helper #215task_to_workspace()helper + sparse-dict-overlay pattern from feat(annotation): configurable constraint severity at deployment + workspace scopes #216Test plan
pytest tests/unit/— 754 pass, no regressionsfield_render_mode: {answer: markdown}in YAML, runpragmata annotation setup, verify resulting Argilla datasets haveuse_markdown=Trueon grounding/generation answer fields (already demoed manually on a downstream demo branch).