Exemple #1
0
def sam_run(self, jobID, inputs):
    if sam_run.request.id is not None:
        task_id = sam_run.request.id
    else:
        task_id = jobID
    logging.info("SAM CELERY task id: {}".format(task_id))
    logging.info("SAM CELERY task starting...")
    inputs["csrfmiddlewaretoken"] = {"0": task_id}
    data = rest_model_caller.model_run("sam", task_id, inputs, module=sam)
    logging.info("SAM CELERY task completed.")
    logging.info("Dumping SAM data into database...")
    mongo_db = connect_to_mongoDB()
    posts = mongo_db.posts
    time_stamp = datetime.utcnow()
    data = {
        '_id': task_id,
        'date': time_stamp,
        'data': json.dumps(data['outputs'])
    }
    posts.insert_one(data)
    logging.info("Completed SAM data db dump.")
    postprocessor = SamPostprocessor(task_id)
    print("Post-processor: fetching sam run data to process")
    postprocessor.get_sam_data()
    print("Post-processor: calculating HUC8 and HUC12 summary stats")
    postprocessor.calc_huc_summary()
    print("Post-processor: appending summary data to database record")
    postprocessor.append_sam_data()
    logging.info("Post-processor: complete")
Exemple #2
0
 def post(self, jobId="000000100000011"):
     """
     SIP post handler.
     :param jobId:
     :return:
     """
     inputs = rest_validation.parse_inputs(request.json)
     print("ScreenipPost")
     if inputs:
         return rest_model_caller.model_run(self.name, jobId, inputs, module=screenip)
     else:
         return rest_model_caller.error(self.name, jobId, inputs)
Exemple #3
0
    def post(self, jobId="000000100000011"):
        """
        Exponential post handler.
        :param jobId:
        :return:
        """
        inputs = rest_validation.parse_inputs(request.json)

        if inputs:
            return rest_model_caller.model_run(self.name, jobId, inputs, module=exponential)
        else:
            return rest_model_caller.error(self.name, jobId, inputs)
Exemple #4
0
    def post(self, jobId="000000100000011"):
        """
        Varroapop post handler.
        :param jobId:
        :return:
        """
        inputs = rest_validation.parse_inputs(request.json)

        if inputs:
            data = rest_model_caller.model_run(self.name, jobId, inputs, module=varroapop)
            return jsonify(**data)
        else:
            return rest_model_caller.error(self.name, jobId, inputs)
Exemple #5
0
    def post(self, jobId="000000100000011"):
        """
        LeslieProbit post handler.
        :param jobId:
        :return:
        """
        inputs = rest_validation.parse_inputs(request.json)

        if inputs:
            return rest_model_caller.model_run(self.name,
                                               jobId,
                                               inputs,
                                               module=leslie_probit)
        else:
            return rest_model_caller.error(self.name, jobId, inputs)
Exemple #6
0
    def post(self, jobId="000000100000011"):
        """
        Agdrift post handler.
        :param jobId:
        :return:
        """

        inputs = rest_validation.parse_inputs(request.json)


        if inputs:
            data = rest_model_caller.model_run(self.name, jobId, inputs, module=agdrift)
            mongo_db_dict = {"jobid": jobId, "inputs": inputs, "outputs": data}
            self.insert_into_db(mongo_db_dict)

            return jsonify(**data)
        else:
            return rest_model_caller.error(self.name, jobId, inputs)