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

Various features and fixes related to Group subclassing and Group in the CLI #3926

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Apr 12, 2020

Fixes #3925

This PR comprises four commits:

  1. Fix a bug in QueryBuilder that was introduced recently by added Group subclassing support
  2. Deprecate --group-type for --type-string which provides querying with subclassing
  3. Add support for subclassing to GroupParamType CLI type
  4. Add auto-complete support for Code and Group instance options and arguments

@codecov
Copy link

codecov bot commented Apr 12, 2020

Codecov Report

Merging #3926 into develop will increase coverage by 0.01%.
The diff coverage is 87.69%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3926      +/-   ##
===========================================
+ Coverage    78.22%   78.23%   +0.01%     
===========================================
  Files          461      461              
  Lines        34050    34073      +23     
===========================================
+ Hits         26634    26656      +22     
- Misses        7416     7417       +1     
Flag Coverage Δ
#django 70.27% <87.69%> (+0.01%) ⬆️
#sqlalchemy 71.12% <87.69%> (+0.01%) ⬆️
Impacted Files Coverage Δ
aiida/cmdline/params/types/choice.py 73.07% <ø> (ø)
aiida/cmdline/commands/cmd_group.py 87.77% <80.00%> (-1.73%) ⬇️
aiida/cmdline/params/types/code.py 100.00% <100.00%> (ø)
aiida/cmdline/params/types/group.py 100.00% <100.00%> (+4.76%) ⬆️
aiida/orm/querybuilder.py 79.93% <100.00%> (+0.02%) ⬆️
aiida/orm/utils/loaders.py 86.04% <100.00%> (+1.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2c28ce...35ce7b8. Read the comment docs.

@sphuber sphuber force-pushed the feature/3925/group-param-type-subclassing branch from 0ae0f86 to 0d79091 Compare April 12, 2020 21:08
Copy link
Contributor

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Cheers @sphuber !

Some, hopefully, helpful comments.

aiida/cmdline/commands/cmd_group.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_group.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_group.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_group.py Show resolved Hide resolved
aiida/cmdline/commands/cmd_group.py Show resolved Hide resolved
tests/cmdline/params/types/test_group.py Show resolved Hide resolved
tests/cmdline/params/types/test_group.py Show resolved Hide resolved
tests/cmdline/params/types/test_group.py Show resolved Hide resolved
tests/cmdline/params/types/test_group.py Show resolved Hide resolved
tests/cmdline/params/types/test_group.py Show resolved Hide resolved
The recent addition of support for subclassing of `Group` entities to
the `QueryBuilder` introduced a bug when joining a tuple of entities to
an appended `Group` clause, e.g.:

    builder = QueryBuilder().append(Group, tag='group)
    builder.append((orm.Float, orm.Int), with_group='group')

This would cause an exception in `QueryBuilder._get_connecting_node`
that would assume that `self._path[index]['entity_type']` would always
be a string, but it can be a tuple as well.
@sphuber sphuber force-pushed the feature/3925/group-param-type-subclassing branch from 0d79091 to b925885 Compare April 14, 2020 13:08
@sphuber
Copy link
Contributor Author

sphuber commented Apr 14, 2020

@CasperWA thanks for the review. There is just two points open. I prefer to keep the unused variables just for consistency's sake, is that ok? And your first suggestion I did not understand. Not sure which option you were suggesting of being generalized.

@CasperWA
Copy link
Contributor

@CasperWA thanks for the review. There is just two points open. I prefer to keep the unused variables just for consistency's sake, is that ok? And your first suggestion I did not understand. Not sure which option you were suggesting of being generalized.

See my comments where applicable above.

@sphuber sphuber force-pushed the feature/3925/group-param-type-subclassing branch 2 times, most recently from 34980b7 to 57cacbe Compare April 14, 2020 14:21
@sphuber sphuber requested a review from CasperWA April 14, 2020 15:00
Copy link
Contributor

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

A minor fix is needed in an informational text. Otherwise look great, thanks @sphuber !

aiida/cmdline/commands/cmd_group.py Outdated Show resolved Hide resolved
The `--group-type` option in `verdi group list` and `verdi group path ls`
has been deprecated and superseded with `-T/--type-string`. The recently
added support for subclassing of the `Group` ORM class has made it
interesting to be able to query for specific subclasses based on the
type strings of groups. Since these can be hierarchical it is useful to
support the inclusion of SQL wildcards `%` and `_` to perform like instead
of exact matching.

Note that this new functionality of filtering is only available for
`verdi group list` and not for `verdi group path ls`, as the `GroupPath`
utility does not support subclassing yet.
This will allow options and arguments that are supposed to match `Group`
instance, to narrow the scope of subclasses that are to be matched.
For example, an option or argument with the following type:

  GroupParamType(sub_classes=('aiida.groups:core.auto',))

will only match group instances that are a subclass of `AutoGroup`. Any
other `Group` subclasses will not be matched.
This will enable auto-completion for existing `Code` and `Group`
instances by their label for commands that have options or arguments
with the corresponding parameter type.
@sphuber sphuber force-pushed the feature/3925/group-param-type-subclassing branch from 57cacbe to 35ce7b8 Compare April 14, 2020 15:44
@sphuber sphuber requested a review from CasperWA April 14, 2020 15:46
@sphuber
Copy link
Contributor Author

sphuber commented Apr 15, 2020

@CasperWA I addressed your final comment

Copy link
Contributor

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Thanks @sphuber !

@sphuber sphuber merged commit 789fdee into aiidateam:develop Apr 15, 2020
@sphuber sphuber deleted the feature/3925/group-param-type-subclassing branch April 15, 2020 08:40
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.

Add support for subclassing to GroupParamType CLI param type
2 participants