Skip to content
This repository was archived by the owner on Mar 20, 2018. It is now read-only.

Update the structure of api_callable. - #107

Merged
jmuk merged 9 commits into
googleapis:masterfrom
jmuk:api_callable
Jun 10, 2016
Merged

jmuk merged 9 commits into
googleapis:masterfrom
jmuk:api_callable

Conversation

@jmuk

@jmuk jmuk commented Jun 9, 2016

Copy link
Copy Markdown
Contributor

Now this allows getting call options as an optional parameter
and changes its behavior.

In a part of #104 effort.

Now this allows getting call options as an optional parameter
and changes its behavior.

In a part of googleapis#104 effort.
Comment thread google/gax/__init__.py Outdated
@property
def flatten_pages(self):
"""
A boolean property whether a page streamed response should make

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"property whether" --> "property indicating whether"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@codecov-io

codecov-io commented Jun 9, 2016 •

Copy link
Copy Markdown

Current coverage is 97.16%

Merging #107 into master will decrease coverage by 0.07%

@@             master       #107   diff @@
==========================================
  Files             8          8          
  Lines           581        600    +19   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            565        583    +18   
- Misses           16         17     +1   
  Partials          0          0          

Powered by Codecov. Last updated by 26d8cef...57f28a6

@geigerj

geigerj commented Jun 9, 2016

Copy link
Copy Markdown
Contributor

Note: googleapis/gapic-generator#214 also changes the handling of metadata, which requires an update to CallSettings and api_callable.

@jmuk

jmuk commented Jun 10, 2016

Copy link
Copy Markdown
Contributor Author

I reviewed #104 discussion but unclear why metadata goes into construct_settings. It's actually not discussed well.

But I don't think that's the key part of the redesign, and therefore I think that's no problem to be in a part of method invocation, i.e.

self._create_shelf(request, options, metadata=self._headers)

And this structure would work well with this PR.

@geigerj

geigerj commented Jun 10, 2016

Copy link
Copy Markdown
Contributor

regarding metadata -- this was in Garrett's original mockup on the pubsub codegen, and is implicitly represented in #104 by the simplified method invocation in the second code block. If you feel that this should not be addressed in this PR, I can do it in a follow-up.

Comment thread google/gax/__init__.py
def next(self):
"""Retrieves the next resource."""
# pylint: disable=next-method-called
while not self._current:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the while loop? That is, when will a PageIterator contain a falsy value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PageIterator could return an empty array but have a next page token, in that case this should skip the empty array and fetch the next page.

@jmuk

jmuk commented Jun 10, 2016

Copy link
Copy Markdown
Contributor Author

Regarding metadata -- rethinking about that, I'm okay with merging into construct_settings.
But I'm thinking CallSettings might not be a good name now -- it keeps the option parameters (like backoff settings) and the information of the API-call such as page descriptions, bundle descriptions, and now metadata (headers) -- those are properties of the method itself rather than invocations (= call).
This could be MethodSettings?

@geigerj

geigerj commented Jun 10, 2016 •

Copy link
Copy Markdown
Contributor

SGTM regarding CallSettings vs MethodSettings. I think there has always been some ambiguity about the difference between CallOptions and CallSettings from their naming -- hopefully this name change will make it clearer.

@jmuk

jmuk commented Jun 10, 2016

Copy link
Copy Markdown
Contributor Author

Updated about the metadata -- not renamed the class yet. I think it can be done in another PR.

Also, I think GAX should not be strongly tied to gRPC itself -- it should be encapsulated into grpc.py file only as far as possible, and therefore, I've added 'kwargs' argument instead.

Comment thread google/gax/__init__.py Outdated
page_descriptor=self.page_descriptor, page_token=page_token,
bundler=bundler, bundle_descriptor=self.bundle_descriptor)
bundler=bundler, bundle_descriptor=self.bundle_descriptor,
kwargs=self.kwargs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's a actually do

if options.kwargs == OPTION_INHERIT:
  kwargs = self.kwargs
else:
  kwargs = self.kwargs.copy()
  kwargs.update(options.kwargs)

I can't tell where options.kwargs is currently being used -- maybe we are just ignoring it at the moment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added -- no such options.kwargs exist currently, so I've added it.

@geigerj

geigerj commented Jun 10, 2016

Copy link
Copy Markdown
Contributor

Just one concern about the CallSettings merge method. Otherwise looks good

@geigerj

geigerj commented Jun 10, 2016

Copy link
Copy Markdown
Contributor

LGTM.

I will update googleapis/gapic-generator#214 to put metadata into kwargs.

@jmuk
jmuk merged commit 5acaf0c into googleapis:master Jun 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants