Skip to content
Snippets Groups Projects
Commit e8ea7d2f authored by Megan Henning's avatar Megan Henning Committed by GitHub
Browse files

Merge pull request #577 from scitran/upgrade-robust

Log & discard malformed gears during v18 upgrade
parents d4755240 8e928fbd
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,7 @@ def eval_match(match_type, match_param, file_, container):
# Match the container having any file (including this one) with this type
elif match_type == 'container.has-type':
for c_file in container['files']:
if match_param == c_file['type']:
if match_param == c_file.get('type'):
return True
return False
......
......@@ -494,7 +494,15 @@ def upgrade_to_18():
if gear_doc is not None:
gear_list = gear_doc.get('gear_list', [])
for gear in gear_list:
gears.upsert_gear(gear)
try:
gears.upsert_gear(gear)
except Exception as e:
logging.error("")
logging.error("Error upgrading gear:")
logging.error(type(e))
logging.error("Gear will not be retained. Document follows:")
logging.error(gear)
logging.error("")
config.db.singletons.remove({"_id": "gears"})
......
......@@ -95,8 +95,8 @@ def test_eval_match_container_measurement():
def test_eval_match_container_has_type():
part = rulePart(match_type='container.has-type', container={'files': [
{'measurements': ['a', 'diffusion', 'b']},
{'measurements': ['c', 'other', 'b']},
{'type': 'diffusion'},
{'type': 'other'},
]})
args = part.gen(match_param='other')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment