Measurement
A Measurement is a reference to a measurement stored on the server.
A reference is a GUID without any additional data. Get the data with Measurement.get_data. This returns an xarray.Dataset (single run) or xarray.DataTree (stacked runs). The getters only work while the measurement reference is attached to a live session. You can re-attach with session.get_measurement(ref) before calling Measurement.get_data.
A MeasurementJob is a handle to a measurement in progress. It consists of a reference (GUID) and is attached to a Session. Starting a measurement returns the job immediately. You can await the job to block until it finishes and receive a Measurement.
job = await claim.start_measurement(method=method) #(1)!
measurement = await job #(2)!
data = await measurement.get_data()
- returns immediately
- blocks until it finishes
The current job status is reported via is_finished. Jobs can be interrupted with abort, pause, and resume.
The measurement data API is still work in progress.
Classes:
pypalmsens.lablink.Measurement
A reference to a measurement.
Holds the GUID of a stored measurement and an optional session link.
Methods:
-
delete–Delete this measurement from the server.
-
get_data–Retrieve recorded data for this measurement.
-
get_info–Get metadata for this measurement (not yet implemented).
Attributes:
Source code in src/pypalmsens/lablink/_measurement.py
32 33 34 | |
delete
async
delete() -> None
Delete this measurement from the server.
Raises:
-
ConnectionError–If this reference is detached from a session.
Source code in src/pypalmsens/lablink/_measurement.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
get_data
async
Retrieve recorded data for this measurement.
Returns:
-
Dataset or DataTree–Measurement data. A
Datasetis returned for a single measurement, aDataTreewhen the measurement contains repeated/stacked runs.
Raises:
-
ConnectionError–If this reference is detached from a session.
Source code in src/pypalmsens/lablink/_measurement.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
get_info
async
get_info() -> None
Get metadata for this measurement (not yet implemented).
Raises:
-
ConnectionError–If no session is attached. Reattach via
session.get_measurement(ref)before calling.
Source code in src/pypalmsens/lablink/_measurement.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
pypalmsens.lablink.MeasurementJob
MeasurementJob(guid: str, *, claim: InstrumentClaim)
A job representing an ongoing measurement.
Holds the GUID of a measurement in progress and its instrument claim.
Methods:
-
abort–Abort the measurement.
-
pause–Pause the measurement.
-
result–Wait for the measurement to finish and return a reference.
-
resume–Resume the measurement.
Attributes:
-
claim(InstrumentClaim) –The instrument claim associated with the measurement job.
-
guid(str) –The unique identifier of the measurement being performed.
-
is_finished(bool) –True if the measurement has finished.
-
serial_number(str) –Serial number of the instrument carrying out the measurement.
Source code in src/pypalmsens/lablink/_measurement.py
115 116 117 118 | |
guid
property
guid: str
serial_number
property
serial_number: str
Serial number of the instrument carrying out the measurement.
abort
async
abort() -> None
Abort the measurement.
Source code in src/pypalmsens/lablink/_measurement.py
216 217 218 | |
pause
async
pause() -> None
Pause the measurement.
Source code in src/pypalmsens/lablink/_measurement.py
220 221 222 | |
result
async
result(*, initial: float = 1.0, cap: float = 30.0, factor: float = 2.0, jitter: float = 0.15, timeout: float | None = None) -> Measurement
Wait for the measurement to finish and return a reference.
Polls claim.get_active_measurement() with exponential backoff so
short jobs are caught quickly while long ones stay cheap.
Parameters:
-
(initialfloat, default:1.0) –Delay before the first retry, in seconds. Defaults to 1.0.
-
(capfloat, default:30.0) –Maximum delay between polls, in seconds. Defaults to 30.0.
-
(factorfloat, default:2.0) –Multiplier applied to the delay after each poll. Defaults to 2.0.
-
(jitterfloat, default:0.15) –Fractional randomness added to each delay (e.g., 0.15 for +/-15%). Defaults to 0.15.
-
(timeoutfloat or None, default:None) –Total seconds to wait before giving up; None waits indefinitely. Defaults to None.
Returns:
-
MeasurementRef–A reference to the finished measurement.
Raises:
-
TimeoutError–If
timeoutis set and the measurement does not finish in time.
Source code in src/pypalmsens/lablink/_measurement.py
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
resume
async
resume() -> None
Resume the measurement.
Source code in src/pypalmsens/lablink/_measurement.py
224 225 226 | |