···11from dataclasses import dataclass
22from datetime import timedelta
33+from enum import IntEnum
34from typing import Any, List, Optional, Self, cast
4556from osprey.engine.executor.custom_extracted_features import CustomExtractedFeature
···89 ENTITY_LABEL_MUTATION_DIMENSION_NAME,
910 ENTITY_LABEL_MUTATION_DIMENSION_VALUE,
1011)
1111-from osprey.rpc.labels.v1.service_pb2 import LabelStatus
12121313from .entities import EntityT
1414from .rules import RuleT, add_slots
151516161717+class LabelStatus(IntEnum):
1818+ ADDED = 0
1919+ REMOVED = 1
2020+ MANUALLY_ADDED = 2
2121+ MANUALLY_REMOVED = 3
2222+2323+ def effective_label_status(self) -> 'LabelStatus':
2424+ """
2525+ Returns the effective status of the label, which is what the upstreams that are observing label
2626+ status changes will see. Which is to say, the upstreams will currently not see if the label status was
2727+ manually added or manually removed, just that it was added or removed.
2828+ """
2929+ match self:
3030+ case LabelStatus.ADDED | LabelStatus.MANUALLY_ADDED:
3131+ return LabelStatus.ADDED
3232+ case LabelStatus.REMOVED | LabelStatus.MANUALLY_REMOVED:
3333+ return LabelStatus.REMOVED
3434+3535+1736@add_slots
1837@dataclass
1938class LabelEffect(EffectToCustomExtractedFeatureBase[List[str]]):
···2342 entity: EntityT[Any]
2443 """The entity that the effect will be applied on."""
25442626- status: LabelStatus.ValueType
4545+ status: LabelStatus
2746 """The status of the label that will be applied by this effect."""
28472948 name: str