Skip to content

Remove get_aiida_class#2309

Merged
sphuber merged 2 commits into
provenance_redesignfrom
issue_2237_rebased2
Dec 7, 2018
Merged

Remove get_aiida_class#2309
sphuber merged 2 commits into
provenance_redesignfrom
issue_2237_rebased2

Conversation

@muhrin
Copy link
Copy Markdown
Contributor

@muhrin muhrin commented Dec 6, 2018

Fixes #2237

This is part of the procedure that @szoupanos is leading to convert to automatically generated dummy models for the QueryBuilder

Replaced all instances with either get_backend_entity or get_orm_entity
(as appropriate).

Also changed backend group to be independent of the ORM. Because the
iterator was getting the orm class and returning that (which required it
to access up to the ORM level). Now it just returns backend entities
which are in turn converted to ORM entities by the orm.Group. This also
means you can't call len(group.nodes) because this is not allowed for
iterators but the same can be achieved with len(list(group.nodes)).

Removal of get_aiida_class from QueryBuilder and addition of
DbModel-to-BackendEntity and BackendEntity-to-OrmEntity convertors.

@muhrin muhrin requested a review from sphuber December 6, 2018 14:48
@muhrin muhrin changed the title Issue 2237 Fixes issue 2237 Dec 6, 2018
@sphuber sphuber changed the title Fixes issue 2237 Remove get_aiida_class Dec 6, 2018
@muhrin muhrin force-pushed the issue_2237_rebased2 branch from 88547ac to 71ce801 Compare December 6, 2018 17:02
@sphuber sphuber force-pushed the issue_2237_rebased2 branch from 71ce801 to 4ddda92 Compare December 6, 2018 17:49
Copy link
Copy Markdown
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few places with dead code, but good otherwise

Comment thread aiida/orm/implementation/sqlalchemy/querybuilder.py Outdated
Comment thread aiida/orm/implementation/sqlalchemy/workflow.py Outdated
Comment thread aiida/orm/querybuilder.py Outdated
Comment thread aiida/orm/querybuilder.py Outdated
@sphuber sphuber force-pushed the issue_2237_rebased2 branch from 4ddda92 to 0e74729 Compare December 7, 2018 08:48
sphuber
sphuber previously approved these changes Dec 7, 2018
Comment thread aiida/orm/convert.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to replace this with self._dbmodel.dbnodes.all().iterator() for lazy loading also while looping with iter and next, see
see also here http://blog.etianen.com/blog/2013/06/08/django-querysets/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but we can't call count() on the iterator so I only use the iterator in the actually iteration code.

Comment thread aiida/orm/groups.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a custom Iterator class as it is done in the Backend classes to have len pipe through the .count() method of the ORM, for efficiency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread aiida/cmdline/commands/cmd_group.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go back to len(group.nodes) once the suggested fix for len is in place, for efficiency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@muhrin muhrin force-pushed the issue_2237_rebased2 branch 3 times, most recently from 86ef75d to 9693d45 Compare December 7, 2018 13:24
giovannipizzi
giovannipizzi previously approved these changes Dec 7, 2018
szoupanos and others added 2 commits December 7, 2018 19:12
Added convertors to go from a DbModel BackendEntity and from
BackendEntity to OrmEntity.
Replaced all instances with either `get_backend_entity` or `get_orm_entity`
(as appropriate).

Also changed backend group to be independent of the ORM.  Because the
iterator was getting the ORM class and returning that, which required it
to access up to the ORM level.  Now it just returns backend entities
which are in turn converted to ORM entities by the `orm.Group`.  This also
means you can't call `len(group.nodes)` because this is not allowed for
iterators but the same can be achieved with `len(list(group.nodes))`
@sphuber sphuber merged commit a6bbe32 into provenance_redesign Dec 7, 2018
@sphuber sphuber deleted the issue_2237_rebased2 branch December 7, 2018 18:58
@coveralls
Copy link
Copy Markdown

coveralls commented Dec 8, 2018

Coverage Status

Coverage increased (+0.01%) to 68.942% when pulling 1a9c869 on issue_2237_rebased2 into 05fae57 on provenance_redesign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants