Module: factory.core/extend.edit/ObjDecisionSegmentationEdit.py
Product: Arbiter
CRUD and YAML export/import interface for versioned segmentation
definitions. Extends ObjDecisionSegmentation following the same
pattern as ObjDecisionSwitchEdit.
ObjDecisionSegmentationEdit
| extends
ObjDecisionSegmentation (factory.core)
| extends
ObjData + ObjVersionMixin
The core class handles read() + evaluate(). This Edit class
adds load, export, import, migration, and all CRUD operations.
load(segment_name, package=None) -> dictLoad complete segment configuration from database. Returns:
{
"segment": {<def_decision_segment row>},
"columns": [<def_decision_segment_columns rows>],
}
Returns {} if not found.
export_to_file(segment_name, filename=None, package=None) -> boolExport segment definition to YAML file.
load() to get header + columns from DBLiteralDumper (multiline | blocks)Output path: local.documents/segments/package.{pkg}/{name}.yaml
import_from_file(filepath) -> boolImport segment definition from YAML. Creates a new version.
def_decision_segment_clean_in_values()def_decision_segment_columnsdef_decision_segment_historySEGMENT_CACHEmigrate_from_legacy(segment_name) -> boolMigrate a segment from the legacy def_segment table to
def_decision_segment using the migrate_from_legacy query.
When importing from YAML, _clean_in_values() strips surrounding
quotes from each value in comma-separated IN operator selections:
Input: 'A','B','C'
Output: A,B,C
This prevents double-quoting when values are later used in
FIND_IN_SET() queries at evaluation time.
| Method | Purpose |
|---|---|
_strip_column_quotes(value) |
Strip 'val' or "val" to val |
_clean_in_values(csv) |
Strip quotes from each CSV item |
_normalize_keys(data) |
Recursively lowercase dict keys |
_to_snake_case(text) |
PascalCase to snake_case |
_convert_keys_to_snake_case(data) |
Recursive key conversion |
_remove_null_values(data) |
Recursive null removal |
segment:
segment_name: seg_limits
version: 1
base_table: data_seg_limits
base_rank: rank
base_guid: guid
base_values: out_segment,out_cut_off
input_guid: guid
meta_segment: data_seg_limits_seg_meta
default_outcome: DEFAULT
columns:
- column_name: scorecard
column_match: scorecard
column_operation: IN
rank: 1
- column_name: department
column_match: department
column_operation: IN
rank: 2
- column_name: msca
column_match: msca
column_operation: LE
rank: 5
# Export a segment to YAML
python factory.core/extend.edit/ObjDecisionSegmentationEdit.py \
export-yaml seg_limits
# Export with custom filename
python factory.core/extend.edit/ObjDecisionSegmentationEdit.py \
export-yaml seg_limits -f custom.yaml
# Import from YAML (creates new version)
python factory.core/extend.edit/ObjDecisionSegmentationEdit.py \
import-yaml path/to/segment.yaml
# Migrate from legacy def_segment
python factory.core/extend.edit/ObjDecisionSegmentationEdit.py \
migrate seg_limits
# List all segments
python factory.core/extend.edit/ObjDecisionSegmentationEdit.py \
list-segments
DecisionSegmentConstants in ObjConstants.py:
| Constant | Value |
|---|---|
SERVICE_CODE |
DECISIONSEGMENT |
TABLE_SEGMENT |
def_decision_segment |
TABLE_COLUMNS |
def_decision_segment_columns |
TABLE_HISTORY |
def_decision_segment_history |
PATH_SEGMENTS |
local.documents/segments |
OPERATORS_IN |
("IN", "CONTAINS", "><", "@") |
| File | Purpose |
|---|---|
factory.core/ObjDecisionSegmentation.py |
Core engine |
factory.core/ObjDecisionSegmentation.md |
Core documentation |
factory.core/ObjDecisionSegmentation.yaml |
Schema + queries |