Models
pipelines.enrichment.shared.models
Summary
Pattern model family + PatternRegistry (port of domain/enrichment/models.py).
The registry is loaded from the family resources/patterns/*.yaml files and
injected into every dagpipe stage node via set_registry.
Classes
ArrayPattern
Bases: BasePattern
Array pattern: a plain list of values.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[ARRAY]
|
Fixed discriminator. |
array |
List
|
Plain value list. |
BasePattern
Bases: BaseModel
Base model for all patterns: a discriminated type tag.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
PatternType
|
Pattern kind discriminator. |
KeywordsPattern
Bases: BasePattern
Keywords pattern: a flat list of keywords.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[KEYWORDS]
|
Fixed discriminator. |
items |
List[str]
|
Keyword list. |
MappingPattern
Bases: BasePattern
Enumerated mapping of token → value.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[MAPPING]
|
Fixed discriminator. |
mapping |
Dict[str, Union[str, MappingValue, List]]
|
Token mapping. |
MappingValue
Bases: BaseModel
Named value inside a mapping pattern.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Mapping key id. |
name |
str
|
Display name. |
PatternRegistry
Bases: BaseModel
Loaded pattern registry injected into dagpipe stage nodes.
Attributes:
| Name | Type | Description |
|---|---|---|
version |
int
|
Registry schema version. |
patterns |
Dict[str, Pattern]
|
Name → pattern. |
Functions
array
Return the raw array of an ArrayPattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
List |
List
|
The array items. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not an ArrayPattern. |
get
Look up a pattern by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Pattern |
Pattern
|
The stored pattern object. |
Raises:
| Type | Description |
|---|---|
KeyError
|
When the pattern name is not registered. |
keywords
Return the keyword list of a KeywordsPattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: The keyword items. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not a KeywordsPattern. |
mapping
Return the token mapping of a MappingPattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str, str]: The mapping dict. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not a MappingPattern. |
regex
Return the compiled regex of a RegexPattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Type | Description |
|---|---|
Pattern
|
re.Pattern: The compiled regex. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not a RegexPattern. |
regex_list
Return the compiled regexes of a RegexListPattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Type | Description |
|---|---|
List[Pattern]
|
List[re.Pattern]: The compiled regexes. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not a RegexListPattern. |
regex_map
Return the compiled (regex, value) pairs of a RegexMapPattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Type | Description |
|---|---|
List[Tuple[Pattern, str]]
|
List[Tuple[re.Pattern, str]]: The compiled pairs. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not a RegexMapPattern. |
rules
Return the rule list of a RulesPattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict]
|
List[Dict]: The ordered rules. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not a RulesPattern. |
template
Return the format string of a TemplatePattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pattern name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The template format string. |
Raises:
| Type | Description |
|---|---|
TypeError
|
When the pattern is not a TemplatePattern. |
PatternType
Bases: str, Enum
Supported pattern kinds loaded from the family pattern files.
RegexListPattern
Bases: BasePattern
List-of-regexes pattern.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[REGEX_LIST]
|
Fixed discriminator. |
patterns |
List[str]
|
Regex sources. |
Functions
compile_all
Compile every regex source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flags |
int
|
Compile flags, default |
IGNORECASE
|
Returns:
| Type | Description |
|---|---|
List[Pattern]
|
List[re.Pattern]: The compiled regexes. |
RegexMapPattern
Bases: BasePattern
Regex → value mapping pattern.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[REGEX_MAP]
|
Fixed discriminator. |
mapping |
Dict[str, str]
|
Regex source → value. |
Functions
compile_all
Pre-compile the mapping into (regex, value) pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flags |
int
|
Compile flags, default |
IGNORECASE
|
Returns:
| Type | Description |
|---|---|
List[Tuple[Pattern, str]]
|
List[Tuple[re.Pattern, str]]: The compiled pairs. |
RegexPattern
Bases: BasePattern
Single-regex pattern.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[REGEX]
|
Fixed discriminator. |
pattern |
str
|
Regex source. |
Functions
compile
Compile the regex pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flags |
int
|
Compile flags, default |
IGNORECASE
|
Returns:
| Type | Description |
|---|---|
Pattern
|
re.Pattern: The compiled regex. |
RulesPattern
Bases: BasePattern
Rule-set pattern: ordered flag rules with emit payloads.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[RULES]
|
Fixed discriminator. |
rules |
List[Dict]
|
Ordered rule dicts. |
TemplatePattern
Bases: BasePattern
String-template pattern.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal[TEMPLATE]
|
Fixed discriminator. |
format |
str
|
Format/template string. |