Skip to content

Commit

Permalink
Special check for 'calculation.job.JobCalculation' in _get_calculatio…
Browse files Browse the repository at this point in the history
…n_info_row

Calculations of the base class JobCalculation will have the class name string
'calculation.job.JobCalculation'. In the _get_calculation_info_row method
the module will therefore be, after the rsplit on the class name, like

    calculation.job

this does not include a period on the end like non base modules would have.
In this exceptional case, the calculation type that is to be returned should
simply be the 'calculation.job' base module
  • Loading branch information
sphuber committed Jan 17, 2018
1 parent 3dd0bc6 commit ce866db
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions aiida/orm/implementation/general/calculation/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,9 +1094,14 @@ def _get_calculation_info_row(cls, res, projections, times_since=None):
calculation_class = from_type_to_pluginclassname(calculation_type)
module, class_name = calculation_class.rsplit('.', 1)

assert(module.startswith(prefix))

d['calculation']['type'] = module[len(prefix):]
# 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 ce866db

Please sign in to comment.