def delete_batch_prediction(self, batch_prediction): """Deletes a batch prediction. """ check_resource_type(batch_prediction, BATCH_PREDICTION_PATH, message="A batch prediction id is needed.") batch_prediction_id = get_batch_prediction_id(batch_prediction) if batch_prediction_id: return self._delete("%s%s" % (self.url, batch_prediction_id))
def update_batch_prediction(self, batch_prediction, changes): """Updates a batch prediction. """ check_resource_type(batch_prediction, BATCH_PREDICTION_PATH, message="A batch prediction id is needed.") batch_prediction_id = get_batch_prediction_id(batch_prediction) if batch_prediction_id: body = json.dumps(changes) return self._update("%s%s" % (self.url, batch_prediction_id), body)
def source_from_batch_prediction(self, batch_prediction, args=None): """Creates a source from a batch prediction using the download url """ check_resource_type(batch_prediction, BATCH_PREDICTION_PATH, message="A batch prediction id is needed.") batch_prediction_id = get_batch_prediction_id(batch_prediction) if batch_prediction_id: download_url = "%s%s%s%s" % (self.url, batch_prediction_id, DOWNLOAD_DIR, self.auth) return self._create_remote_source(download_url, args=args)
def download_batch_prediction(self, batch_prediction, filename=None): """Retrieves the batch predictions file. Downloads predictions, that are stored in a remote CSV file. If a path is given in filename, the contents of the file are downloaded and saved locally. A file-like object is returned otherwise. """ check_resource_type(batch_prediction, BATCH_PREDICTION_PATH, message="A batch prediction id is needed.") batch_prediction_id = get_batch_prediction_id(batch_prediction) if batch_prediction_id: return self._download("%s%s%s" % (self.url, batch_prediction_id, DOWNLOAD_DIR), filename=filename)
def get_batch_prediction(self, batch_prediction): """Retrieves a batch prediction. The batch_prediction parameter should be a string containing the batch_prediction id or the dict returned by create_batch_prediction. As batch_prediction is an evolving object that is processed until it reaches the FINISHED or FAULTY state, the function will return a dict that encloses the batch_prediction values and state info available at the time it is called. """ check_resource_type(batch_prediction, BATCH_PREDICTION_PATH, message="A batch prediction id is needed.") batch_prediction_id = get_batch_prediction_id(batch_prediction) if batch_prediction_id: return self._get("%s%s" % (self.url, batch_prediction_id))