Skip to content

Abc

pipelines.enrichment.tags.abc

Summary

Abstract contracts for the tags enrichment family (no implementation).


The tags family chains resolved entities into tags:

1
amount_flags → entity_flags → set_tags

It consumes the output of the entity family (entity.name + amount) and emits tags. TagsPipeline is the hexa root; TagsFinalizePort dedupes tags and defaults to ["misc"].

Classes

EntityFlagsPort

Bases: RegistryPort, ABC

entity.name + candidate.flags → entity_* flags via ENTITY_BASED_FLAG_MAPPING.

Attributes
config property
config

Per-node config injected via set_config.

Returns:

Type Description

dict | None: The per-node config, or None before injection.

Functions
resolve abstractmethod
resolve(state: State) -> Iterable[State]

Yield forks with entity_* flags appended from the entity name.

Parameters:

Name Type Description Default
state State

Incoming dagpipe state carrying entity.name.

required

Yields:

Name Type Description
State Iterable[State]

Forked states carrying updated candidate flags.

set_config
set_config(config)

Inject the per-node config.

Parameters:

Name Type Description Default
config dict

Per-node config from the dagpipe spec.

required
set_registry
set_registry(registry)

Inject the merged pattern registry.

Parameters:

Name Type Description Default
registry PatternRegistry

The merged pattern registry.

required

SetTagsPort

Bases: RegistryPort, ABC

candidate.flags → tags via FLAGS_BASED_TAGS_RULES.

Attributes
config property
config

Per-node config injected via set_config.

Returns:

Type Description

dict | None: The per-node config, or None before injection.

Functions
resolve abstractmethod
resolve(state: State) -> Iterable[State]

Yield forks with tags populated from candidate flags.

Parameters:

Name Type Description Default
state State

Incoming dagpipe state carrying candidate flags.

required

Yields:

Name Type Description
State Iterable[State]

Forked states carrying the emitted tags.

set_config
set_config(config)

Inject the per-node config.

Parameters:

Name Type Description Default
config dict

Per-node config from the dagpipe spec.

required
set_registry
set_registry(registry)

Inject the merged pattern registry.

Parameters:

Name Type Description Default
registry PatternRegistry

The merged pattern registry.

required

TagsFinalizePort

Bases: FinalizePort, ABC

terminal states → {"tags": [...]} (deduped, default ["misc"]).

Functions
process abstractmethod
process(states: List) -> dict

Build the tags result dict from the terminal states.

Parameters:

Name Type Description Default
states List

Terminal states from the dagpipe graph.

required

Returns:

Name Type Description
dict dict

The tags result dict.

TagsPipeline

Bases: ABC

Root — wires amount_flags → entity_flags → set_tags, then runs the graph.

Attributes:

Name Type Description
amount_flags AmountFlagsPort

Amount-flags stage port.

entity_flags EntityFlagsPort

Entity-flags stage port.

set_tags SetTagsPort

Set-tags stage port.

finalize TagsFinalizePort

Terminal finalize port.

Functions
enrich abstractmethod
enrich(payload: dict) -> dict

Enrich an entity payload into a tags result.

Parameters:

Name Type Description Default
payload dict

Payload carrying entity.name and the amount.

required

Returns:

Name Type Description
dict dict

The tags result dict.