publish_predictions_to_core

def publish_predictions_to_core(self):
        """publish_predictions_to_core"""

        status = FAILED
        msg = "not started"

        try:

            msg = "generating request"
            log.info(msg)

            # noqa https://stackoverflow.com/questions/29815129/pandas-dataframe-to-list-of-dictionaries
            publish_req = generate_ai_request(
                predict_rows=self.df.fillna(
                    ANTINEX_MISSING_VALUE).to_dict("records"),
                req_dict=self.request_dict)

            if publish_req["status"] != SUCCESS:
                log.error(("failed generate_ai_request with err={}")
                          .format(
                            publish_req["error"]))
                status = ERROR

            else:

                msg = "publishing as user={} url={} model={}".format(
                    ANTINEX_USER,
                    ANTINEX_URL,
                    ANTINEX_USE_MODEL_NAME)

                log.info(msg)

                response = self.client.run_job(
                    body=publish_req["data"])

                if response["status"] == SUCCESS:
                    log.info("predictions sent")
                    status = SUCCESS
                elif response["status"] == FAILED:
                    log.error(("job failed with error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                elif response["status"] == ERROR:
                    log.error(("job had an error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                elif response["status"] == LOGIN_FAILED:
                    log.error(("job reported user was not able to log in "
                               "with an error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                # logging for good/bad cases during publish
            # if generated a good request
        except Exception as e:
            log.error(("failed generating request last_step='{}' ex={}")
                      .format(
                        msg,
                        e))
        # end of try/ex

        return status