Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SlurmExecutorPlugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EOSC
SlurmExecutorPlugin
Commits
e82bd3ed
Commit
e82bd3ed
authored
5 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
capturing output of srun and check allow the specification of of a list of commands
parent
cf458076
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/slurm_cli/slurm_control.py
+8
-8
8 additions, 8 deletions
lib/slurm_cli/slurm_control.py
with
8 additions
and
8 deletions
lib/slurm_cli/slurm_control.py
+
8
−
8
View file @
e82bd3ed
from
typing
import
List
,
Tuple
,
Union
,
Dict
from
.jobs
import
SlurmJobStatus
from
subprocess
import
run
as
run_process
from
subprocess
import
run
as
__
run_process
__SQUEUE_PATH
=
'
squeue
'
__SRUN_PATH
=
'
srun
'
def
execute_on_shell
(
cmd
,
args
):
process_status
=
run_process
([
cmd
]
+
args
)
def
__
execute_on_shell
(
cmd
,
args
):
process_status
=
__
run_process
([
cmd
]
+
args
,
capture_output
=
True
)
if
process_status
.
returncode
>
0
:
raise
SlurmCallError
()
output
=
process_status
.
stdout
output
=
process_status
.
stdout
.
decode
()
return
output
...
...
@@ -49,7 +49,7 @@ def __compose_get_processes_status_cmd(job_ids: Union[List, Tuple] = (), job_nam
def
__execute_squeue
(
args
):
return
execute_on_shell
(
__SQUEUE_PATH
,
args
)
return
__
execute_on_shell
(
__SQUEUE_PATH
,
args
)
def
__parse_squeue_output
(
squeue_output
)
->
List
[
SlurmJobStatus
]:
...
...
@@ -79,7 +79,7 @@ def __map_job_status_per_jobid(job_status_list: List[SlurmJobStatus]) -> Dict[st
return
{
job_status
.
job_id
:
job_status
for
job_status
in
job_status_list
}
def
get_jobs_status
(
job_ids
:
Union
[
List
,
Tuple
]
=
(),
job_name
:
Union
[
List
,
Tuple
]
=
()):
def
get_jobs_status
(
job_ids
:
Union
[
List
,
Tuple
]
=
(),
job_name
:
Union
[
List
,
Tuple
]
=
())
->
Dict
[
str
,
SlurmJobStatus
]
:
args
=
__compose_get_processes_status_cmd
(
job_ids
,
job_name
)
output
=
__execute_squeue
(
args
)
parsed_output
=
__parse_squeue_output
(
output
)
...
...
@@ -87,7 +87,7 @@ def get_jobs_status(job_ids: Union[List, Tuple] = (), job_name: Union[List, Tupl
def
__execute_srun
(
args
):
return
execute_on_shell
(
__SRUN_PATH
,
args
)
return
__
execute_on_shell
(
__SRUN_PATH
,
args
)
def
__compose_run_job_arguments
(
cmd
,
queue
=
None
,
executor_config
=
None
,
job_name
=
None
):
...
...
@@ -101,7 +101,7 @@ def __compose_run_job_arguments(cmd, queue=None, executor_config=None, job_name=
args
+=
[
'
-J
'
,
job_name
]
else
:
args
+=
[
'
-J
'
,
cmd
]
args
+=
cmd
.
split
(
'
'
)
args
+=
cmd
.
split
(
'
'
)
if
isinstance
(
cmd
,
str
)
else
cmd
return
args
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment