opensampl.db.orm
Main openSAMPL database ORM
AdvaMetadata
Bases: Base
ADVA Clock Probe specific metadata
This is metadata that is specifically provided by ADVA probes in their text file exports.
Source code in opensampl/db/orm.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
BaseHelpers
Mixin for Base class that adds some helper methods.
Provides common functionality for database models including serialization, constraint handling, and reference resolution.
Source code in opensampl/db/orm.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
get_session()
Extract session from object, raise runtime error if not found.
Returns:
Type | Description |
---|---|
Session
|
Database session associated with this object. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If no session is found for this object. |
Source code in opensampl/db/orm.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
identifiable_constraint()
classmethod
Get the name of the unique constraint used for identification.
Used in cases where we want to use a unique constraint to overwrite other entries. Primarily used for probe metadata, so that we can use probe_key and ip_address to change name, which is also a unique constraint, without manually retrieving the uuid from the db.
Returns:
Type | Description |
---|---|
Optional[str]
|
Name of the unique constraint, or None if not applicable. |
Source code in opensampl/db/orm.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
resolve_references(session=None)
Resolve UUIDs for other entries in the database given a unique constraint.
Primarily used for probe metadata, so that we can use location_name and test_name to resolve to UUIDs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
Optional[Session]
|
Database session to use for resolution. |
None
|
Source code in opensampl/db/orm.py
60 61 62 63 64 65 66 67 68 69 70 |
|
to_dict()
Convert to dictionary, including changes to make it serializable.
Returns:
Type | Description |
---|---|
Dictionary representation of the object with serializable values. |
Source code in opensampl/db/orm.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
Defaults
Bases: Base
Table for storing the default uuid for lookup tables
Source code in opensampl/db/orm.py
395 396 397 398 399 400 401 |
|
Locations
Bases: Base
Table for storing locations
Automatically parses lat, lon, and z into point
Source code in opensampl/db/orm.py
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 |
|
__init__(**kwargs)
Initialize Location object, including converting lat, lon, and z into point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
dict
|
Keyword arguments including lat, lon, z, and projection for geometry. |
{}
|
Source code in opensampl/db/orm.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
MetricType
Bases: Base
The type of metric that is being recorded in probe_data
Stores a required value type (as in, string, int, float) and a unit (as in seconds, ppm, etc). Optionally identify it with a name and a description.
Source code in opensampl/db/orm.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
MicrochipTP4100Metadata
Bases: Base
Microchip TP4100 Clock Probe specific metadata
This is metadata that is specifically provided by microchip TP4100 probes in their text file exports.
Source code in opensampl/db/orm.py
422 423 424 425 426 427 428 429 430 431 432 433 |
|
MicrochipTWSTMetadata
Bases: Base
Microchip TWST Clock Probe specific metadata
This is metadata that is specifically provided by microchip twst probes in their text file exports.
Source code in opensampl/db/orm.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
ProbeData
Bases: Base
Table for storing actual time data from the probes.
Each entry has a reference to the probe's uuid, timestamp for the measurement, and value for the measurement.
Source code in opensampl/db/orm.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
ProbeMetadata
Bases: Base
Stores the basic information about clock probes.
A unique probe is identified by its ip address and probe_id.
Can be associated with an existing location or test by its name by providing location_name/test_name
Source code in opensampl/db/orm.py
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 212 213 214 215 216 217 218 219 220 221 222 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 250 251 |
|
__init__(**kwargs)
Initialize Probe Metadata object, dealing with converting location name into uuid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Keyword arguments including location_name and test_name for reference resolution. |
{}
|
Source code in opensampl/db/orm.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
identifiable_constraint()
classmethod
Get the name of the unique constraint used for identification.
Returns:
Type | Description |
---|---|
Optional[str]
|
Name of the unique constraint for probe metadata. |
Source code in opensampl/db/orm.py
204 205 206 207 208 209 210 211 212 213 |
|
resolve_references(session=None)
Resolve references to location and/or test entries when given just the name.
Provides the correct foreign UUID key by looking up the location or test by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
Optional[Session]
|
SQLAlchemy session, used to query for the location/test. |
None
|
Source code in opensampl/db/orm.py
215 216 217 218 219 220 221 222 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 250 251 |
|
Reference
Bases: Base
Table for storing reference information.
These references are what the recorded values in Probe Data are against. Types of reference are determined by metric type
Source code in opensampl/db/orm.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
ReferenceType
Bases: Base
Stores the types of reference that can be used in the reference table.
Source code in opensampl/db/orm.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
TestMetadata
Bases: Base
TestMetadata table for storing name, start and end of tests
Source code in opensampl/db/orm.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
get_table_names()
Get all table names from the ORM in opensampl.db.orm.
Returns:
Type | Description |
---|---|
List of table names sorted by dependency order. |
Source code in opensampl/db/orm.py
493 494 495 496 497 498 499 500 501 |
|
resolve_uuid(mapper, connection, target)
Resolve the location_uuid and test_uuid entries for a probe before the object is inserted into the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapper
|
SQLAlchemy mapper object. |
required | |
connection
|
Database connection. |
required | |
target
|
ProbeMetadata
|
ProbeMetadata instance being inserted. |
required |
Source code in opensampl/db/orm.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
|
set_probe_data_defaults(mapper, connection, target)
Set default values for reference_uuid and metric_type_uuid before inserting ProbeData.
Uses the database function get_default_uuid_for() to retrieve default UUIDs when the values are not explicitly provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapper
|
SQLAlchemy mapper object. |
required | |
connection
|
Database connection. |
required | |
target
|
ProbeData
|
ProbeData instance being inserted. |
required |
Source code in opensampl/db/orm.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
|