Low-Level API¶
Swarm¶
chime_frb_api.modules.swarm.Swarm
¶
CHIME/FRB Swarm API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
API |
chime_frb_api.core.API Base class handling the actual HTTP requests. |
required |
Source code in chime_frb_api/modules/swarm.py
13 14 15 16 17 18 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 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 |
|
Functions¶
__init__(API)
¶
get_job_status(job_name)
¶
Get job[s] status with a regex match to argument job_name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_name |
str
|
Name of the job |
required |
Returns:
Type | Description |
---|---|
Dict[str, str]
|
{ job_name : STATUS } : dict |
Dict[str, str]
|
Where STATUS can be, |
Dict[str, str]
|
NEW The job was initialized. |
Dict[str, str]
|
PENDING Resources for the job were allocated. |
Dict[str, str]
|
ASSIGNED Docker assigned the job to nodes. |
Dict[str, str]
|
ACCEPTED The job was accepted by a worker node. |
Dict[str, str]
|
PREPARING Docker is preparing the job. |
Dict[str, str]
|
STARTING Docker is starting the job. |
Dict[str, str]
|
RUNNING The job is executing. |
Dict[str, str]
|
COMPLETE The job exited without an error code. |
Dict[str, str]
|
FAILED The job exited with an error code. |
Dict[str, str]
|
SHUTDOWN Docker requested the job to shut down. |
Dict[str, str]
|
REJECTED The worker node rejected the job. |
Dict[str, str]
|
ORPHANED The node was down for too long. |
Dict[str, str]
|
REMOVE The job is not terminal but the associated job was removed |
Source code in chime_frb_api/modules/swarm.py
get_jobs()
¶
Returns the name of all jobs on the analysis cluster.
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of job names. |
get_logs(job_name)
¶
Return logs from a CHIME/FRB Job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_name |
str
|
Unique name for the cluster job |
required |
Returns:
Name | Type | Description |
---|---|---|
job_logs |
Dict[str, str]
|
dict |
Source code in chime_frb_api/modules/swarm.py
jobs_running(job_names)
¶
Monitor job[s] on CHIME/FRB Analysis Cluster.
Monitors job[s] on the CHIME/FRB Analysis Cluster untill they are either COMPLETE, FAILED or SHUTDOWN
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_names |
List[str]
|
A list of string job_name paramerters to monitor |
required |
Source code in chime_frb_api/modules/swarm.py
kill_failed_jobs(job_name=None)
¶
Remove FAILED jobs with a regex match to job_name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_name |
Optional[str]
|
Unique name for the cluster job |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, bool]
|
{job_name : boolean} |
Source code in chime_frb_api/modules/swarm.py
kill_job(job_name)
¶
Remove (forcibly) job with ANY status but with an exact match to job_name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_name |
str
|
Unique name for the cluster job |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, bool]
|
{job_name : boolean} |
Source code in chime_frb_api/modules/swarm.py
monitor_jobs(job_name, error_logs=False)
¶
Continously monitor job[s] on the CHIME/FRB Analysis Cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_name |
str
|
Regular expression matching to the job_name |
required |
error_logs |
bool
|
Print error logs, by default False |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Status of the pipeline |
Source code in chime_frb_api/modules/swarm.py
prune_jobs(job_name)
¶
Remove COMPLETED jobs with a regex match to argument job_name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_name |
str
|
Unique name for the cluster job |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, bool]
|
{job_name : boolean} |
Source code in chime_frb_api/modules/swarm.py
spawn_baseband_job(event_number, task_name, arguments=[], job_id=None, image_name='chimefrb/baseband-localization:latest', command=['baseband_analysis/pipelines/cluster/cluster_cli.py'], job_name=None, job_mem_limit=10 * 1024 ** 3, job_mem_reservation=10 * 1024 ** 3, environment={}, **kwargs)
¶
Spawn a CHIME/FRB Baseband job on the Analysis Cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_number |
int
|
ID of the event to process. |
required |
task_name |
str
|
Name of the task to run. Eg. localization |
required |
arguments |
list
|
Arguments to the command. Default: None. |
[]
|
job_id |
Optional[int]
|
ID of the job to run. Default: None. |
None
|
command |
list
|
The command to be run in the container. Default: cluster_cli.py. |
['baseband_analysis/pipelines/cluster/cluster_cli.py']
|
image_name |
str
|
Name of the container image to spawn the job with Default: chimefrb/baseband-analysis:latest |
'chimefrb/baseband-localization:latest'
|
job_name |
Optional[str]
|
Unique name for the cluster job Default: baseband-EVENT_NUMBER-TASK_NAME-UUID_CODE |
None
|
job_mem_limit |
int
|
Memory limit of the created container in bytes Default: 10 GB |
10 * 1024 ** 3
|
job_mem_reservation |
int
|
Minimum memory reserved of the created container in bytes. Default: 10 GB |
10 * 1024 ** 3
|
environment |
dict
|
ENV variables to pass to the container Default: read authentication tokens from the environment |
{}
|
kwargs |
Additional parameters for spawn_job |
{}
|
Source code in chime_frb_api/modules/swarm.py
spawn_job(image_name, command, arguments, job_name, mount_archiver=True, swarm_network=True, job_mem_limit=4294967296, job_mem_reservation=268435456, job_cpu_limit=1, job_cpu_reservation=1, environment={})
¶
Spawn a job on the CHIME/FRB Analysis Cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_name |
str
|
Name of the container image |
required |
command |
list
|
Command to run in the container |
required |
arguments |
list
|
Arguments to the command |
required |
job_name |
str
|
Unique name for the job |
required |
mount_archiver |
bool
|
Mount Site Data Archivers, by default True |
True
|
swarm_network |
bool
|
Mount Cluster Network, by default True |
True
|
job_mem_limit |
int
|
Memory limit in bytes, by default 4294967296 |
4294967296
|
job_mem_reservation |
int
|
Minimum memory reserved, by default 268435456 |
268435456
|
job_cpu_limit |
float
|
Maximum cpu cores job can use, by default 1 |
1
|
job_cpu_reservation |
float
|
Minimum cores reservers for the job, default 1 |
1
|
environment |
dict
|
ENV to pass to the container, default is {} |
{}
|
Returns:
Type | Description |
---|---|
Dict[str, str]
|
JSON [description] |
Source code in chime_frb_api/modules/swarm.py
Workflow¶
chime_frb_api.workflow.Work
¶
Bases: BaseModel
Work Object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
BaseModel |
BaseModel
|
Pydantic BaseModel. |
required |
Attributes:
Name | Type | Description |
---|---|---|
pipeline |
str
|
Name of the pipeline. (Required) Automatically reformated to hyphen-case. |
site |
str
|
Site where the work will be performed. (Required) |
user |
str
|
User who created the work. (Required) |
function |
Optional[str]
|
Name of the function ran as |
command |
Optional[List[str]]
|
Command to run as |
parameters |
Optional[Dict[str, Any]]
|
Parameters to pass to the function. |
command |
Optional[List[str]]
|
Command to run as |
results |
Optional[Dict[str, Any]]
|
Results of the work. |
products |
Optional[Dict[str, Any]]
|
Products of the work. |
plots |
Optional[Dict[str, Any]]
|
Plots of the work. |
event |
Optional[List[int]]
|
Event ID of the work. |
tags |
Optional[List[str]]
|
Tags of the work. |
timeout |
int
|
Timeout for the work in seconds. Default is 3600 seconds. |
retries |
int
|
Number of retries for the work. Default is 2 retries. |
priority |
int
|
Priority of the work. Default is 3. |
config |
WorkConfig
|
Configuration of the work. |
notify |
Notify
|
Notification configuration of the work. |
id |
str
|
ID of the work. |
creation |
float
|
Creation time of the work. |
start |
float
|
Start time of the work. |
stop |
float
|
Stop time of the work. |
status |
str
|
Status of the work. |
Raises:
Type | Description |
---|---|
ValueError
|
If the work is not valid. |
Returns:
Name | Type | Description |
---|---|---|
Work | Work object. |
Example
Source code in chime_frb_api/workflow/work.py
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 |
|
Attributes¶
payload: Dict[str, Any]
property
¶
Return the dictioanary representation of the work.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The payload of the work. |
Dict[str, Any]
|
Non-instanced attributes are excluded from the payload. |
Classes¶
Config
¶
Functions¶
delete(**kwargs)
¶
Delete work from the buckets backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids |
List[str]
|
List of ids to delete. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if successful, False otherwise. |
Source code in chime_frb_api/workflow/work.py
deposit(return_ids=False, **kwargs)
¶
Deposit work to the buckets backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Dict[str, Any]
|
Keyword arguments for the Buckets API. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Union[bool, List[str]]
|
True if successful, False otherwise. |
Source code in chime_frb_api/workflow/work.py
from_dict(payload)
classmethod
¶
Create a work from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload |
Dict[str, Any]
|
The dictionary. |
required |
Returns:
Name | Type | Description |
---|---|---|
Work |
Work
|
The work. |
from_json(json_str)
classmethod
¶
Create a work from a json string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_str |
str
|
The json string. |
required |
Returns:
Name | Type | Description |
---|---|---|
Work |
Work
|
The work. |
post_init(values)
¶
Initialize work attributes after validation.
Source code in chime_frb_api/workflow/work.py
update(**kwargs)
¶
Update work in the buckets backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Dict[str, Any]
|
Keyword arguments for the Buckets API. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if successful, False otherwise. |
Source code in chime_frb_api/workflow/work.py
withdraw(pipeline, event=None, site=None, priority=None, user=None, **kwargs)
classmethod
¶
Withdraw work from the buckets backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline |
str
|
Name of the pipeline. |
required |
**kwargs |
Dict[str, Any]
|
Keyword arguments for the Buckets API. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Work |
Optional[Work]
|
Work object. |