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

fix: adds comment with explicit hostname change #94

Merged
merged 5 commits into from Mar 11, 2021
Merged

Conversation

telpirion
Copy link
Contributor

@telpirion telpirion commented Mar 5, 2021

A common issue we're seeing among Document AI customers is that they set the location to 'eu' but don't know to change the hostname as well to 'eu-documentai.googleapis.com'.

@product-auto-label product-auto-label bot added the api: documentai label Mar 5, 2021
@google-cla google-cla bot added the cla: yes label Mar 5, 2021
@telpirion telpirion marked this pull request as ready for review Mar 5, 2021
@telpirion telpirion requested a review from as a code owner Mar 5, 2021
@telpirion telpirion requested review from kurtisvg and leahecole and removed request for Mar 5, 2021
# You must set the api_endpoint if you use a location other than 'us', e.g.:
# client = documentai.DocumentProcessorServiceClient(
# {"api_endpoint": "eu-documentai.googleapis.com"}
# )
client = documentai.DocumentProcessorServiceClient()
Copy link

@kurtisvg kurtisvg Mar 5, 2021

Choose a reason for hiding this comment

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

I generally dislike commented code because you can't test it or even guarantee it'll compile once uncommented. Would it be acceptable to do something like this instead?

Suggested change
# You must set the api_endpoint if you use a location other than 'us', e.g.:
# client = documentai.DocumentProcessorServiceClient(
# {"api_endpoint": "eu-documentai.googleapis.com"}
# )
client = documentai.DocumentProcessorServiceClient()
# You must set the api_endpoint if you use a location other than 'us', e.g.:
opts = {}
if location == "eu":
opts = {"api_endpoint": "eu-documentai.googleapis.com"}
client = documentai.DocumentProcessorServiceClient(opts)

Copy link
Contributor Author

@telpirion telpirion Mar 10, 2021

Choose a reason for hiding this comment

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

Done

@telpirion telpirion requested a review from kurtisvg Mar 9, 2021
Copy link

@kurtisvg kurtisvg left a comment

Looks like something is failing in the tests. Are we sure this is the correct way to specify opts?

@PicardParis
Copy link

@PicardParis PicardParis commented Mar 10, 2021

Hi Kurtis,
This code works for me:

assert api_location in ("us", "eu")
client_options = dict(api_endpoint=f"{api_location}-documentai.googleapis.com")
client = documentai.DocumentProcessorServiceClient(client_options=client_options)

@telpirion
Copy link
Contributor Author

@telpirion telpirion commented Mar 10, 2021

This code works for me:

assert api_location in ("us", "eu")
client_options = dict(api_endpoint=f"{api_location}-documentai.googleapis.com")
client = documentai.DocumentProcessorServiceClient(client_options=client_options)

Thank you for the suggestion, @PicardParis . I want to avoid putting asserts in the samples. Also, although the GCE locations and hostnames for Doc AI currently overlap, that may not always be true--string interpolation may not be our best option here.

@telpirion
Copy link
Contributor Author

@telpirion telpirion commented Mar 10, 2021

Looks like something is failing in the tests. Are we sure this is the correct way to specify opts?

Should be fixed now--I forgot the client_options parameter.

@telpirion telpirion requested a review from kurtisvg Mar 10, 2021
@telpirion telpirion merged commit bb639f9 into master Mar 11, 2021
8 checks passed
@telpirion telpirion deleted the location-comment branch Mar 11, 2021
gcf-merge-on-green bot pushed a commit that referenced this issue Mar 25, 2021
🤖 I have created a release \*beep\* \*boop\*
---
## [0.4.0](https://www.github.com/googleapis/python-documentai/compare/v0.3.0...v0.4.0) (2021-03-25)


### Features

* add 'from_service_account_info' factory to clients ([d6f183a](https://www.github.com/googleapis/python-documentai/commit/d6f183a696b211c6d29bc28e9bbd0a8537f65577))
* add common resource path helpers, expose client transport ([#43](https://www.github.com/googleapis/python-documentai/issues/43)) ([4918e62](https://www.github.com/googleapis/python-documentai/commit/4918e62033b4c118bf99ba83730377b4ecc86d17))
* add documentai v1 ([#101](https://www.github.com/googleapis/python-documentai/issues/101)) ([74fabb5](https://www.github.com/googleapis/python-documentai/commit/74fabb5e260ecc27e9cf005502d79590fa7f72e4))
* add from_service_account_info factory and fix sphinx identifiers  ([#80](https://www.github.com/googleapis/python-documentai/issues/80)) ([d6f183a](https://www.github.com/googleapis/python-documentai/commit/d6f183a696b211c6d29bc28e9bbd0a8537f65577))


### Bug Fixes

* added if statement to filter out dir blob files ([#63](https://www.github.com/googleapis/python-documentai/issues/63)) ([7f7f541](https://www.github.com/googleapis/python-documentai/commit/7f7f541bcf4d2f42b2f619c2ceb45f53c5d0e9eb))
* adds comment with explicit hostname change ([#94](https://www.github.com/googleapis/python-documentai/issues/94)) ([bb639f9](https://www.github.com/googleapis/python-documentai/commit/bb639f9470304b9c408143a3e8091a4ca8c54160))
* fix sphinx identifiers ([d6f183a](https://www.github.com/googleapis/python-documentai/commit/d6f183a696b211c6d29bc28e9bbd0a8537f65577))
* moves import statment inside region tags ([#71](https://www.github.com/googleapis/python-documentai/issues/71)) ([a04fbea](https://www.github.com/googleapis/python-documentai/commit/a04fbeaf026d3d204dbb6c6cecf181068ddcc882))
* remove client recv msg limit and add enums to `types/__init__.py` ([#72](https://www.github.com/googleapis/python-documentai/issues/72)) ([c94afd5](https://www.github.com/googleapis/python-documentai/commit/c94afd55124b0abc8978bf86b84743dd4afb0778))
* removes C-style semicolons and slash comments ([#59](https://www.github.com/googleapis/python-documentai/issues/59)) ([1b24bfd](https://www.github.com/googleapis/python-documentai/commit/1b24bfdfc603952db8d1c633dfde108a396aa707))
* **samples:** swaps 'continue' for 'return' ([#93](https://www.github.com/googleapis/python-documentai/issues/93)) ([dabe48e](https://www.github.com/googleapis/python-documentai/commit/dabe48e8c1439ceb8a50c18aa3c7dca848a9117a))


### Documentation

* fix pypi link ([#46](https://www.github.com/googleapis/python-documentai/issues/46)) ([5162674](https://www.github.com/googleapis/python-documentai/commit/5162674091b9a2111b90eb26739b4e11f9119582))
* **samples:** new Doc AI samples for v1beta3 ([#44](https://www.github.com/googleapis/python-documentai/issues/44)) ([cc8c58d](https://www.github.com/googleapis/python-documentai/commit/cc8c58d1bade4be53fde08f6a3497eb3f79f63b1))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: documentai cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants