def upload(self, file_path, dataset=None, public=False):
upload_status = self.upload_file(file_path)<EOL>err_msg = '<STR_LIT>'<EOL>if not upload_status.successful:<EOL><INDENT>msg = '<STR_LIT>'.format(err_msg, upload_status.error)<EOL>raise ValueError(msg)<EOL><DEDENT>err_msg = '<STR_LIT>'<EOL>upload_ver_status = self.upload_verify(upload_status.properties.location, dataset)<EOL>if not upload_ver_status.successful:<EOL><INDENT>ver_err = '<STR_LIT:\r\n>'.join(upload_ver_status.errors)<EOL>msg = '<STR_LIT>'.format(err_msg, ver_err)<EOL>raise ValueError(msg)<EOL><DEDENT>ds_upload = definition.DatasetUpload(upload_ver_status, upload_status, dataset, public)<EOL>ds_upload_submit_result = self.upload_submit(ds_upload)<EOL>err_msg = '<STR_LIT>'<EOL>if ds_upload_submit_result.status == '<STR_LIT>':<EOL><INDENT>ver_err = '<STR_LIT:\r\n>'.join(ds_upload_submit_result.errors)<EOL>msg = '<STR_LIT>'.format(err_msg, ver_err)<EOL>raise ValueError(msg)<EOL><DEDENT>ds_upload_result = None<EOL>while True:<EOL><INDENT>ds_upload_result = self.upload_status(ds_upload_submit_result.submit_id)<EOL>if ds_upload_result.status == '<STR_LIT>' or ds_upload_result.status == '<STR_LIT>':<EOL><INDENT>time.sleep(<NUM_LIT:5>)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if ds_upload_result.status != '<STR_LIT>':<EOL><INDENT>ver_err = '<STR_LIT:\r\n>'.join(ds_upload_result.errors)<EOL>msg = '<STR_LIT>'.format(err_msg, ver_err)<EOL>raise ValueError(msg)<EOL><DEDENT>return ds_upload_result.dataset<EOL>
Use this function to upload data to Knoema dataset.