Commit 951d923e authored by David Mendez's avatar David Mendez
Browse files

Status Daemon: require job id to be run

parent a3296a09
......@@ -35,7 +35,7 @@ print(f'AGENT_RUN_DIR: {AGENT_RUN_DIR}')
print('------------------------------------------------------------------------------')
def check_jobs_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
......
......@@ -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()
......@@ -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_jobs_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_jobs_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_jobs_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!')
......@@ -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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment