Database Provider
Implementation of the data provider layer for SQL databases.
This implementation only support the new compressed (Zstandard) format. Thus, a dictionary provider always exists and is used to store the Zstandard dictionaries.
Thanks to the database layout (using SQLite with SQLAlchemy), dict and data entries are linked, making dict impossible to be deleted if data entries are still using it (safety).
Schema
- data: String name [PK], Integer job [PK, FK:job.id], Integer dict [FK:dict.id], BLOB data.
- dict: Integer id [PK], String name [UNIQUE], Integer zstd_id [NULLABLE], BLOB data [NULLABLE].
- job: Integer id [PK], Integer dirac_id [NULLABLE], Boolean success [NULLABLE].
Classes:
Name | Description |
---|---|
- SQLDataEntry |
SQL data entry implementation. |
- SQLDictEntry |
SQL dictionary entry implementation. |
- SQLJobEntry |
SQL job entry implementation. |
- SQLDataProvider |
SQL data provider implementation. |
- SQLDictProvider |
SQL dictionary provider implementation. |
- SQLDriver |
the SQLite driver used by the other classes. |
- SQLDataIO |
SQL data file-like IO implementation. |
SQLDataEntry
Bases: DataEntry
SQL Database data entry implementation.
Only supports the new compressed (Zstandard) format.
Source code in src/lhcbdirac_log/providers/database/accessors.py
349 350 351 352 353 354 355 356 357 358 359 360 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 |
|
__init__(driver, name, job, *, readonly)
[Internal] Initialize the data entry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
driver |
SQLDriver
|
the SQL driver |
required |
name |
str
|
the data name |
required |
job |
int
|
the job id |
required |
readonly |
bool
|
indicate weather the data is read-only or not |
required |
Notes
- compressed is always True
Source code in src/lhcbdirac_log/providers/database/accessors.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
SQLDataIO
Bases: BufferedIOBase
, BinaryIO
SQL Data file-like I/O implementation for binary data access.
Supported methods and properties
- name
- mode
- readable
- writable
- read
- write
- seekable
- seek
- tell
- flush
- close
- enter
- exit
Source code in src/lhcbdirac_log/providers/database/accessors.py
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 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 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 252 253 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 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 339 340 341 342 343 344 345 346 |
|
mode: str
property
Get the file mode.
Returns:
Type | Description |
---|---|
str
|
the file mode |
name: str
property
Get the file name.
Returns:
Type | Description |
---|---|
str
|
the file name |
__init__(driver, entry, write_buffer=0, *, read_mode=True)
[Internal] Initialize the SQL Data file-like I/O.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
driver |
SQLDriver
|
the SQL driver |
required |
entry |
SQLDataEntry
|
the data entry to work with |
required |
write_buffer |
int
|
the size of the write buffer (default is driver.BLOB_LIMIT) |
0
|
read_mode |
bool
|
True if the I/O is in read mode, False otherwise |
True
|
Source code in src/lhcbdirac_log/providers/database/accessors.py
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 87 88 89 90 91 |
|
__repr__()
Get the string representation of the file-like I/O.
Returns:
Type | Description |
---|---|
str
|
the string representation |
Source code in src/lhcbdirac_log/providers/database/accessors.py
340 341 342 343 344 345 346 |
|
close()
Close the file-like I/O.
Source code in src/lhcbdirac_log/providers/database/accessors.py
330 331 332 333 334 335 336 337 338 |
|
read(size=-1)
Read data from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
int | None
|
the number of bytes to read (default is -1, read all) |
-1
|
Returns:
Type | Description |
---|---|
bytes
|
the read data |
Raises:
Type | Description |
---|---|
DataNotExistsError
|
if the data does not exist |
Source code in src/lhcbdirac_log/providers/database/accessors.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
readable()
Check if the file is readable.
Returns:
Type | Description |
---|---|
bool
|
True if the file is readable, False otherwise |
Raises:
Type | Description |
---|---|
ValueError
|
if the I/O is closed and in read mode |
Source code in src/lhcbdirac_log/providers/database/accessors.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
readline(limit=-1)
Unsupported operation.
Source code in src/lhcbdirac_log/providers/database/accessors.py
121 122 123 124 |
|
readlines(hint=-1)
Unsupported operation.
Source code in src/lhcbdirac_log/providers/database/accessors.py
228 229 230 231 |
|
seek(offset, whence=os.SEEK_SET)
Seek to a position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset |
int
|
the offset to seek to |
required |
whence |
int
|
the reference point for the offset |
SEEK_SET
|
Returns:
Type | Description |
---|---|
int
|
the new position |
Raises:
Type | Description |
---|---|
ValueError
|
if the I/O is closed or invalid whence |
OSError
|
if the I/O is in write-only mode or invalid offset |
Source code in src/lhcbdirac_log/providers/database/accessors.py
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 |
|
seekable()
Check if the file is seekable.
Returns:
Type | Description |
---|---|
bool
|
True if the file is seekable, False otherwise |
Raises:
Type | Description |
---|---|
ValueError
|
if the I/O is closed |
Source code in src/lhcbdirac_log/providers/database/accessors.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
tell()
Get the current position.
Returns:
Type | Description |
---|---|
int
|
the current position |
Source code in src/lhcbdirac_log/providers/database/accessors.py
215 216 217 218 219 220 221 222 223 224 225 226 |
|
writable()
Check if the file is writable.
Returns:
Type | Description |
---|---|
bool
|
True if the file is writable, False otherwise |
Raises:
Type | Description |
---|---|
ValueError
|
if the I/O is closed and in write mode |
Source code in src/lhcbdirac_log/providers/database/accessors.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
write(data)
Write data to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Buffer | bytes | bytearray | memoryview
|
the data to write |
required |
Returns:
Type | Description |
---|---|
int
|
the number of bytes written |
Raises:
Type | Description |
---|---|
ValueError
|
if the I/O is closed |
OSError
|
if the I/O is in read-only mode |
BufferError
|
if the write buffer limit will be reached |
Source code in src/lhcbdirac_log/providers/database/accessors.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
writelines(lines)
Unsupported operation.
Source code in src/lhcbdirac_log/providers/database/accessors.py
233 234 235 236 |
|
SQLDataProvider
Bases: DataProvider[SQLJobEntry]
SQL data provider implementation.
Only supports the new compressed (Zstandard) format.
Source code in src/lhcbdirac_log/providers/database/providers.py
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 |
|
driver: SQLDriver
property
__init__(driver=None, dict_provider=None, *, readonly=False)
Initialize the data provider.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
driver |
SQLDriver | None
|
the SQL driver, use the |
None
|
dict_provider |
SQLDictProvider | None
|
the dictionary provider, if None, a new one will be created |
None
|
readonly |
bool
|
indicate weather the provider is read-only or not (default: False) |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
if the specified dictionary provider uses a different SQL driver |
Source code in src/lhcbdirac_log/providers/database/providers.py
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 |
|
SQLDictEntry
Bases: DictEntry
SQL Database dictionary entry implementation.
Source code in src/lhcbdirac_log/providers/database/accessors.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
__init__(driver, name, config, data=None, zstd_id=None)
[Internal] Initialize the dictionary entry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
driver |
SQLDriver
|
the SQL driver |
required |
name |
str
|
the dictionary name |
required |
config |
Config
|
the configuration to use for precomputing the dictionary |
required |
data |
bytes | None
|
the dictionary data (create a new dict if not None) |
None
|
zstd_id |
int | None
|
the zstd dictionary id (None for unknown) |
None
|
Source code in src/lhcbdirac_log/providers/database/accessors.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
|
SQLDictProvider
Bases: DictProvider[SQLDictEntry]
SQL dictionary provider implementation.
Source code in src/lhcbdirac_log/providers/database/providers.py
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 |
|
driver: SQLDriver
property
__init__(driver, config=DEFAULT_CONFIG, *, readonly=False)
Initialize the dictionary provider.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
driver |
SQLDriver
|
the SQL driver |
required |
config |
Config
|
the configuration to use for precomputing the dictionaries (default: DEFAULT_CONFIG) |
DEFAULT_CONFIG
|
readonly |
bool
|
whether the provider is read-only (default: False) |
False
|
Source code in src/lhcbdirac_log/providers/database/providers.py
42 43 44 45 46 47 48 49 50 51 |
|
SQLDriver
[Internal] SQL low-level database driver for SQLite databases.
This class provides the low-level database access used for all other classes of this implementation.
This class must be instantiated manually but not used directly. Must be used through the SQLDataProvider and SQLDictProvider classes.
Source code in src/lhcbdirac_log/providers/database/driver.py
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 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 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 252 253 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 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 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 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
|
blob_limit: int
property
Get the maximum size of a BLOB in the database.
Returns:
Type | Description |
---|---|
int
|
the maximum size of a BLOB in the database |
connection: Connection
property
Get the database connection.
Returns:
Type | Description |
---|---|
Connection
|
the database connection |
engine: Engine
property
Get the database engine.
Returns:
Type | Description |
---|---|
Engine
|
the database engine |
__init__(engine)
Initialize a new SQLite database driver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine |
Engine
|
the database engine |
required |
Notes
- use the
create
class method to create a new driver from a database path
Schema
- data: String name [PK], Integer job [PK, FK:job.id], Integer dict [FK:dict.id], BLOB data
- dict: Integer id [PK], String name [UNIQUE], Integer zstd_id [NULLABLE], BLOB data [NULLABLE]
- job: Integer id [PK], Integer dirac_id [NULLABLE], Boolean success [NULLABLE]
Source code in src/lhcbdirac_log/providers/database/driver.py
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 |
|
check_data(job, file_name)
Check if a file exists in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
file_name |
str
|
the file name |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the file exists, False otherwise |
Source code in src/lhcbdirac_log/providers/database/driver.py
189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
check_dict(dict_name, *, invalid=False)
Check if a dictionary exists in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dict_name |
str
|
the dictionary name |
required |
invalid |
bool
|
if True, return the dict id even if the dictionary is invalid, otherwise return None (default is False) |
False
|
Returns:
Type | Description |
---|---|
int | None
|
the dict id if the dictionary exists, None otherwise |
Source code in src/lhcbdirac_log/providers/database/driver.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
check_job(job)
Check if a job exists in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the job exists, False otherwise |
Source code in src/lhcbdirac_log/providers/database/driver.py
203 204 205 206 207 208 209 210 211 212 213 |
|
clear_job(job)
Clear all files from a job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
Source code in src/lhcbdirac_log/providers/database/driver.py
441 442 443 444 445 446 447 448 449 450 |
|
close()
Close the connection to the database, and dispose it.
Notes
- the driver may not be used after this method is called
Source code in src/lhcbdirac_log/providers/database/driver.py
586 587 588 589 590 591 592 593 |
|
create(path=None)
classmethod
Create a new SQLite database driver instance attached to a SQLite database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str | None
|
the path to the database file (new or existing), in-memory database by default (default is None) |
None
|
Returns:
Type | Description |
---|---|
Self
|
a new SQLManager instance |
Source code in src/lhcbdirac_log/providers/database/driver.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
delete_data(job, file_name)
Delete a file from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
file_name |
str
|
the file name |
required |
Raises:
Type | Description |
---|---|
DataNotExistsError
|
if the file does not exist |
Source code in src/lhcbdirac_log/providers/database/driver.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
delete_dict(dict_name)
Delete a dictionary from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dict_name |
str
|
the dictionary name |
required |
Raises:
Type | Description |
---|---|
DataExistsError
|
if the dictionary has associated files |
DictNotExistsError
|
if the dictionary does not exist |
Source code in src/lhcbdirac_log/providers/database/driver.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
delete_job(job, *, force=False)
Delete a job from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
force |
bool
|
if True, delete the job and its associated files (default is False) |
False
|
Raises:
Type | Description |
---|---|
DataExistsError
|
if the job has associated files and force is False |
Source code in src/lhcbdirac_log/providers/database/driver.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
|
get_all_data_size()
Get the storage size of all files data.
Returns:
Type | Description |
---|---|
int
|
the storage size of all files data |
Source code in src/lhcbdirac_log/providers/database/driver.py
554 555 556 557 558 559 560 561 562 |
|
get_all_dict_size()
Get the storage size of all dictionaries data.
Returns:
Type | Description |
---|---|
int
|
the storage size of all dictionaries data |
Source code in src/lhcbdirac_log/providers/database/driver.py
534 535 536 537 538 539 540 541 542 |
|
get_data_count(job)
Get the number of files in a job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
Returns:
Type | Description |
---|---|
int
|
the number of files in the job |
Source code in src/lhcbdirac_log/providers/database/driver.py
564 565 566 567 568 569 570 571 572 573 574 575 |
|
get_data_size(job, file_name)
Get the size of a file in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
file_name |
str
|
the file name |
required |
Returns:
Type | Description |
---|---|
int | None
|
the size of the file, or None if the file does not exist |
Source code in src/lhcbdirac_log/providers/database/driver.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
|
get_db_size()
Get the storage size of the database file.
Returns:
Type | Description |
---|---|
int
|
the storage size of the database file |
Source code in src/lhcbdirac_log/providers/database/driver.py
577 578 579 580 581 582 583 584 |
|
get_dict_size(dict_name)
Get the storage size of the specified dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dict_name |
str
|
the dictionary name |
required |
Returns:
Type | Description |
---|---|
int
|
the storage size of the specified dictionary |
Source code in src/lhcbdirac_log/providers/database/driver.py
521 522 523 524 525 526 527 528 529 530 531 532 |
|
get_dicts(*, invalid=False)
Get all dictionaries in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
invalid |
bool
|
if True, include invalid dictionaries (default is False) |
False
|
Returns:
Type | Description |
---|---|
set[str]
|
a set of dictionary names |
Notes
- may not be a huge set
Source code in src/lhcbdirac_log/providers/database/driver.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
get_files(job)
Get all files in a job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
Returns:
Type | Description |
---|---|
set[str]
|
a set of file names |
Notes
- may not be a huge set
Source code in src/lhcbdirac_log/providers/database/driver.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
get_invalid_dicts()
Get all invalid dictionaries in the database.
Returns:
Type | Description |
---|---|
set[str]
|
a set of dictionary names |
Notes
- may not be a huge set
Source code in src/lhcbdirac_log/providers/database/driver.py
452 453 454 455 456 457 458 459 460 461 462 |
|
get_job_size(job)
Get the storage size of all files data from a job.
Returns:
Type | Description |
---|---|
int
|
the storage size of all files data from a job |
Source code in src/lhcbdirac_log/providers/database/driver.py
544 545 546 547 548 549 550 551 552 |
|
get_jobs()
Get all jobs in the database.
Returns:
Type | Description |
---|---|
Generator[int, None, None]
|
a generator of job ids |
Source code in src/lhcbdirac_log/providers/database/driver.py
497 498 499 500 501 502 503 504 |
|
load_data(job, file_name)
Load a file from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
file_name |
str
|
the file name |
required |
Returns:
Type | Description |
---|---|
bytes
|
the file data or None if the file does not exist |
Raises:
Type | Description |
---|---|
DataNotExistsError
|
if the file does not exist |
Source code in src/lhcbdirac_log/providers/database/driver.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
load_dict(dict_name)
Load a (non-invalid) dictionary from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dict_name |
str
|
the dictionary name |
required |
Returns:
Type | Description |
---|---|
tuple[bytes, int]
|
a tuple of the dictionary data and its zstd ID |
Raises:
Type | Description |
---|---|
DictNotExistsError
|
if the dictionary does not exist or is invalid |
Source code in src/lhcbdirac_log/providers/database/driver.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
load_job(job)
Load job metadata from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
Returns:
Type | Description |
---|---|
JobInfo
|
the job metadata |
Source code in src/lhcbdirac_log/providers/database/driver.py
261 262 263 264 265 266 267 268 269 270 271 272 |
|
save_data(job, file_name, data)
Save a file to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
file_name |
str
|
the file name |
required |
data |
bytes
|
the data to save |
required |
Raises:
Type | Description |
---|---|
DictNotExistsError
|
if the dictionary does not exist |
Source code in src/lhcbdirac_log/providers/database/driver.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
save_dict(name, data, zstd_id)
Save a dictionary to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the dictionary name |
required |
data |
bytes | None
|
the dictionary data or None for invalid |
required |
zstd_id |
int | None
|
the zstd dictionary id or None for invalid |
required |
Raises:
Type | Description |
---|---|
ValueError
|
if any of the dictionary data or zstd id is None and not the other |
DictExistsError
|
if the (non-invalid) dictionary already exists |
Notes
- overwrites the dictionary if it already exists but is invalid
Source code in src/lhcbdirac_log/providers/database/driver.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
save_invalid_dict(name)
Save an invalid dictionary to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the dictionary name |
required |
Notes
- forwards to save_dict with data=None and zstd_id=None
Source code in src/lhcbdirac_log/providers/database/driver.py
274 275 276 277 278 279 280 281 282 283 |
|
save_job(job, info=None)
Save/overwrite a job to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
int
|
the job id |
required |
info |
JobInfo | None
|
the job metadata (default is None) |
None
|
Source code in src/lhcbdirac_log/providers/database/driver.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
SQLJobEntry
Bases: JobEntry[SQLDataEntry]
SQL Database job entry implementation.
Only supports the new compressed (Zstandard) format.
Source code in src/lhcbdirac_log/providers/database/accessors.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 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 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
|
driver: SQLDriver
property
__init__(driver, job, *, readonly, create=True, exists_ok=True)
[Internal] Initialize the job entry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
driver |
SQLDriver
|
the SQL driver |
required |
job |
int
|
the job id |
required |
readonly |
bool
|
indicate weather the job is read-only or not |
required |
create |
bool
|
if True, create the job (default is True) |
True
|
exists_ok |
bool
|
if True, ignore the error if the data already exists (default is True) |
True
|
Raises:
Type | Description |
---|---|
JobExistsError
|
if the job exists and exists_ok is False |
JobNotExistsError
|
if the job does not exist and create is False |
Notes
- compressed is always True
Source code in src/lhcbdirac_log/providers/database/accessors.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|