-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pause running workflows when stopping beeflow with 'beeflow core stop' (
#830) * Handles active workflows for 'beeflow core stop' - Pause running workflows when stopping beeflow with 'beeflow core stop' - Add info about stoping beeflow to documentation - Set workflow state to Running when 'beeflow resume <wf_id>' command is issued - Display beeflow version when starting core - Add job updates for tasks job to log - Add final job status check with sacct command when state cannot be found otherwise - Handle bad job IDs --------- Co-authored-by: Jake Tronge <jtronge@lanl.gov>
- Loading branch information
Showing
9 changed files
with
88 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Worker utility functions.""" | ||
|
||
import subprocess | ||
from beeflow.common.worker.worker import WorkerError | ||
|
||
|
||
def get_state_sacct(job_id): | ||
"""Get state from slurm using sacct command, used when other means fail.""" | ||
try: | ||
resp = subprocess.run(['sacct', '--parsable', '-j', str(job_id)], text=True, check=True, | ||
stdout=subprocess.PIPE) | ||
data = resp.stdout.splitlines() | ||
header, info = data | ||
header = header.split('|') | ||
info = info.split('|') | ||
state_idx = header.index('State') | ||
return info[state_idx] | ||
except (subprocess.CalledProcessError, ValueError, KeyError) as exc: | ||
raise WorkerError(f'sacct query failed for job {job_id}') from exc | ||
|
||
|
||
def parse_key_val(pair): | ||
"""Parse the key-value pair separated by '='.""" | ||
i = pair.find('=') | ||
return (pair[:i], pair[i + 1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters