Commit Graph

42 Commits

Author SHA1 Message Date
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
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
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
Richard Belleville
0cdffa970c Buildifier 2020-04-13 10:25:56 -07:00
Richard Belleville
c14fce7ab4 Typo 2020-04-10 19:35:01 -07:00
Richard Belleville
e97cd37e68 Support running multiprocessing example without Bazel 2020-04-10 19:33:07 -07:00
Richard Belleville
96024a9ad3 Update documentation 2020-04-10 19:22:55 -07:00
Yannic Bonenberger
06ecc87290 [bazel] Add fixes for --incompatible_load_proto_rules_from_bzl 2020-02-05 19:58:30 +01:00
Esun Kim
7be821ac47 Yapf all target python sources 2020-01-03 09:25:10 -08:00
Lidi Zheng
c34bef4ca4 Format all Bazel files with buildifier 2019-11-05 14:03:52 -08:00
Richard Belleville
1444cd1dd3 Revert "Revert "Merge pull request #20097 from gnossen/dual_version_python_tests""
This reverts commit 24c562dbaa.
2019-08-29 10:51:36 -07:00
Richard Belleville
24c562dbaa Revert "Merge pull request #20097 from gnossen/dual_version_python_tests"
This reverts commit c9c847f334, reversing
changes made to 07ba4de392.
2019-08-29 10:47:44 -07:00
Richard Belleville
27990a5541 Explicitly add python versions to examples. 2019-08-27 17:47:52 -07:00
Richard Belleville
ba04bafede And the examples directory 2019-08-21 14:39:54 -07:00
Richard Belleville
7b2c8c27b0 Separate py_grpc_library and py_proto_library.
By popular demand, we'll now be offering separate py_grpc_library and
py_proto_library targets sharing the same interface as within google3.
This change necessitated some modifications to how we pull in our own
Python-level dependencies and how we make those available to those
pulling in our project via Bazel.

There is now a grpc_python_deps() Bazel workspace rule that pulls in the
appropriate dependencies, which should be called from the client
project's WORKSPACE file. A test has been added to the bazel/test/
directory to verify that this behavior works as intended.

It's worth noting that the protobuf repository's usage of Starlark
bind() caused a great deal of trouble in ensuring that we could also
pull in six.

This change also required a change in the way generated proto code is
imported in the channelz and health-check modules, as well as in their
associated tests. We were importing them two different ways, each
relative. This resulted in two different module objects being imported
into the process, which were incompatible. I am not sure exactly what
caused this behavior to begin, as this should have been possible before
this PR. As a workaround, I am simply trying two different absolute
imports and using the one that works. This should function both inside
and outside of Bazel environments.
2019-08-01 15:16:22 -07:00
Richard Belleville
8fb51946bf Fix multiprocessing example for MacOS.
A closer reading of the API for getsockopt revealed that we were
depending on an implementation detail of getsockopt on Linux. This
assumption breaks down on MacOS.

getsockopt merely guarantees that it will return on 0 in case of failure
and a value greater than 0 in case of success. There is no guarantee as
to *which* non-zero value you will receive. On Linux, it seems to be 1,
the value which was explicitly set. On MacOS, it seems to be the value
of the FLAG which was set, i.e. 512 for SO_REUSEPORT.

This commit ensures the check we use does not rely on either of these
implementation details.
2019-06-21 14:01:27 -07:00
Nicolas "Pixel" Noble
929f151016 Cherry-picking #19349 in. 2019-06-17 22:42:08 +02:00
Nicolas "Pixel" Noble
0472933d71 Trying to fix build. 2019-06-14 07:35:33 +02:00
Richard Belleville
930cec4e27 Revert "Merge pull request #18912 from grpc/revert-bazel-changes"
This reverts commit c9a259aa3a, reversing
changes made to 9c882bc725.
2019-04-30 11:17:11 -07:00
Richard Belleville
50b5240d0a Revert "Merge pull request #18859 from grpc/internal_py_proto_library"
This reverts commit 5b720f19c1, reversing
changes made to a64ae3c0d5.
2019-04-29 17:47:56 -07:00
Richard Belleville
05f37c8143 Remove dependency on pubref/rules_proto.
This commit resolves #18331.
This commit resolves #18256.
This commit resolves... another TODO that apparently didn't have an
associated github issue.

We swap out pubref's implementation of py_proto_library with our own,
which more closely mirrors the interface of the internal
py_proto_library, taking the descriptor file output of a proto_library
rule as input.

One minor change in behavior was introduced for simplicity. When a
py_proto_library depends on a proto_library with a source proto file in
a subdirectory of the bazel package, the import module of the resultant
python library will reflect the package, *not* the full directory of the
proto file, including both the bazel package and the subdirectories, as
pubref did previously. This behavior also more closely mirrors google
internal behavior.

This commit also introduces a slightly more stringent bazel format
script. Buildifier on its own will not take care of long lines, but by
running yapf first, we end up with a more legible file. At the moment,
there is no sanity check associated with this formatter.
2019-04-24 17:36:08 -07:00
Richard Belleville
dde238cb5d Apparently no ipv6 on kokoro 2019-03-12 10:44:05 -07:00
Richard Belleville
f3b57e35ec Properly import protos 2019-03-12 10:15:19 -07:00
Richard Belleville
b9659d58da Actually generate proto 2019-03-12 09:16:30 -07:00
Richard Belleville
2a50960b4c Add copyright to BUILD file 2019-03-12 08:37:07 -07:00
Richard Belleville
2640822c2d Remove a statement proven wrong by science 2019-03-08 17:24:59 -08:00
Richard Belleville
4c8c8e36d2 Show some respect 2019-03-08 16:52:33 -08:00
Richard Belleville
69b5476429 Expand the readme 2019-03-08 16:38:58 -08:00
Richard Belleville
d359dbe44d Remove unnecessary flush 2019-03-08 16:21:49 -08:00
Richard Belleville
81c3b0bfb6 Fix lint errors 2019-03-08 16:18:57 -08:00
Richard Belleville
d832738c08 Yapf 2019-03-08 15:16:12 -08:00
Richard Belleville
67ca10b4f9 Add README 2019-03-08 15:06:02 -08:00
Richard Belleville
0f6293e85e Improve logging handlers 2019-03-08 13:50:17 -08:00
Richard Belleville
acbc095ab8 Implement test for example 2019-03-08 13:40:44 -08:00
Richard Belleville
5c4823c17b Build with bazel 2019-03-07 16:34:48 -08:00
Richard Belleville
0c8418c4bf WIP. Start BUILD file 2019-03-05 15:08:23 -08:00
Richard Belleville
510beaaede Add a CLI parser to the client 2019-03-01 17:41:56 -08:00
Richard Belleville
a6c33d3516 Dynamically allocate port 2019-03-01 17:35:35 -08:00
Richard Belleville
f2c7ffc9fb Add multiprocessed client 2019-03-01 13:27:16 -08:00
Richard Belleville
4a8a2e286e Add basic multiprocessing-based server 2019-03-01 11:14:40 -08:00