-
Notifications
You must be signed in to change notification settings - Fork 192
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
👌 IMPROVE: QueryBuilder
reprs (incl/ queryhelp -> as_dict)
#5081
👌 IMPROVE: QueryBuilder
reprs (incl/ queryhelp -> as_dict)
#5081
Conversation
…iida_core into querybuilder-repr
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## develop #5081 +/- ##
===========================================
+ Coverage 80.44% 80.50% +0.06%
===========================================
Files 531 531
Lines 36973 37020 +47
===========================================
+ Hits 29738 29798 +60
+ Misses 7235 7222 -13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Ok this is done, I would like to merge this asap, to feed it up into #5069. So looking to merge in next day or two |
aiida/orm/querybuilder.py
Outdated
@property | ||
def queryhelp(self) -> QueryDict: | ||
""""Legacy name for ``as_dict`` method.""" | ||
# deprecate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only outstanding question, for me, is whether we actually add a deprecation warning here, or "schedule" it for a later date. I guess essentially it shouldn't be removed until v3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it will be good for users to have deorecation warnings showing up when they've just switched to v2, so I would be tempted to leave it for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks @chrisjsewell !
Some comments along with the actual review comments:
Maybe rename the awkward _kw
to the more standard kwargs
?
Are the *.txt and test_as_dict.yml files in the test folder for the QueryBuilder
necessary? They seem to maybe be relics from some tests that should be removed or are they intentional?
cheers for the quick review @CasperWA 😄 |
No they are intentional and generated in |
done |
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
Why? Is there a reason this is necessary to keep in the repo? Couldn't it just be deleted after use or kept in memory if it's to be used elsewhere? |
No this is just how https://pytest-regressions.readthedocs.io works; it’s regressing against the stored files. I’d definitely recommend it, we use it loads, for example, in aiida-quantumespresso |
@CasperWA I've addressed all your comments cheers |
QueryBuilder
representations (replace queryhelp)QueryBuilder
reprs (incl/ queryhelp -> as_dict)
merging this today (the link check fail is just that https://shapeshed.com/unix-exit-codes/ is down at present) |
Sure - but maybe always wait for an approving review, or? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a bunch @chrisjsewell !
Approved on my end. I found a single "one sentence per one line" thing in the documentation and that's about it.
I had full faith that you would sign it off today 😄 |
Thanks! |
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
This PR principally does:
queryhelp
foras_dict()
and also add afrom_dict
classmethodAs I believe @mbercx and @CasperWA already agree,
queryhelp
is a very unintuitive name, and a stumbling block for many new users.__str__
outputs with a representation ofas_dict()
rather than the compiled SQL query (and also use this for__repr__
).Users should not need to be exposed to the SQL, this is a "dev-user" feature
as_sql
method, for retrieving the SQL query stringThis has an option to allow for both strings with the parameters inlined or external.
It also fixes #3844 and #4659 (since the SQL string is no longer generated on print, this is also less of an issue)
Add
analyze_query
method, to run postgresql'sEXPLAIN
command.Some more type hinting and tests
closes #4502
closes #3844
closes #3845
closes #4659