Commit Graph

276 Commits

Author SHA1 Message Date
Xuan Wang 49d48c94ab
[Python Example] Fix compression example (#34745)
Fix: https://github.com/grpc/grpc/issues/34690

Also added generated proto files to example folder so we can run example
directly.
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
2023-10-20 09:10:14 -07:00
Xuan Wang cedef1b7f3
[Python example] Add example for TLS (#34116)
Add example for TLS.

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
2023-08-22 13:02:40 -07:00
Sergii Tkachenko de6ed9ba9f
[Python] Migrate from yapf to black (#33138)
- Switched  from yapf to black
- Reconfigure isort for black
- Resolve black/pylint idiosyncrasies 

Note: I used `--experimental-string-processing` because black was
producing "implicit string concatenation", similar to what described
here: https://github.com/psf/black/issues/1837. While currently this
feature is experimental, it will be enabled by default:
https://github.com/psf/black/issues/2188. After running black with the
new string processing so that the generated code merges these `"hello" "
world"` strings concatenations, then I removed
`--experimental-string-processing` for stability, and regenerated the
code again.

To the reviewer: don't even try to open "Files Changed" tab 😄 It's
better to review commit-by-commit, and ignore `run black and isort`.
2023-06-09 15:08:55 -07:00
molto 1980841257
[example] Fix bad example (#32161)
Channel object has no method ``stop``, it supposed to be ``close`` here.

---------

Co-authored-by: Xuan Wang <xuanwn@google.com>
2023-05-10 17:36:04 -07:00
Xuan Wang 40f20c0f48
[Python fix-it][Aysnc Example] Adding examples for aysnc interceptor context propagaton (#32840)
### Description

Fix https://github.com/grpc/grpc/issues/24470.

Adding one example which demonstrate the following use cases:

* Generate RPC ID on client side and propagate to server.
* Context propagation from client to server.
* Context propagation between different server interceptors and the
server handler.

## Use:

1. Start server: `python3 -m async_greeter_server_with_interceptor`
2. Start client: `python3 -m async_greeter_client`

### Expected Logs:

* On client side:

```
Sending request with rpc id: 73bb98beff10c2dd7b9f2252a1e2039e
Greeter client received: Hello, you!
```

* On server side:

```
INFO:root:Starting server on [::]:50051
INFO:root:Interceptor1 called with rpc_id: default
INFO:root:Interceptor2 called with rpc_id: Interceptor1-default
INFO:root:Handle rpc with id Interceptor2-Interceptor1-73bb98beff10c2dd7b9f2252a1e2039e in server handler.
```
2023-05-04 19:31:01 +00:00
Xuan Wang a190831789
Add examples for timeout, kepp_alive, reflection and health_checking (#32243)
* Add timeout example

* Add pb2 file to example

* Remove .proto file

* Add keep_alive example

* Add refelction client

* fixes

* Add example for health_check

* Changes based on comments

* Fix pylint
2023-02-03 14:11:27 -08:00
Richard Belleville d175c79935
Add lb policy example (#32256)
* Add lb policy example

* Update copyright

* This is Python 3

* Fix isort
2023-02-03 09:58:50 -08:00
Xuan Wang 10e5b2115e
Add wait_for_ready with client timeout example (#32183)
* Add wait_for_ready with client timeout example

* Use with to create channel

* Fix sanity tests

* Changes based on comments

* Change thread to daemon thread

* Changes based on comments
2023-01-25 11:02:13 -08:00
Ian Rodney cfd3395e9b
explain that keys must be lower cased (#31586) 2023-01-10 16:42:29 -08:00
Ho Ngok Chao 28e49b0f6f
Add concurrency into python example in route_guide (#31724)
* Add concurrency into python example in route_guide

- replace await single tasks sequentially with await task_group

* Add comments for asyncio.gather for concurrency

* Correct typo

* Update asyncio_route_guide to meet google style

Co-authored-by: Richard Belleville <rbellevi@google.com>
2022-12-21 11:17:14 -08:00
niquepolice 3714762731
Fix typo in multiprocessing example Readme (#30132) 2022-11-22 14:32:56 -08:00
Xuan Wang 149f5615ba
Remove enum and future (#31381)
* [Python][Remove enum34] Remove enum34

* [Python][Remove futures] Remove futures

* Remove empty deps from .bazel files
2022-10-18 14:58:30 -07:00
Xuan Wang 7aca6d4007
[Remove Six] Remove dependency on six (#31340)
* [Python][Remove Six] Remove Six from requirements
2022-10-17 09:34:45 -07:00
AmosWang 166824205e
Print info when server starts (#30964) 2022-09-14 15:54:01 -07:00
Yash Tibrewal 41ec08c69a
Update third_party/protobuf to 3.21.4 (#30377)
* Update third_party/protobuf

* run tools/distrib/python/make_grpcio_tools.py

* regenerate protos for ruby, php

* update build_handwritten.yaml

* regenerate projects

* Build - Use :well_known_type_protos instead of :well_known_protos

* Fix target

* Update upb

* Update Python for Protobuf 4.21 (#140)

* Update protobuf dependency on grpcio-tools

* Off by one

* Drop python 3.6 support

* Try upgrading pip

* And in the other script

* Try to figure out if we're compatible with abi3

* See what we've already got installed

* Update the requirements.txt file I didn't know existed

* And here too

* See what's installed

* Let's try that again

* Remove

* Try to confirm version

* Let me see the generated code

* Fix non-Bazel test runner

* Work for all test directories

* Regenerate example protos

* Clean up

* Generate .pyi files

* Fix type checking and linting

* Exclude pyi files from isort

* Upgrade to 3.21.4

* Update iwyu to get around messy protobuf IWYU rules

Co-authored-by: Richard Belleville <gnossen@gmail.com>
2022-08-04 09:39:49 -07:00
Lidi Zheng 3f2b3460a4
[Python] Add an UDS example (#29592) 2022-05-09 17:08:54 -07:00
Xiao ad3f591af3
[Aio] Fix typo in async graceful shutdown example (#29521)
Background: https://github.com/grpc/grpc/pull/26622
2022-05-03 10:51:44 -07:00
Michael Mercier b784a4307d
Add python async example for hellostreamingworld using generator (#27343)
* Add python async example for hellostreamingworld using generator

* add stub.read() client example + fix Copyrights + small improvements

* Format and lint + remove exernal generator

* Apply lint and auto-format
2022-01-06 10:15:40 -08:00
Richard Belleville 468768865b
Make Buildifier Sanity Test Strict (#27807)
* Fix all lint errors in repo.

* Use strict buildifier by default

* Whoops. That file does not exist

* Attempt fix to buildifier invocation

* Add missing copyright
2021-11-03 14:57:04 -07:00
Richard Belleville ffc43e05d8
Switch Python xDS Example Server to Listen on IPV4 Only (#27679) (#27758)
* Switch to IPV4

* Update to all hosts
2021-10-18 09:36:08 -07:00
Craig Tiller d1e01ac139
Add a test for a (now-illegal) build file construct (#27602)
* Add a test for a (now-illegal) build file construct

* add to test suite!

* fix

* fix

* fix syntax
2021-10-06 07:43:59 -07:00
小么小儿郎EL 435d5207ab
fix: use == instead of is when comparing with a certain types of literals (#26519) 2021-09-21 15:36:26 -07:00
Richard Belleville a48067c4c8
Replace StopIteration with return (#26861) 2021-08-03 11:08:31 -07:00
Lidi Zheng 6c6463e1cd
Add retry example for gRPC Python (#26829)
* Add retry example for gRPC Python

* Make sanity test happy && simplfy proto definition

* Fix a grammer issue
2021-07-29 17:31:05 -07:00
Lidi Zheng 2231c2ba77
Introduce Python import sorting to our sanity test suite (#26768)
* Add isort_code.sh to sanity tests

* Run tools/distrib/isort_code.sh

* Fine tune the import order for relative imports

* Make pylint and project generation happy

* Fix a few corner cases

* Use --check instead of --diff

* The import order impacts test result somehow

* Make isort print diff and check output at the same time

* Let tools/run_tests/python_utils be firstparty library

* Run isort against latest HEAD
2021-07-26 12:31:21 -07:00
Lidi Zheng 933b10d2a8
Add a correct graceful shutdwon example for the asyncio API (#26622) 2021-07-08 10:58:58 -07:00
Richard Belleville 7125bbe5a5
Add Python PSM security example (#26170)
* Add Python PSM security example

* Fix lint

* Add in maintenance port configuration

* Align CLI flags with Java

* Pylint
2021-05-05 15:57:38 -07:00
Yash Tibrewal f4e55b85bc Replace disrespectful term 2021-02-08 15:29:53 -08:00
Sergii Tkachenko 8db79e2e71 Python style: reformat code using updated yapf 0.30.0 2021-01-13 14:00:12 -05:00
Lidi Zheng e6dffc6fbe Adding three more AsyncIO examples
* Channelz or Debug
* Route guide
* Wait for ready
2021-01-06 10:52:39 -08:00
Esun Kim e0ebe46ad3 Fix python examples 2020-12-23 09:23:32 -08:00
Esun Kim e7afadc255 Refactor examples BUILD files 2020-12-23 09:23:32 -08:00
Lidi Zheng c515666a73
Merge pull request #24668 from lidizheng/example-async-bidi
Add async bidi-streaming example
2020-12-21 15:15:16 -08:00
Lidi Zheng f2d06b8458 Add async bidi-streaming example 2020-12-21 14:38:39 -08:00
Lidi Zheng 40a5a655af Polish and add AsyncIO examples
* Add type annotations
* Add test for asyncio auth example
* Use dynamic stubs to allow same code runs manually and under Bazel
* Add grpcio-tools as a Bazel dependency
* asyncio.run is not yet existed in 3.6
* Improve readability
2020-12-08 13:44:43 -08:00
Richard Belleville 14d6850f5a And remove it too 2020-10-19 13:09:07 -07:00
Richard Belleville 3dad0eb862 Oops 2020-10-19 13:07:52 -07:00
Richard Belleville 897f97212a Add -x to shell script 2020-10-19 10:51:42 -07:00
Richard Belleville 7821040586 Modernize run_codegen script 2020-10-16 13:58:16 -07:00
Tim Hughes 80799468bd lint 2020-10-05 21:56:48 +01:00
Tim Hughes 0b3fc20b83 clean up docstrings and remove unused imports 2020-10-05 21:30:57 +01:00
Tim Hughes 7aff6c4555
dont need ThreadPoolExecutor in asyncio 2020-10-04 21:51:05 +01:00
Tim Hughes cef8dbf27c
Adds python aio helloworld examples 2020-10-01 00:05:11 +01:00
Richard Belleville e56fa264b6 Period 2020-08-17 11:37:21 -07:00
Richard Belleville 578c24a5e4 Spruce up no_codegen example 2020-08-17 11:03:32 -07:00
Richard Belleville a362c2566d Revert examples 2020-08-14 19:21:04 -07:00
Richard Belleville c128e61cf4 Format examples 2020-08-14 19:08:44 -07:00
Richard Belleville b2bc02d5a4 Add pregenerated example 2020-08-14 17:01:52 -07:00
Richard Belleville 8917e6d2a0 Pylint 2020-08-14 16:53:47 -07:00
Richard Belleville 828edcc67a Use bazel imports instead of sys.path 2020-08-14 16:15:01 -07:00