Return annotation profile and field role config parsed from LabelView tags. The UI uses this to select the right annotation method and map user interactions to schema fields.
(label_view_name: str)
| 736 | |
| 737 | @rest_app.get("/annotation-config/{label_view_name}") |
| 738 | def annotation_config(label_view_name: str): |
| 739 | """Return annotation profile and field role config parsed from LabelView tags. |
| 740 | |
| 741 | The UI uses this to select the right annotation method and map |
| 742 | user interactions to schema fields. |
| 743 | """ |
| 744 | try: |
| 745 | fv = store.registry.get_label_view(label_view_name, store.project) |
| 746 | |
| 747 | tags = dict(getattr(fv, "tags", {})) |
| 748 | profile = tags.get("feast.io/labeling-method", "table") |
| 749 | |
| 750 | field_roles: Dict[str, str] = {} |
| 751 | label_values: Dict[str, List] = {} |
| 752 | label_widgets: Dict[str, str] = {} |
| 753 | |
| 754 | for key, value in tags.items(): |
| 755 | if key.startswith("feast.io/field-role:"): |
| 756 | field_name = key[len("feast.io/field-role:") :] |
| 757 | field_roles[field_name] = value |
| 758 | elif key.startswith("feast.io/label-values:"): |
| 759 | field_name = key[len("feast.io/label-values:") :] |
| 760 | label_values[field_name] = [v.strip() for v in value.split(",")] |
| 761 | elif key.startswith("feast.io/label-widget:"): |
| 762 | field_name = key[len("feast.io/label-widget:") :] |
| 763 | label_widgets[field_name] = value |
| 764 | |
| 765 | entity_names = fv.entities if fv.entities else [] |
| 766 | feature_names = [f.name for f in fv.features] |
| 767 | labeler_field = getattr(fv, "labeler_field", "labeler") |
| 768 | push_source_name = fv.source.name if fv.source else None |
| 769 | |
| 770 | return { |
| 771 | "label_view": label_view_name, |
| 772 | "profile": profile, |
| 773 | "field_roles": field_roles, |
| 774 | "label_values": label_values, |
| 775 | "label_widgets": label_widgets, |
| 776 | "entities": entity_names, |
| 777 | "features": feature_names, |
| 778 | "labeler_field": labeler_field, |
| 779 | "push_source_name": push_source_name, |
| 780 | } |
| 781 | except Exception: |
| 782 | logger.exception("Annotation config lookup failed") |
| 783 | return _safe_error_response("Annotation config", status.HTTP_404_NOT_FOUND) |
| 784 | |
| 785 | app.mount("/api/v1", rest_app) |
| 786 |
nothing calls this directly
no test coverage detected