openaleph_procrastinate.model
DatasetJob
Bases: Job
A job with arbitrary payload bound to a dataset
.
The payload always contains an iterable of serialized EntityProxy
objects
in the entities
key. It may contain other payload context data in the
context
key.
There are helpers for accessing archive files or loading entities.
Source code in openaleph_procrastinate/model.py
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 |
|
from_entities(dataset, queue, task, entities, dehydrate=False, **context)
classmethod
Make a job to process entities for a dataset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
str
|
Name of the dataset |
required |
queue
|
str
|
Name of the queue |
required |
task
|
str
|
Python module path of the task |
required |
entities
|
Iterable[EntityProxy]
|
Entities |
required |
dehydrate
|
bool | None
|
Reduce entity payload to only a reference (tasks should re-fetch these entities from the store if they need more data) |
False
|
context
|
Any
|
Job context |
{}
|
Source code in openaleph_procrastinate/model.py
get_entities()
Get the entities from the payload
Source code in openaleph_procrastinate/model.py
get_file_references()
Get file references per entity from this job
Example
# process temporary file paths
for reference in job.get_file_references():
with reference.get_local_path() as path:
subprocess.run(["command", "-i", str(path)])
# temporary path will be cleaned up when leaving context
# process temporary file handlers
for reference in job.get_file_references():
with reference.open() as handler:
do_something(handler.read())
# temporary path will be cleaned up when leaving context
Yields:
Type | Description |
---|---|
EntityFileReference
|
The file references |
Source code in openaleph_procrastinate/model.py
get_writer()
load_entities()
Load the entities from the store to refresh it to the latest data
Source code in openaleph_procrastinate/model.py
EntityFileReference
Bases: BaseModel
A file reference (via content_hash
) to a servicelayer file from an entity
Source code in openaleph_procrastinate/model.py
get_localpath()
Job
Bases: BaseModel
A job with arbitrary payload
Source code in openaleph_procrastinate/model.py
context
property
Get the context from the payload if any
job_id
property
Get the job_id if it is stored in the context