Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ChEMBL
C
ChEMBL
Delayed Jobs
Delayed Jobs API
Commits
951d923e
Commit
951d923e
authored
Apr 01, 2021
by
David Mendez
Browse files
Status Daemon: require job id to be run
parent
a3296a09
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
9 deletions
+19
-9
app/job_status_daemon/daemon.py
app/job_status_daemon/daemon.py
+1
-1
app/job_status_daemon/run_daemon.py
app/job_status_daemon/run_daemon.py
+14
-4
app/job_status_daemon/test/test_status_daemon.py
app/job_status_daemon/test/test_status_daemon.py
+3
-3
functional_tests/run_functional_tests.py
functional_tests/run_functional_tests.py
+1
-1
No files found.
app/job_status_daemon/daemon.py
View file @
951d923e
...
...
@@ -35,7 +35,7 @@ print(f'AGENT_RUN_DIR: {AGENT_RUN_DIR}')
print
(
'------------------------------------------------------------------------------'
)
def
check_job
s
_status
(
job_id
,
delete_lock_after_finishing
=
True
):
def
check_job_status
(
job_id
,
delete_lock_after_finishing
=
True
):
"""
The main function of this module. Checks for jobs to check the status, and checks their status in lsf
:param job_id: job id to check
...
...
app/job_status_daemon/run_daemon.py
View file @
951d923e
...
...
@@ -3,17 +3,27 @@
Script that runs the daemon that checks for the job status
"""
import
time
import
argparse
from
app.job_status_daemon
import
daemon
from
app
import
create_app
from
app.models
import
delayed_job_models
PARSER
=
argparse
.
ArgumentParser
()
PARSER
.
add_argument
(
'job_id'
,
help
=
'id of the job to check'
)
ARGS
=
PARSER
.
parse_args
()
def
run
():
def
run
():
flask_app
=
create_app
()
job_id
=
ARGS
.
job_id
with
flask_app
.
app_context
():
while
True
:
sleep_time
,
jobs_were_checked
=
daemon
.
check_jobs_status
()
job
=
delayed_job_models
.
get_job_by_id
(
job_id
,
force_refresh
=
True
)
while
job
.
needs_to_be_checked_in_lsf
():
sleep_time
,
jobs_were_checked
=
daemon
.
check_job_status
()
time
.
sleep
(
sleep_time
)
job
=
delayed_job_models
.
get_job_by_id
(
job_id
,
force_refresh
=
True
)
if
__name__
==
"__main__"
:
run
()
\ No newline at end of file
run
()
app/job_status_daemon/test/test_status_daemon.py
View file @
951d923e
...
...
@@ -374,7 +374,7 @@ class TestJobStatusDaemon(unittest.TestCase):
job_id_to_check
=
f
'Job-
{
lsf_host
}
-
{
delayed_job_models
.
JobStatuses
.
QUEUED
}
'
with
self
.
flask_app
.
app_context
():
daemon
.
check_job
s
_status
(
job_id
=
job_id_to_check
,
delete_lock_after_finishing
=
False
)
daemon
.
check_job_status
(
job_id
=
job_id_to_check
,
delete_lock_after_finishing
=
False
)
current_lsf_host
=
RUN_CONFIG
.
get
(
'lsf_submission'
).
get
(
'lsf_host'
)
lock_hostname_got
=
locks
.
get_lock_for_job
(
job_id_to_check
)
...
...
@@ -396,7 +396,7 @@ class TestJobStatusDaemon(unittest.TestCase):
with
self
.
flask_app
.
app_context
():
locks
.
set_lock_for_job
(
job_id_to_check
,
'another_owner'
)
sleep_time_got
,
jobs_were_checked
=
daemon
.
check_job
s
_status
(
job_id_to_check
)
sleep_time_got
,
jobs_were_checked
=
daemon
.
check_job_status
(
job_id_to_check
)
self
.
assertFalse
(
jobs_were_checked
,
msg
=
'The jobs should have not been checked'
)
sleep_time
=
RUN_CONFIG
.
get
(
'status_agent'
).
get
(
'sleep_time'
)
...
...
@@ -415,7 +415,7 @@ class TestJobStatusDaemon(unittest.TestCase):
job_id_to_check
=
f
'Job-
{
lsf_host
}
-
{
delayed_job_models
.
JobStatuses
.
QUEUED
}
'
with
self
.
flask_app
.
app_context
():
daemon
.
check_job
s
_status
(
job_id_to_check
)
daemon
.
check_job_status
(
job_id_to_check
)
lock_got
=
locks
.
get_lock_for_job
(
job_id_to_check
)
self
.
assertIsNone
(
lock_got
,
msg
=
'The LSF lock was not deleted!'
)
functional_tests/run_functional_tests.py
View file @
951d923e
...
...
@@ -26,8 +26,8 @@ def run():
for
test_module
in
[
func_test_successful_job_run
,
func_test_job_cache
,
func_test_parallel_job_submission
,
func_test_failing_job
]:
test_module
.
run_test
(
ARGS
.
server_base_path
,
ARGS
.
admin_username
,
ARGS
.
admin_password
)
if
__name__
==
"__main__"
:
run
()
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