Skip to content

Commit

Permalink
Merge pull request #1053 from sphuber/fix_verdi_calculation_list_type…
Browse files Browse the repository at this point in the history
…_string

Check that calculation type strings start with 'calculation.job.' prefix
  • Loading branch information
sphuber authored Jan 17, 2018
2 parents ec93d99 + ce866db commit ecdee80
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions aiida/orm/implementation/general/calculation/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,9 +1089,19 @@ def _get_calculation_info_row(cls, res, projections, times_since=None):
d = copy.deepcopy(res)

try:
d['calculation']['type'] = from_type_to_pluginclassname(
d['calculation']['type']
).rsplit(".", 1)[0].lstrip('calculation.job.')
prefix = 'calculation.job.'
calculation_type = d['calculation']['type']
calculation_class = from_type_to_pluginclassname(calculation_type)
module, class_name = calculation_class.rsplit('.', 1)

# For the base class 'calculation.job.JobCalculation' the module at this point equals 'calculation.job'
# For this case we should simply set the type to the base module calculation.job. Otherwise we need
# to strip the prefix to get the proper sub module
if module == prefix.rstrip('.'):
d['calculation']['type'] = module[len(prefix):]
else:
assert module.startswith(prefix), "module '{}' does not start with '{}'".format(module, prefix)
d['calculation']['type'] = module[len(prefix):]
except KeyError:
pass
for proj in ('ctime', 'mtime'):
Expand Down

0 comments on commit ecdee80

Please sign in to comment.