fix: Fix the dataset can't load issue by unifying "values" keyword in tags object.#363
fix: Fix the dataset can't load issue by unifying "values" keyword in tags object.#363
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to resolve dataset loading failures caused by inconsistent tag field naming by standardizing the internal “full” tag format to use the values key (instead of value), aligning with the frontend parsing expectation.
Changes:
- Update tag conversion output to emit
valuesin the full tag format. - Update related docstrings/examples to reference
valuesfor the full format.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| runtime/datamate-python/app/module/dataset/service/service.py | Updates tag format documentation to reflect values in the full format. |
| runtime/datamate-python/app/module/annotation/utils/tag_converter.py | Changes full-format tag output to use values and updates example snippets, but also alters simplified-format detection logic. |
Comments suppressed due to low confidence (1)
runtime/datamate-python/app/module/annotation/utils/tag_converter.py:175
is_simplified_formatis currently broken:has_valueduplicateshas_values(both check'values' in tag), so the return conditionhas_values and not has_type and not has_valuewill always be False whenvaluesis present. This prevents simplified tags from being converted inconvert_if_needed. Update the detection logic (e.g., treat tags as simplified when'values' in tagand'type' not in tag, or additionally differentiate by checking whethertag['values']is a dict vs list) and fix the related inline comment which still refers to nestedvalue.
# Simplified format has 'values' at top level and no 'type' field
has_values = 'values' in tag
has_type = 'type' in tag
has_value = 'values' in tag
# If it has 'values' but no 'type', it's simplified
# If it has 'type' and nested 'value', it's already full format
return has_values and not has_type and not has_value
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| full_tag = { | ||
| "id": tag_id, | ||
| "from_name": from_name, | ||
| "to_name": to_name, | ||
| "type": control_type, | ||
| "value": { | ||
| "values": { | ||
| control_type: values | ||
| } | ||
| } |
There was a problem hiding this comment.
This change switches the full-format output key from value to values, but the existing unit tests in app/module/annotation/utils/test_tag_converter.py still assert on the value field (e.g., converted_update[0]["value"] == ...). Update the tests to validate the new values structure so CI doesn’t fail and the new format is covered.
| 如果提供了 template_id,会自动将简化格式的标签转换为完整格式。 | ||
| 简化格式: {"from_name": "x", "to_name": "y", "values": [...]} | ||
| 完整格式: {"id": "...", "from_name": "x", "to_name": "y", "type": "...", "value": {"type": [...]}} | ||
| 完整格式: {"id": "...", "from_name": "x", "to_name": "y", "type": "...", "values": {"type": [...]}} |
There was a problem hiding this comment.
Docstring example for the full tag format uses "values": {"type": [...]}; in the actual converter the nested dict key is the control type value (e.g., "choices", "rectanglelabels"). Consider updating the example to something like "values": {"<type>": [...]} to avoid misleading callers.
| 完整格式: {"id": "...", "from_name": "x", "to_name": "y", "type": "...", "values": {"type": [...]}} | |
| 完整格式: {"id": "...", "from_name": "x", "to_name": "y", "type": "...", "values": {"<type>": [...]}} |
No description provided.