Skip to content

Commit

Permalink
raise error and return None for ParentNotHarvestedException
Browse files Browse the repository at this point in the history
  • Loading branch information
FuhuXia committed Jun 25, 2024
1 parent 3506258 commit ae522b7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions ckanext/datajson/datajson.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,7 @@ def is_part_of_to_package_id(self, ipo, harvest_object):
# we have 0 o bad results
msg = 'Parent identifier not found: "{}"'.format(ipo)
log.error(msg)
try:
harvest_object_error = HarvestObjectError(message=msg, object=harvest_object)
harvest_object_error.save()
harvest_object.state = "ERROR"
harvest_object.save()
except Exception:
pass
raise ParentNotHarvestedException('Unable to find parent dataset. Raising error to allow re-run later')
raise ParentNotHarvestedException('Unable to find parent dataset.')

def import_stage(self, harvest_object):
# The import stage actually creates the dataset.
Expand Down Expand Up @@ -501,7 +494,11 @@ def import_stage(self, harvest_object):

# check if parent is already harvested
parent_identifier = parent_pkg_id.replace('IPO:', '')
parent = self.is_part_of_to_package_id(parent_identifier, harvest_object)
try:
parent = self.is_part_of_to_package_id(parent_identifier, harvest_object)
except ParentNotHarvestedException as e:
self._save_object_error(str(e), harvest_object, 'Import')
return None
parent_pkg_id = parent['id']

if extra.key.startswith('catalog_'):
Expand Down

0 comments on commit ae522b7

Please sign in to comment.