def change_publish_status(): ''' uncache model if their last date of access more than 60 days. ''' try: manager = ProjectManager() query = {} data = manager.find_all_model(query) for document in data: try: ner_status= get(document,'ner.status',"new") ir_status= get(document,'ir.status',"new") print(ner_status, ir_status) serviceid= document['serviceid'] if ner_status=="published" and ir_status=="published": ner_status='trained' ir_status = 'trained' print('condition1') elif ner_status=="published" and ir_status!="published": ner_status = 'trained' print('condition2') elif ir_status=="published" and ner_status!="published": ir_status = 'trained' print('condition3') manager.update_ir_ner_status(serviceid, ner_status, ir_status) except Exception as e: print("exception : ",e) except Exception as e: print("exception : ",e)
def uncache_project_if_exists(): ''' uncache model if their last date of access more than X days. ''' try: manager = ProjectManager() query = {} data = manager.find_all_model(query) for document in data: try: serviceid = document['serviceid'] last_accessed = document['lastAccessed'] days_diff = datetime.today() - timedelta( days=int(app_config['MINIO_DAYS'])) ner_status = document['ner']['status'] ir_status = document['ir']['status'] if last_accessed < days_diff and ner_status in [ 'trained', 'validated' ] and ir_status in ['trained', 'validated']: logger.info("removal process starts") requests.post( url="http://localhost:8021/api/parse/cache/remove", json={'serviceid': serviceid}, headers={'Content-type': 'application/json'}) logger.info( "Model with service id: %s is removed from minio cache since it was last accessed 90 " "days back. Please retrain." % serviceid) except Exception as ex: logger.exception(ex, exc_info=True) logger.error(traceback.format_exc()) description = 'Internal Server Error, Please try again later' raise falcon.HTTPServiceUnavailable('Service Outage', description, 30) except Exception as ex: logger.exception(ex, exc_info=True) logger.error(traceback.format_exc()) description = 'Internal Server Error, Please try again later' raise falcon.HTTPServiceUnavailable('Service Outage', description, 30)