Skip to content

Commit

Permalink
Merge pull request #27 from ebi-ait/task/delete-errors-every-upload
Browse files Browse the repository at this point in the history
Delete submission errors every attempt to upload
  • Loading branch information
Alegria Aclan authored Aug 13, 2021
2 parents 31fcf99 + 0c8a4db commit 5a4411b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ingest/api/ingestapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ def create_submission_manifest(self, submission_url, data):
def create_submission_error(self, submission_url, data):
return self.create_entity(submission_url, data, 'submissionEnvelopeErrors')

def delete_submission_errors(self, submission_url: str):
r = self.session.delete(f'{submission_url}/submissionErrors')
r.raise_for_status()

def create_entity(self, submission_url, data, entity_type, uuid=None):
params = {}
if uuid:
Expand Down Expand Up @@ -495,4 +499,5 @@ def find_staging_job(self, upload_area_uuid, filename):

@staticmethod
def __get_basic_header():
return {'Content-type': 'application/json'}
return {'Content-type': 'application/json'}

4 changes: 3 additions & 1 deletion ingest/importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from requests import HTTPError

from ingest.api.ingestapi import IngestApi
from ingest.importer.conversion import template_manager
from ingest.importer.conversion.metadata_entity import MetadataEntity
from ingest.importer.conversion.template_manager import TemplateManager
Expand All @@ -26,7 +27,7 @@ class XlsImporter:
for more information on the spreadsheet format.
"""

def __init__(self, ingest_api):
def __init__(self, ingest_api: IngestApi):
self.ingest_api = ingest_api
self.logger = logging.getLogger(__name__)
self.submitter = IngestSubmitter(self.ingest_api)
Expand Down Expand Up @@ -61,6 +62,7 @@ def import_file(self, file_path, submission_url, is_update=False, project_uuid=N
template_mgr = None
spreadsheet_json, template_mgr, errors = self.generate_json(file_path, is_update, project_uuid=project_uuid)
entity_map = EntityMap.load(spreadsheet_json)
self.ingest_api.delete_submission_errors(submission_url)

if errors:
self.report_errors(submission_url, errors)
Expand Down

0 comments on commit 5a4411b

Please sign in to comment.