Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that calculation type strings start with 'calculation.job.' prefix #1053

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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