NDB: Start in on ndb.client.Client#6876
Conversation
…n is just going to fix anyway.
dhermes
left a comment
There was a problem hiding this comment.
@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 |
dhermes
left a comment
There was a problem hiding this comment.
@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. |
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.
NDB: Start implementation of ndb.client.Client.
This is patterned off of
datastore.client.Clientand depends heavily ongoogle.cloud.client.