elog
Provides utilities for communicating with the LCLS eLog.
Make use of various eLog API endpoint to retrieve information or post results.
Functions:
Name | Description |
---|---|
get_elog_opr_auth |
str): Return an authorization object to interact with
eLog API as an opr account for the hutch where |
get_elog_kerberos_auth |
Return the authorization headers for the user account submitting the job. |
elog_http_request |
str, request_type: str, **params): Make an HTTP
request to the API endpoint at |
format_file_for_post |
Union[str, tuple, list]): Prepare files according to the specification needed to add them as attachments to eLog posts. |
post_elog_message |
str, msg: str, tag: Optional[str], title: Optional[str], in_files: List[Union[str, tuple, list]], auth: Optional[Union[HTTPBasicAuth, Dict]] = None) Post a message to the eLog. |
post_elog_run_status |
Dict[str, Union[str, int, float]], update_url: Optional[str] = None) Post a run status to the summary section on the Workflows>Control tab. |
post_elog_run_table |
str, run: int, data: Dict[str, Any], auth: Optional[Union[HTTPBasicAuth, Dict]] = None) Update run table in the eLog. |
get_elog_runs_by_tag |
str, tag: str, auth: Optional[Union[HTTPBasicAuth, Dict]] = None) Return a list of runs with a specific tag. |
get_elog_params_by_run |
str, params: List[str], runs: Optional[List[int]]) Retrieve the requested parameters by run. If no run is provided, retrieve the requested parameters for all runs. |
_get_current_run_status(update_url)
Retrieve the current 'counters' or status for a workflow.
This function is intended to be called from the posting function to allow for incremental updates to the status. It will only work for currently running workflows, as it does not go back to the database, only the JID/ARP.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update_url
|
str
|
The JID_UPDATE_COUNTERS url. |
required |
Returns:
Name | Type | Description |
---|---|---|
data |
Dict[str, str]
|
A dictionary of key:value pairs of currently displayed data. |
Source code in lute/io/elog.py
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 |
|
elog_http_request(exp, endpoint, request_type, **params)
Make an HTTP request to the eLog.
This method will determine the proper authorization method and update the passed parameters appropriately. Functions implementing specific endpoint functionality and calling this function should only pass the necessary endpoint-specific parameters and not include the authorization objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp
|
str
|
Experiment. |
required |
endpoint
|
str
|
eLog API endpoint. |
required |
request_type
|
str
|
Type of request to make. Recognized options: POST or GET. |
required |
**params
|
Dict
|
Endpoint parameters to pass with the HTTP request! Differs depending on the API endpoint. Do not include auth objects. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
status_code |
int
|
Response status code. Can be checked for errors. |
msg |
str
|
An error message, or a message saying SUCCESS. |
value |
Optional[Any]
|
For GET requests ONLY, return the requested information. |
Source code in lute/io/elog.py
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 |
|
format_file_for_post(in_file)
Format a file for attachment to an eLog post.
The eLog API expects a specifically formatted tuple when adding file attachments. This function prepares the tuple to specification given a number of different input types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_file
|
str | tuple | list
|
File to include as an attachment in an eLog post. |
required |
Source code in lute/io/elog.py
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 |
|
get_elog_active_expmt(hutch, *, endstation=0)
Get the current active experiment for a hutch.
This function is one of two functions to manage the HTTP request independently.
This is because it does not require an authorization object, and its result
is needed for the generic function elog_http_request
to work properly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hutch
|
str
|
The hutch to get the active experiment for. |
required |
endstation
|
int
|
The hutch endstation to get the experiment for. This should generally be 0. |
0
|
Source code in lute/io/elog.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 |
|
get_elog_auth(exp)
Determine the appropriate auth method depending on experiment state.
Returns:
Name | Type | Description |
---|---|---|
auth |
HTTPBasicAuth | Dict[str, str]
|
Depending on whether an experiment is active/live, returns authorization for the hutch operator account or the current user submitting a job. |
Source code in lute/io/elog.py
182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
get_elog_kerberos_auth()
Returns Kerberos authorization key.
This functions returns authorization for the USER account submitting jobs.
It assumes that kinit
has been run.
Returns:
Name | Type | Description |
---|---|---|
auth |
Dict[str, str]
|
Dictionary containing Kerberos authorization key. |
Source code in lute/io/elog.py
215 216 217 218 219 220 221 222 223 224 225 226 |
|
get_elog_opr_auth(exp)
Produce authentication for the "opr" user associated to an experiment.
This method uses basic authentication using username and password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp
|
str
|
Name of the experiment to produce authentication for. |
required |
Returns:
Name | Type | Description |
---|---|---|
auth |
HTTPBasicAuth
|
HTTPBasicAuth for an active experiment based on username and password for the associated operator account. |
Source code in lute/io/elog.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
get_elog_params_by_run(exp, params, runs=None)
Retrieve requested parameters by run or for all runs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp
|
str
|
Experiment to retrieve parameters for. |
required |
params
|
List[str]
|
A list of parameters to retrieve. These can be any parameter recorded in the eLog (PVs, parameters posted by other Tasks, etc.) |
required |
Source code in lute/io/elog.py
515 516 517 518 519 520 521 522 523 524 525 526 527 |
|
get_elog_runs_by_tag(exp, tag, auth=None)
Retrieve run numbers with a specified tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp
|
str
|
Experiment name. |
required |
tag
|
str
|
The tag to retrieve runs for. |
required |
Source code in lute/io/elog.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
|
get_elog_workflows(exp)
Get the current workflow definitions for an experiment.
Returns:
Name | Type | Description |
---|---|---|
defns |
Dict[str, str]
|
A dictionary of workflow definitions. |
Source code in lute/io/elog.py
71 72 73 74 75 76 77 |
|
post_elog_message(exp, msg, *, tag, title, in_files=[])
Post a new message to the eLog. Inspired by the elog
package.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp
|
str
|
Experiment name. |
required |
msg
|
str
|
BODY of the eLog post. |
required |
tag
|
str | None
|
Optional "tag" to associate with the eLog post. |
required |
title
|
str | None
|
Optional title to include in the eLog post. |
required |
in_files
|
List[str | tuple | list]
|
Files to include as attachments in the eLog post. |
[]
|
Returns:
Name | Type | Description |
---|---|---|
err_msg |
str | None
|
If successful, nothing is returned, otherwise, return an error message. |
Source code in lute/io/elog.py
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 |
|
post_elog_run_status(data, update_url=None)
Post a summary to the status/report section of a specific run.
In contrast to most eLog update/post mechanisms, this function searches for a specific environment variable which contains a specific URL for posting. This is updated every job/run as jobs are submitted by the JID. The URL can optionally be passed to this function if it is known.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Dict[str, Union[str, int, float]]
|
The data to post to the eLog report section. Formatted in key:value pairs. |
required |
update_url
|
Optional[str]
|
Optional update URL. If not provided, the function searches for the corresponding environment variable. If neither is found, the function aborts |
None
|
Source code in lute/io/elog.py
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 |
|
post_elog_run_table(exp, run, data)
Post data for eLog run tables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp
|
str
|
Experiment name. |
required |
run
|
int
|
Run number corresponding to the data being posted. |
required |
data
|
Dict[str, Any]
|
Data to be posted in format data["column_header"] = value. |
required |
Returns:
Name | Type | Description |
---|---|---|
err_msg |
None | str
|
If successful, nothing is returned, otherwise, return an error message. |
Source code in lute/io/elog.py
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 |
|
post_elog_workflow(exp, name, executable, wf_params, *, trigger='run_end', location='S3DF', **trig_args)
Create a new eLog workflow, or update an existing one.
The workflow will run a specific executable as a batch job when the specified trigger occurs. The precise arguments may vary depending on the selected trigger type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
An identifying name for the workflow. E.g. "process data" |
required |
executable
|
str
|
Full path to the executable to be run. |
required |
wf_params
|
str
|
All command-line parameters for the executable as a string. |
required |
trigger
|
str
|
When to trigger execution of the specified executable. One of: - 'manual': Must be manually triggered. No automatic processing. - 'run_start': Execute immediately if a new run begins. - 'run_end': As soon as a run ends. - 'param_is': As soon as a parameter has a specific value for a run. |
'run_end'
|
location
|
str
|
Where to submit the job. S3DF or NERSC. |
'S3DF'
|
**trig_args
|
str
|
Arguments required for a specific trigger type. trigger='param_is' - 2 Arguments trig_param (str): Name of the parameter to watch for. trig_param_val (str): Value the parameter should have to trigger. |
{}
|
Source code in lute/io/elog.py
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 |
|