Processors API
src.processors
¶
Initialize processors package and register all processors.
__all__ = ['DataProcessor', 'CGMProcessor', 'BGMProcessor', 'CarbsProcessor', 'InsulinProcessor', 'NotesProcessor']
module-attribute
¶
DataProcessor
¶
Main processor class that handles processing of all data types.
Source code in src/processors/base.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
_type_processors: Dict[DataType, Type[BaseTypeProcessor]] = {}
class-attribute
instance-attribute
¶
DEFAULT_INSULIN_BOLUS_LIMIT: float = 8.0
class-attribute
instance-attribute
¶
DEFAULT_INSULIN_MAX_DOSE: float = 15.0
class-attribute
instance-attribute
¶
create_table_configs(detected_format: DeviceFormat) -> Dict[str, TableStructure]
staticmethod
¶
Creates a table configuration dictionary from detected format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detected_format | DeviceFormat | Format object containing files and their table configurations | required |
Returns:
Type | Description |
---|---|
Dict[str, TableStructure] | Dict[str, TableStructure]: Dictionary mapping table names to their structures |
Source code in src/processors/base.py
process_tables(table_data: Dict[str, TableData], detected_format: DeviceFormat, interpolation_limit: Optional[Any] = None, bolus_limit: Optional[float] = None, max_dose: Optional[float] = None) -> Dict[DataType, ProcessedTypeData]
¶
Process all tables according to their configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_data | Dict[str, TableData] | Dictionary mapping table names to their data | required |
detected_format | DeviceFormat | Format object containing table configurations | required |
interpolation_limit | Optional[Any] | Max length of gaps to interpolate | None |
bolus_limit | Optional[float] | Maximum insulin dose to be classified as bolus(default = 8) | None |
max_dose | Optional[float] | Maximum insulin dose - all over will be discarded | None |
Returns:
Type | Description |
---|---|
Dict[DataType, ProcessedTypeData] | Dict[DataType, ProcessedTypeData]: Processed data organized by type |
Source code in src/processors/base.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
register_processor(data_type: DataType)
classmethod
¶
Register a processor class for a specific data type.
Source code in src/processors/base.py
get_processor_for_type(data_type: DataType) -> BaseTypeProcessor
¶
Get appropriate processor instance for the data type.
Source code in src/processors/base.py
BGMProcessor
¶
Bases: BaseTypeProcessor
Processes BGM data with validation and cleaning.
Source code in src/processors/bgm.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
process_type(columns: List[ColumnData]) -> ProcessedTypeData
¶
Process all BGM data from various sources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns | List[ColumnData] | List of ColumnData containing all BGM data columns | required |
Returns:
Type | Description |
---|---|
ProcessedTypeData | ProcessedTypeData containing combined and cleaned BGM data |
Source code in src/processors/bgm.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
CarbsProcessor
¶
Bases: BaseTypeProcessor
Processes carbohydrate intake data with validation and cleaning.
Source code in src/processors/carbs.py
process_type(columns: List[ColumnData]) -> ProcessedTypeData
¶
Process all carbohydrate data from various sources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns | List[ColumnData] | List of ColumnData containing all carb data columns | required |
Returns:
Type | Description |
---|---|
ProcessedTypeData | ProcessedTypeData containing combined and cleaned carb data |
Source code in src/processors/carbs.py
CGMProcessor
¶
Bases: BaseTypeProcessor
Processes CGM data with validation and cleaning.
Source code in src/processors/cgm.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
process_type(columns: List[ColumnData], interpolation_limit: int = 4) -> ProcessedTypeData
¶
Process all CGM data from various sources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns | List[ColumnData] | List of ColumnData containing all CGM data columns | required |
interpolation_limit | int | Maximum number of consecutive missing values to interpolate (default: 4, equivalent to 20 minutes at 5-min intervals) | 4 |
Returns:
Type | Description |
---|---|
ProcessedTypeData | ProcessedTypeData containing combined and cleaned CGM data |
Source code in src/processors/cgm.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
InsulinProcessor
¶
Bases: BaseTypeProcessor
Processes insulin dose data with classification from meta data if available.
Source code in src/processors/insulin.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
_extract_meta_info(meta_value: str) -> Tuple[bool, bool, Optional[str]]
¶
Extract insulin type information from meta JSON.
Returns:
Type | Description |
---|---|
Tuple[bool, bool, Optional[str]] | Tuple of (is_bolus, is_basal, insulin_type) |
Source code in src/processors/insulin.py
process_type(columns: List[ColumnData], bolus_limit: float = 8.0, max_limit: float = 15.0) -> ProcessedTypeData
¶
Process insulin data and classify doses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns | List[ColumnData] | List of ColumnData containing insulin data and metadata | required |
bolus_limit | float | Maximum insulin units to classify as bolus | 8.0 |
max_limit | float | Maximum valid insulin dose | 15.0 |
Source code in src/processors/insulin.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
NotesProcessor
¶
Bases: BaseTypeProcessor
Processes text notes/comments data.
Source code in src/processors/notes.py
process_type(columns: List[ColumnData]) -> ProcessedTypeData
¶
Process notes data ensuring safe string storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns | List[ColumnData] | List of ColumnData containing notes columns | required |
Returns:
Type | Description |
---|---|
ProcessedTypeData | ProcessedTypeData containing processed notes |