API Reference
This section provides the auto-generated API documentation for the core classes of SieveComP.
Core Runner Class
High-level orchestration class that: 1. Loads configuration (databases, queries, polygons, checks, output) 2. Resolves DB credentials 3. Loads SQL 4. Loads cached polygons 5. Fetches data from the selected database 6. Optionally checks for duplicates 7. Performs configured checks 8. Applies [output] column selection and returns the final table
Source code in sievecomp/core/runner.py
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 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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
__init__(config_path)
Initialize the Runner with a path to the TOML configuration file.
Parameters
config_path : Path Path to the TOML configuration file.
Source code in sievecomp/core/runner.py
50 51 52 53 54 55 56 57 58 59 60 61 | |
list_checks()
Return the list of check names defined in [[checks]].
Source code in sievecomp/core/runner.py
70 71 72 73 74 | |
list_queries()
Return the list of query names defined in [[queries]].
Source code in sievecomp/core/runner.py
64 65 66 67 68 | |
run(*, query_name=None, multi_query=True, perform_duplicates=True, perform_checks=True, sql_text_override=None, sql_params=None)
Run the full pipeline:
- Load settings (via ConfigManager)
- Load credentials (via DatabaseManager)
- Load SQL (via io.sql.load_sql) or override with a wrapped SQL string
- Load cached polygons
- Fetch data from one or more databases
- Check for duplicates, if requested
- Perform checks, if configured
- Apply [output] column selection and return the final table
CLI and frontend modules can extend or override behavior by: - Supplying a wrapped SQL string and params instead of the base SQL. - Toggling perform_duplicates / perform_checks flags. - Adjusting output selection or adding extra post-processing.
Parameters
query_name : str or None, default=None
Name of the query to run. If None and multi_query is set to False, ConfigManager.select_query() will choose
a single active query if unambiguous. If multi_query is True, it is possible use this parameter to select a
specific query.
multi_query : bool, default=True
Bool variable to set whether to run all non-skipped queries or a single query. Defaults to True
If True, run every non-skipped query and concatenate the results. When more than one [[database]] profile
is configured, every active [[queries]] entry must include a nonempty database field matching a configured
profile name. With exactly one database profile, database is optional.
perform_duplicates : bool, default=True
If True, run duplicate detection and annotate the events table. If False, skip duplicate detection.
perform_checks : bool, default=True
If True, run configured checks and annotate the events table.
sql_text_override : str or None, default=None
If provided, this SQL string is executed instead of the base SQL from the config.
Intended for CLI/frontend wrapping or custom runs.
sql_params : Mapping[str, Any] or None, default=None
Optional parameters dict passed to pandas.read_sql via DatabaseManager.fetch_events.
CLI/frontend can use this to apply time/author filters safely.
Returns
RunResult A dataclass containing: - total_events: pd.DataFrame of all fetched events (before duplicates/checks) - duplicates: pd.DataFrame of detected duplicates (if perform_duplicates is True) - checks: pd.DataFrame of events after checks (if perform_checks is True) - output: pd.DataFrame of final output after [output] column selection
Source code in sievecomp/core/runner.py
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 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 | |
update_from_cache(events_df, reload_config=True)
Re-run duplicates, polygons, and checks on an existing DataFrame without re-querying the database. Useful for applying TOML configuration updates quickly.
Parameters
events_df : pd.DataFrame The cached events DataFrame (usually from a previous RunResult.total_events). reload_config : bool, default=True If True, reloads the TOML file to pick up any user changes to checks, duplicates, or output.
Source code in sievecomp/core/runner.py
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 | |
Configuration Management Class
Load and expose structured access to the TOML configuration file.
This class is responsible for: - Reading the TOML file once. - Tracking the base directory (for resolving relative paths). - Providing accessors for [[database]], [[queries]], [[polygons]] and [[checks]]. - Selecting a single query entry based on name and skip flags.
Source code in sievecomp/core/config_loader.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 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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
base_dir
property
Return the base directory of the TOML configuration file.
config_data
property
Return the configuration data of the TOML configuration file.
config_path
property
Return the path to the TOML configuration file.
__init__(config_path)
Initialize the ConfigManager with a TOML configuration file.
Parameters
config_path : Path Path to the TOML configuration file.
Source code in sievecomp/core/config_loader.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
default_database_name()
Return the default database profile name if unambiguous.
Rules: - Zero or multiple [[database]] profiles return None. - A sole unnamed profile returns DEFAULT_DATABASE_NAME. - A sole named profile returns its stripped explicit name. - An empty or invalid explicit name returns None.
Returns
str or None
Source code in sievecomp/core/config_loader.py
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 | |
get_author_column()
Return the author column name.
Defaults to 'creationInfo_author'.
Source code in sievecomp/core/config_loader.py
341 342 343 344 345 346 347 348 349 350 | |
get_checks()
Return the list of checks defined in [[checks]].
Returns
list[dict] Each dict is one [[checks]] entry. Returns an empty list if no checks are defined.
Source code in sievecomp/core/config_loader.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
get_database()
Return the list of database profiles defined in [[database]].
Returns
list[dict] Each dict is one [[database]] entry. Returns an empty list if no databases are defined.
Source code in sievecomp/core/config_loader.py
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 | |
get_event_type_column()
Return the event-type column name.
Defaults to 'event_type'.
Source code in sievecomp/core/config_loader.py
318 319 320 321 322 323 324 325 326 327 | |
get_polygons()
Return the list of polygons defined in [[polygons]].
Returns
list[dict] Each dict is one [[polygons]] entry. Returns an empty list if no polygons are defined.
Source code in sievecomp/core/config_loader.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
get_queries()
Return the list of queries defined in [[queries]].
Returns
list[dict] Each dict is one [[queries]] entry. Returns an empty list if no queries are defined.
Source code in sievecomp/core/config_loader.py
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 | |
get_time_column()
Return the event-time column name.
Defaults to 'time_value'.
Source code in sievecomp/core/config_loader.py
330 331 332 333 334 335 336 337 338 339 | |
select_query(name=None)
Select a single query configuration from [[queries]]. Used for handle multiple cases in [[queries]] semantics.
Selection rules:
- Queries with skip=true are ignored.
- If name is provided, the query with that name must exist
and must not be skipped; otherwise a ValueError is raised.
- If name is None and there is exactly one active (non-skipped)
query, that query is returned.
- If name is None and there are zero active queries, a ValueError
is raised.
- If name is None and there are multiple active queries, a ValueError
is raised asking the caller to specify a name.
Parameters
name : str or None, default=None Name of the query to select. If None, selection falls back to the single active query if exactly one exists.
Returns
dict The selected [[queries]] entry.
Raises
ValueError If no suitable query can be selected.
Source code in sievecomp/core/config_loader.py
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 | |
Database Management Class
Manage database credentials and DB selection for queries.
This class is responsible for: - Resolve credentials for each [[database]] profile - Decide which database profile to use for a given [[queries]] entry - Fetch data via SQL queries, applying time filters if required
Source code in sievecomp/core/database_manager.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 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 | |
__init__(config_manager)
Initialize the DatabaseManager from a ConfigManager. A single [[database]] entry may omit name
It is stored internally under DEFAULT_DATABASE_NAME. Multiple profiles must each have a unique,
nonempty name.
Parameters
config_manager : ConfigManager Already-initialized ConfigManager pointing to the TOML file.
Source code in sievecomp/core/database_manager.py
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 | |
fetch_events(query_cfg, sql_text, params=None, read_sql_kwargs=None)
Execute the given SQL query against the database selected for this query and return the resulting event table.
This method assumes that any filtering (time range, author, etc.) has already been applied to sql_text by
the caller (core pipeline, CLI wrapper, or frontend). It does not modify the SQL.
Parameters
query_cfg : Mapping[str, Any] Parsed contents of one [[queries]] entry from the TOML file. Used only to determine which database profile to use and for error messages / logging. sql_text : str Final SQL string to execute. May be a base query or a wrapped query with WHERE clauses and ORDER BY. params : Mapping[str, Any] or None, default=None Optional parameter dict to pass to pandas.read_sql for safe value substitution (e.g., {"start": "...", "end": "...", "author": "..."}). read_sql_kwargs : Mapping[str, Any] or None, default=None Additional keyword arguments forwarded to pandas.read_sql, such as chunksize or dtype hints.
Returns
pd.DataFrame Table containing the fetched events.
Raises
ConnectionError If the database connection cannot be established. pymysql.MySQLError If the underlying MySQL driver raises an error during execution.
Source code in sievecomp/core/database_manager.py
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 | |
get_credentials(db_name)
Return the credentials associated with a given [[database]] profile.
Parameters
db_name : str The name of the profile to query.
Returns
dict[str, Any] Credentials with keys: host, port, user, password, database.
Raises
KeyError If no credentials are found for the requested db_name.
Source code in sievecomp/core/database_manager.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
get_db_name_for_query(query_cfg)
Determine which database profile to use for a given [[queries]] entry.
Routing: - If the query configuration specifies a "database" field, use that. - If the query configuration does not specify a "database" field, use ConfigManager.default_database_name() - If neither yields a valid name, raise a ValueError.
Parameters
query_cfg : Mapping[str, Any] The configuration dictionary for a specific query. Parsed from [[queries]] entry.
Returns
str The name of the database profile to use.
Raises
ValueError If the query configuration does not specify a valid database.
Source code in sievecomp/core/database_manager.py
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 | |