Source code for gain.annotation.debug_annotator


from typing import Any

from gain.annotation.annotatable import Annotatable
from gain.annotation.annotation_config import AnnotatorInfo
from gain.annotation.annotation_pipeline import (
    AnnotationPipeline,
    Annotator,
    AttributeSpec,
)
from gain.annotation.annotator_base import AnnotatedValues, AnnotatorBase


[docs] class HelloWorldAnnotator(AnnotatorBase): """Defines example annotator."""
[docs] def get_attribute_specs(self) -> dict[str, AttributeSpec]: return { "hi": AttributeSpec( source="hi", value_type="str", description="Test attribute", internal_default=False, ), }
def _do_annotate( self, annotatable: Annotatable, # ruff: ignore[unused-method-argument] context: dict[str, Any], # ruff: ignore[unused-method-argument] ) -> AnnotatedValues: return self._every("hello world")
[docs] def build_annotator(pipeline: AnnotationPipeline, info: AnnotatorInfo) -> Annotator: """Create an example hello world annotator.""" return HelloWorldAnnotator(pipeline, info)