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[EntityTuple]
|
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.
Source code in dp3/common/task.py
parse_eids_from_cache ¶
Parses entity IDs from the "Link" cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_spec
|
ModelSpec
|
Model specification. |
required |
link_entity_entries
|
list[str]
|
List of entity entries from the cache. |
required |
Returns:
Type | Description |
---|---|
list[AnyEidT]
|
List of entity IDs. |
Source code in dp3/common/task.py
parse_eid_tuples_from_cache ¶
parse_eid_tuples_from_cache(model_spec: ModelSpec, link_entity_entries: list[str]) -> list[tuple[str, AnyEidT]]
Parses entity IDs from the "Link" cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_spec
|
ModelSpec
|
Model specification. |
required |
link_entity_entries
|
list[str]
|
List of entity entries from the cache. |
required |
Returns:
Type | Description |
---|---|
list[tuple[str, AnyEidT]]
|
List of tuples (entity type, entity ID). |