-
Notifications
You must be signed in to change notification settings - Fork 1.6k
NDB: Start in on ndb.client.Client
#6876
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
Conversation
…n is just going to fix anyway.
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.
@chrisrossi I'm not clear why this special Client
class is needed. A parallel to ndb
would be https://github.com/googleapis/google-cloud-python-happybase, which doesn't define a Client
of it's own (but does have a similar metaphor).
ndb/src/google/cloud/ndb/client.py
Outdated
from google.cloud.client import ClientWithProject | ||
from google.cloud import _helpers | ||
|
||
_DATASTORE_HOST = "datastore.googleapis.com" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
def test_constructor_no_args(): | ||
with patch_credentials("testing"): | ||
client = client_module.Client() | ||
assert client.SCOPE == ("https://www.googleapis.com/auth/datastore",) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
A couple of days ago, before starting this, I sent around an email entitled "NDB client story", where I was pretty much fishing for exactly this kind of input. Did you see that? I can look at happybase--I'm not familiar with it at the moment. Basically, if we're going to interact with datastore, we need to get credentials, figure out the project/app, and possibly get a namespace. Since this is just a layer on datastore, I looked to datastore for the model on how to do it. I'm not wed to anything in particular, but I try not to invent new idioms if there is one already available, and I figured datastore probably represented some kind of "best practice" for Google APIs. |
I've looked at HappyBase this morning and it has a |
@chrisrossi I'd say push on with |
@dhermes I'm reasonably confident we can contain all the state we need in |
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.
@chrisrossi You have an uncovered branch in conftest.py
, so you need a no cover pragma?
ndb/src/google/cloud/ndb/client.py
Outdated
from google.cloud.client import ClientWithProject | ||
from google.cloud import _helpers | ||
|
||
_DATASTORE_HOST = "datastore.googleapis.com" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@dhermes Yep, fixed. |
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.
LGTM
ndb/src/google/cloud/ndb/client.py
Outdated
super(Client, self).__init__(project=project, credentials=credentials) | ||
self.namespace = namespace | ||
self.host = os.environ.get( | ||
environment_vars.GCD_HOST, _http.DATASTORE_API_HOST |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ndb/src/google/cloud/ndb/client.py
Outdated
|
||
from google.cloud import environment_vars | ||
from google.cloud import _helpers | ||
from google.cloud.client import ClientWithProject |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ndb/tests/conftest.py
Outdated
def environ(): | ||
"""Copy of ``os.environ``""" | ||
original = os.environ | ||
environ = original.copy() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
NDB: Start implementation of ndb.client.Client.
This is patterned off of
datastore.client.Client
and depends heavily ongoogle.cloud.client
.