timelapse_store
plantimager.controller.scanner.timelapse_store Link
ScanRecord
dataclass
Link
ScanRecord(scan_id, started_at=None, finished_at=None, status='pending', error=None)
Only the data needed to resume/re‑run a timelapse.
from_scan
classmethod
Link
from_scan(scan_obj)
Create a record from a live Scan instance.
Source code in plantimager/controller/scanner/timelapse_store.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
TimelapseStore
dataclass
Link
TimelapseStore(_file_name=getenv('PI3_TIMELAPSE_FILE_NAME', TIMELAPSE_STORAGE_JSON), version=1, timelapse_id='', mode='', state='', schedule_times=list(), next_idx=0, current_idx=0, warmup_sec=0, standby_threshold_sec=0, grace_period=0, start_at=None, scans=list(), extra=dict())
Encapsulates atomic persistence of a TimeLapse object.
from_timelapse
staticmethod
Link
from_timelapse(tl_obj)
Create a store instance from a live TimeLapse object. Only the fields that are required for a restart are persisted.
Source code in plantimager/controller/scanner/timelapse_store.py
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 | |
new_store_from_last
classmethod
Link
new_store_from_last()
Load a TimelapseStore instance from a stored JSON file in the storage directory.
This method attempts to recreate a TimelapseStore object from a persisted state
stored in a JSON file. If the JSON file cannot be found or is invalid, the method
logs the issue and returns None. In case of a version mismatch between the stored
data and the current implementation, the method attempts a best-effort loading process.
Returns:
| Type | Description |
|---|---|
Optional[TimelapseStore]
|
A |
Notes
- The JSON file' is located at
~/.local/share/plant-imager3-app/$PI3_TIMELAPSE_FILE_NAME. If the environment variable is not set, it defaults to"timelapse_storage.json". - A basic version check is performed to ensure backward compatibility. If a version mismatch is detected, a warning is logged, and the loading process continues on a best-effort basis.
- Any exception encountered during file reading or JSON parsing will be caught, and a corresponding error message will be logged.
Source code in plantimager/controller/scanner/timelapse_store.py
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 | |
save Link
save()
Write the current state to disk atomically.
Source code in plantimager/controller/scanner/timelapse_store.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
to_timelapse_kwargs Link
to_timelapse_kwargs()
Convert the stored JSON into a dict that can be fed to a new
TimeLapse instance for a quick “resume” path.
Source code in plantimager/controller/scanner/timelapse_store.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
get_storage_dir Link
get_storage_dir()
Return the path to the storage directory at ~/.local/share/plant-imager3-app
Source code in plantimager/controller/scanner/timelapse_store.py
16 17 18 | |