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

WIP: Model properties #96

Merged
merged 4 commits into from
May 24, 2019
Merged

WIP: Model properties #96

merged 4 commits into from
May 24, 2019

Conversation

cguardia
Copy link
Contributor

This is almost done, but needs a final push for test coverage edge cases. I decided to remove work on LocalStructuredProperty, so that this can be merged first, and after that I can handle PR #93 without conflicts.

For now, I commented out the part where the RepeatedStructuredPropertyFilterPredicate is used.

Note that the StructuredProperty had quite complex serialization/deserialization methods, which we do not support now, so not sure what is needed to be done there.

@cguardia cguardia requested a review from chrisrossi May 17, 2019 09:02
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 17, 2019
Copy link
Contributor

@chrisrossi chrisrossi left a comment

Choose a reason for hiding this comment

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

Lookin' really good.

Needs nox -e blacken and for the build to pass.

I would also really like to see some system tests.

"""Dynamically get a subproperty."""
# Optimistically try to use the dict key.
prop = self._modelclass._properties.get(attrname)
# We're done if we have a hit and _code_name matches.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment seems unrelated to code. Don't see _code_name anymore. Only done-ness seems to be if we didn't get a hit, then it raises an exception.

return prop_copy

def _comparison(self, op, value):
if op != '=':
Copy link
Contributor

Choose a reason for hiding this comment

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

query._EQ_OP?

raise exceptions.BadFilterError(
'Cannot query for non-empty repeated property %s' % prop._name)
continue
assert isinstance(vals, list) and len(vals) == 1, repr(vals)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for user or programmer error to cause this to be False?

'Expected list, tuple or set, got %r' % (value,))
from .query import DisjunctionNode, FalseNode
# Expand to a series of == filters.
filters = [self._comparison('=', val) for val in value]
Copy link
Contributor

Choose a reason for hiding this comment

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

query._EQ_OP?

(self._modelclass.__name__, value.__class__))

def _has_value(self, entity, rest=None):
# rest: optional list of attribute names to check in addition.
Copy link
Contributor

Choose a reason for hiding this comment

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

Turn comment into docstring?

super(GenericProperty, self).__init__(name=name, **kwargs)
self._compressed = compressed
if compressed and self._indexed:
# TODO: Allow this, but only allow == and IN comparisons?
Copy link
Contributor

Choose a reason for hiding this comment

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

We've been getting rid of ancient TODO comments. If it hasn't been done by now...

If something feels particularly pertinent, you can always make an issue in github, which will be a better way to track/prioritize.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels May 22, 2019
@cguardia
Copy link
Contributor Author

cguardia commented May 22, 2019

@andrewsg or @crwilcox seems like I'm going to need your help to get this one through. I addressed review comments and the build passes now, but I think the problem is that I rebased on my local branch. Anyway, maybe you can help me with the squash and merge? Thanks.

@tseaver
Copy link
Contributor

tseaver commented May 22, 2019

@cguardia Can you try the following on your local checkout? I'm assuming you have two remotes, upstream pointing to this repo and origin pointing to your fork.

$ git checkout master && git fetch --all --prune && git merge upstream master
$ git checkout model_properties
$ git rebase -i master  # edit out the commits before 6e75bba 
$ git push -f origin model_properties

@cguardia
Copy link
Contributor Author

@tseaver seems that it worked, thanks.

@cguardia cguardia added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels May 22, 2019
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot removed the cla: yes This human has signed the Contributor License Agreement. label May 22, 2019
@googlebot
Copy link

☹️ Sorry, but only Googlers may change the label cla: yes.

@cguardia cguardia dismissed chrisrossi’s stale review May 23, 2019 00:45

Changes have been applied and reviewer is on vacation.

self._modelclass = modelclass

def _get_value(self, entity):
"""Override _get_value() to *not* raise UnprojectedPropertyError."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you expand this docstring to say something about why this intentionally raises unprojectedpropertyerror and under what circumstances you'd want to override that behavior?

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 24, 2019
@cguardia cguardia added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 24, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 24, 2019
@cguardia cguardia merged commit 1517281 into googleapis:master May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants