def update_jobs_created(): jobs_created = job_manager.get_jobs_by_status("CREATED") for job in jobs_created: tasks_log.info("Found new job") job.status_id = job_manager.get_job_status_id("IN_PROGRESS") db.commit() email_manager.send_job_created_email(job)
def get_or_create_user(email_address, iam_username=DEFAULT_IAM_USER): user = User.query.filter_by(email=email_address).first() if user is None: user = User(email_address, iam_username) db.add(user) db.commit() return user
def create_job(user, data): plugin_name = data['plugin']['name'] method = data['plugin']['method'] settings = data['plugin']['settings'] output_file_suffix = get_output_file_suffix(plugin_name, settings) channel = data['plugin']['settings']['params']['channel'] job = Job(user.id, 1, data['outputDir'], plugin_name, method, channel, output_file_suffix) db.add(job) db.commit() job_item_queue = sqs.get_queue(SQS_JOB_ITEMS_QUEUE) for f in data['filenames']: job_item_doc = job_item_manager.build_job_item_doc(job, f) job_item_manager.store_job_item_doc(job_item_doc) job_item_manager.add_job_item_to_queue(job_item_doc.job_item_key, job_item_queue) return job.job_id
def update_jobs_in_progress(): jobs_in_progress = job_manager.get_jobs_by_status("IN_PROGRESS") for job in jobs_in_progress: job_items = job_manager.get_job_items(job.job_id) complete = True has_error = False for job_item in job_items: if job_item['job_item_status'] in ['ERROR','TIMEOUT']: has_error = True elif job_item['job_item_status'] in ['CREATED', 'IN_PROGRESS']: complete = False break if complete: if has_error: job.status_id = job_manager.get_job_status_id("COMPLETE_WITH_ERRORS") else: job.status_id = job_manager.get_job_status_id("COMPLETE") db.commit() email_manager.send_job_complete_email(job)
def update_jobs_in_progress(): jobs_in_progress = job_manager.get_jobs_by_status("IN_PROGRESS") for job in jobs_in_progress: job_items = job_manager.get_job_items(job.job_id) complete = True has_error = False for job_item in job_items: if job_item['job_item_status'] in ['ERROR', 'TIMEOUT']: has_error = True elif job_item['job_item_status'] in ['CREATED', 'IN_PROGRESS']: complete = False break if complete: if has_error: job.status_id = job_manager.get_job_status_id( "COMPLETE_WITH_ERRORS") else: job.status_id = job_manager.get_job_status_id("COMPLETE") db.commit() email_manager.send_job_complete_email(job)