Jobs Logic
Job-related business logic including submission, querying, status management, and sandboxes.
Job Submission
submission
Attributes
logger = logging.getLogger(__name__)
module-attribute
MAX_PARAMETRIC_JOBS = 20
module-attribute
Classes
JobSubmissionSpec
pydantic-model
Bases: BaseModel
Fields:
-
jdl(str) -
owner(str) -
owner_group(str) -
initial_status(str) -
initial_minor_status(str) -
vo(str)
Source code in diracx-logic/src/diracx/logic/jobs/submission.py
Attributes
jdl
pydantic-field
owner
pydantic-field
owner_group
pydantic-field
initial_status
pydantic-field
initial_minor_status
pydantic-field
vo
pydantic-field
Functions
submit_jdl_jobs(job_definitions, job_db, job_logging_db, user_info, config)
async
Submit a list of JDLs to the JobDB.
Source code in diracx-logic/src/diracx/logic/jobs/submission.py
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 | |
create_jdl_jobs(jobs, job_db, config)
async
Create jobs from JDLs and insert them into the DB.
Source code in diracx-logic/src/diracx/logic/jobs/submission.py
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 | |
Job Query
query
Attributes
logger = logging.getLogger(__name__)
module-attribute
MAX_PER_PAGE = 10000
module-attribute
Classes
Functions
search(config, job_db, job_parameters_db, job_logging_db, preferred_username, vo, page=1, per_page=100, body=None)
async
Retrieve information about jobs.
Source code in diracx-logic/src/diracx/logic/jobs/query.py
summary(config, job_db, preferred_username, vo, body)
async
Show information suitable for plotting.
Source code in diracx-logic/src/diracx/logic/jobs/query.py
Job Status
status
Attributes
logger = logging.getLogger(__name__)
module-attribute
JOB_ATTRIBUTES_ALIASES = {(field.alias): field_namefor (field_name, field) in (JobAttributes.model_fields.items()) if field.alias}
module-attribute
JOB_PARAMETERS_ALIASES = {(field.alias): field_namefor (field_name, field) in (JobParameters.model_fields.items()) if field.alias}
module-attribute
Classes
Functions
remove_jobs(job_ids, config, job_db, job_logging_db, sandbox_metadata_db, task_queue_db)
async
Fully remove a list of jobs from the WMS databases.
Source code in diracx-logic/src/diracx/logic/jobs/status.py
set_job_statuses(status_changes, config, job_db, job_logging_db, task_queue_db, job_parameters_db, force=False, additional_attributes={})
async
Set various status fields for job specified by its jobId. Set only the last status in the JobDB, updating all the status logging information in the JobLoggingDB. The status dict has datetime as a key and status information dictionary as values.
:raises: JobNotFound if the job is not found in one of the DBs
Source code in diracx-logic/src/diracx/logic/jobs/status.py
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 | |
reschedule_jobs(job_ids, config, job_db, job_logging_db, task_queue_db, job_parameters_db, reset_jobs=False)
async
Reschedule given job.
Source code in diracx-logic/src/diracx/logic/jobs/status.py
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 | |
remove_jobs_from_task_queue(job_ids, config, task_queue_db)
async
Remove the job from TaskQueueDB.
Source code in diracx-logic/src/diracx/logic/jobs/status.py
set_job_parameters_or_attributes(updates, job_db, job_parameters_db)
async
Set job parameters or attributes for a list of jobs.
Source code in diracx-logic/src/diracx/logic/jobs/status.py
add_heartbeat(data, config, job_db, job_logging_db, task_queue_db, job_parameters_db)
async
Send a heart beat sign of life for a job jobID.
Source code in diracx-logic/src/diracx/logic/jobs/status.py
get_job_commands(job_ids, job_db)
async
Get the pending job commands for a list of job IDs.
This function automatically marks the commands as "Sent" in the database.
Source code in diracx-logic/src/diracx/logic/jobs/status.py
Job Sandboxes
sandboxes
Attributes
MAX_SANDBOX_SIZE_BYTES = 100 * 1024 * 1024
module-attribute
SANDBOX_PFN_REGEX = '^(:?SB:[A-Za-z]+\\|)?/S3/[a-z0-9\\.\\-]{3,63}(?:/[^/]+){3}/[a-z0-9]{3,10}:[0-9a-f]{64}\\.[a-z0-9\\.]+$'
module-attribute
logger = logging.getLogger(__name__)
module-attribute
Classes
Functions
initiate_sandbox_upload(user_info, sandbox_info, sandbox_metadata_db, settings)
async
Get the PFN for the given sandbox, initiate an upload as required.
If the sandbox already exists in the database then the PFN is returned and there is no "url" field in the response.
If the sandbox does not exist in the database then the "url" and "fields" should be used to upload the sandbox to the storage backend.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
get_sandbox_file(pfn, sandbox_metadata_db, settings)
async
Get a presigned URL to download a sandbox file.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
get_job_sandboxes(job_id, sandbox_metadata_db)
async
Get input and output sandboxes of given job.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
get_job_sandbox(job_id, sandbox_metadata_db, sandbox_type)
async
Get input or output sandbox of given job.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
assign_sandbox_to_job(job_id, pfn, sandbox_metadata_db, settings)
async
Map the pfn as output sandbox to job.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
unassign_jobs_sandboxes(jobs_ids, sandbox_metadata_db)
async
Delete bulk jobs sandbox mapping.
pfn_to_key(pfn)
Convert a PFN to a key for S3.
This removes the leading "/S3/
insert_sandbox(sandbox_metadata_db, se_name, user, pfn, size)
async
Add a new sandbox in SandboxMetadataDB.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
clean_sandboxes(sandbox_metadata_db, settings, *, limit=10000, max_concurrent_batches=10)
async
Delete sandboxes that are not assigned to any job.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
delete_batch_and_log(settings, objects, semaphore)
async
Helper function to delete a batch of objects and log the result.
Source code in diracx-logic/src/diracx/logic/jobs/sandboxes.py
Job Utilities
utils
Classes
Functions
make_job_manifest_config(config, vo)
Create job manifest configuration for DIRACCommon functions from diracx config.
Source code in diracx-logic/src/diracx/logic/jobs/utils.py
make_check_and_prepare_job_config(config, vo)
Create checkAndPrepareJob configuration for DIRACCommon functions from diracx config.
Source code in diracx-logic/src/diracx/logic/jobs/utils.py
check_and_prepare_job(job_id, class_ad_job, class_ad_req, owner, owner_group, job_attrs, vo, job_db, config)
async
Check Consistency of Submitted JDL and set some defaults Prepare subJDL with Job Requirements.