dp3.common.task ¶
Task ¶
Bases: BaseModel
, ABC
A generic task type class.
An abstraction for the task queue classes to depend upon.
DataPointTask ¶
Bases: Task
DataPointTask
Contains single task to be pushed to TaskQueue and processed. Attributes: etype: Entity type eid: Entity id / key data_points: List of DataPoints to process tags: List of tags ttl_tokens: Dictionary of TTL tokens. delete: If True, delete entity
Set the model_spec
context variable and initialize the Task.
See https://docs.pydantic.dev/latest/concepts/validators/#validation-context
Source code in dp3/common/task.py
Snapshot ¶
Bases: Task
Snapshot
Contains a list of entities, the meaning of which depends on the type
.
If type
is "task", then the list contains linked entities for which a snapshot
should be created. Otherwise type
is "linked_entities", indicating which entities
must be skipped in a parallelized creation of unlinked entities.
Attributes:
Name | Type | Description |
---|---|---|
entities |
list[tuple[str, str]]
|
List of (entity_type, entity_id) |
time |
datetime
|
timestamp for snapshot creation |
final |
bool
|
If True, this is the last linked snapshot for the given time |
HASH ¶
Hash function used to distribute tasks to worker processes. Args: key: to be hashed Returns: last 4 bytes of MD5
task_context ¶
Context manager for setting the model_spec
context variable.