Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
SlurmExecutorPlugin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EOSC
SlurmExecutorPlugin
Commits
182106d4
Commit
182106d4
authored
Sep 18, 2019
by
mancini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented scheduling workflow
parent
e82bd3ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
16 deletions
+44
-16
lib/slurm_executor/slurm.py
lib/slurm_executor/slurm.py
+44
-16
No files found.
lib/slurm_executor/slurm.py
View file @
182106d4
from
airflow.plugins_manager
import
AirflowPlugin
from
airflow.executors.base_executor
import
BaseExecutor
from
airflow.utils.state
import
State
from
slurm_cli.slurm_control
import
get_jobs_status
import
subprocess
from
slurm_cli.slurm_control
import
get_jobs_status
,
run_job
import
logging
import
uuid
logger
=
logging
.
getLogger
(
__name__
)
def
reindex_job_status_by_job_name
(
job_list
):
return
{
job_status
.
job_name
:
job_status
for
job_status
in
job_list
.
values
()}
# Will show up under airflow.executors.slurm.SlurmExecutor
class
SlurmExecutor
(
BaseExecutor
):
def
__init__
(
self
):
super
().
__init__
()
self
.
commands_to_
run
=
[]
self
.
commands_to_
check
=
{}
def
execute_async
(
self
,
key
,
command
,
queue
=
None
,
executor_config
=
None
):
print
(
"execute async called"
)
self
.
commands_to_run
.
append
((
key
,
command
,
))
def
trigger_tasks
(
self
,
open_slots
):
print
(
'trigger tasks called'
,
open_slots
)
s
uper
().
trigger_tasks
(
open_slots
)
unique_id
=
str
(
key
[
0
])
+
str
(
uuid
.
uuid1
(
))
queue
=
queue
if
queue
!=
'default'
else
None
logging
.
debug
(
'submitting job %s on queue %s'
,
key
,
queue
)
run_job
(
cmd
=
command
,
queue
=
queue
,
task_name
=
unique_id
)
s
elf
.
commands_to_check
[
unique_id
]
=
key
def
sync
(
self
):
for
key
,
command
in
self
.
commands_to_run
:
self
.
log
.
info
(
"Executing command with key %s: %s"
,
key
,
command
)
def
check_state
(
self
):
ids
=
list
(
self
.
commands_to_check
.
keys
())
statuses
=
reindex_job_status_by_job_name
(
get_jobs_status
(
job_name
=
ids
))
logger
.
debug
(
'statuses found are %s'
,
statuses
)
logger
.
debug
(
'commands to check are %s'
,
self
.
commands_to_check
)
try
:
subprocess
.
check_call
(
command
,
close_fds
=
True
)
completed_jobs
=
[]
for
unique_id
,
key
in
self
.
commands_to_check
.
items
():
status
=
statuses
[
unique_id
]
if
status
.
status_code
==
'CD'
:
self
.
change_state
(
key
,
State
.
SUCCESS
)
except
subprocess
.
CalledProcessError
as
e
:
completed_jobs
.
append
(
unique_id
)
elif
status
.
status_code
==
'F'
:
self
.
change_state
(
key
,
State
.
FAILED
)
self
.
log
.
error
(
"Failed to execute task %s."
,
str
(
e
))
completed_jobs
.
append
(
unique_id
)
elif
status
.
status_code
in
(
'CG'
,
'R'
):
self
.
change_state
(
key
,
State
.
RUNNING
)
elif
status
.
status_code
==
'PD'
:
self
.
change_state
(
key
,
State
.
SCHEDULED
)
for
unique_id
in
completed_jobs
:
if
unique_id
in
self
.
commands_to_check
:
self
.
commands_to_check
.
pop
(
unique_id
)
else
:
logger
.
error
(
'id %s missing in %s'
,
unique_id
,
self
.
commands_to_check
)
def
trigger_tasks
(
self
,
open_slots
):
self
.
check_state
()
super
().
trigger_tasks
(
open_slots
)
self
.
commands_to_run
=
[]
def
sync
(
self
):
pass
def
end
(
self
):
self
.
heartbeat
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment