dp3.core.updater ¶
Core module that executes periodic update callbacks.
UpdaterConfig ¶
Bases: BaseModel
The configuration of the Updater module.
The periodic update is executed in smaller batches for better robustness. The batch size is dynamically adjusted based the total number of entities and the estimated growth rate.
Attributes:
Name | Type | Description |
---|---|---|
update_batch_cron |
CronExpression
|
A CRON expression for the periodic update. |
update_batch_period |
ParsedTimedelta
|
The period of the periodic update.
Should equal to the period of |
cache_management_cron |
CronExpression
|
A CRON expression for the cache management. |
cache_max_entries |
int
|
The maximum number of finished cache entries per thread_id. |
UpdateThreadState ¶
Bases: BaseModel
A cache item describing a state of one configured update thread.
Attributes:
Name | Type | Description |
---|---|---|
type |
Literal['state']
|
"state" |
t_created |
datetime
|
Time of creation. |
t_last_update |
datetime
|
Time of last update. |
t_end |
datetime
|
Time of predicted period end. |
processed |
int
|
The number of currently processed entities. |
total |
int
|
The total number of entities. |
iteration |
int
|
The current iteration. |
total_iterations |
int
|
Total number of iterations. |
etype |
str
|
Entity type. |
period |
float
|
Period length in seconds. |
eid_only |
bool
|
Whether only eids are passed to hooks. |
hook_ids |
list[str]
|
Hook ids. |
runtime_secs |
float
|
Total hook runtime in seconds. |
new
classmethod
¶
Create a new instance initialized with hooks and thread_id components.
Source code in dp3/core/updater.py
id_attributes
staticmethod
¶
reset ¶
Resets counters and timestamps.
Source code in dp3/core/updater.py
UpdaterCache ¶
The cache collection contains the metadata documents with the state of the update process for each entity type.
Source code in dp3/core/updater.py
get_unfinished ¶
Yields all unfinished cache entries from DB.
upsert ¶
Update or insert a state entry into DB.
Source code in dp3/core/updater.py
register_management ¶
Registers the cache management task with the scheduler.
Source code in dp3/core/updater.py
Updater ¶
Updater(db: EntityDatabase, task_queue_writer: TaskQueueWriter, platform_config: PlatformConfig, scheduler: Scheduler, elog: EventGroupType)
Executes periodic update callbacks.
Source code in dp3/core/updater.py
register_record_update_hook ¶
register_record_update_hook(hook: Callable[[str, str, dict], list[DataPointTask]], hook_id: str, entity_type: str, period: ParsedTimedelta)
Registers a hook for periodic update of entities of the specified type.
The hook receives the entity type, the entity ID and the master record.
Source code in dp3/core/updater.py
register_eid_update_hook ¶
register_eid_update_hook(hook: Callable[[str, str], list[DataPointTask]], hook_id: str, entity_type: str, period: ParsedTimedelta)
Registers a hook for periodic update of entities of the specified type.
The hook receives the entity type and the entity ID.
Source code in dp3/core/updater.py
start ¶
Starts the updater.
Will fetch the state of the updater from the cache and schedule the update threads.
Source code in dp3/core/updater.py
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 |
|