Skip to main content

grpc for Humans. grpc reflection support client

Project description

grpc_requests

Nox Ruff Checked with mypy PyPI PyPI - Python Version PyPI download month License Views

GRPC for Humans

Leverage reflection to interact with GRPC in a familiar manner for users of the requests library.

from grpc_requests import Client

client = Client.get_by_endpoint("localhost:50051")
assert client.service_names == ["helloworld.Greeter"]

request_data = {"name": "sinsky"}
say_hello_response = client.request("helloworld.Greeter", "SayHello", request_data)
assert say_hello_response ==  {"message":"Hello sinsky!"}

Features

  • Create a client easily when connecting to servers implementing grpc reflection
  • Still support creating a client from stubs when reflection isn't available
  • All unary and stream methods supported
  • TLS and compression connections supported
  • AsyncIO API supported

Install

pip install grpc_requests

Usage

In short:

Instantiate a client using the URL of a GRPC server and any authentication credentials you may need. If the server utilizes SSL (and it probably does) make sure to toggle that flag.

from grpc_requests import Client

metadata = [("authorization", "bearer my.cool.jwt")]
client = Client.get_by_endpoint("cool.servers.arecool:443", ssl=True, metadata=metadata)

The examples page provides more thorough examples of usage scenarioes, and the unit tests are also a useful reference point.

Contributing

Contributions from the community are welcomed and greatly appreciated.

Before opening a PR, running python -m nox can be used to ensure the contribution passes linting and unit test checks for all supported versions of Python and protobuf. You can also run complexity.sh to use radon to look at the cyclomatic complexity, maintainability index, and Halstead effort and difficulty of files.

PRs should be targeted to merge with the develop branch. When opening a PR, please assign it to a maintainer for review. The maintainers will take it from there.

Compatibility

grpc_requests currently does its best to support versions of Python and protobuf that are within their support lifetimes. You may find that other versions of dependencies work with the library, but this should be treated as a happy accident.

For Python, we target versions that are in the security and bugfix phases. For protobuf, we target versions that in their public support phase.

Python's support matrix Protobuf's support matrix

Protobuf Compatibility

The maintainers of grpc_requests have found that protobuf 4.25.4 is not compatible with verisons >=1.66.0 of both grpcio and grpcio-reflection. If your use case needs 4.25.4 of protobuf, we recommend sticking to verison 1.65.x of grpcio and grpcio-reflection.

The maintainers have also noted that under Python 3.13 grpc_requests will work only with protobuf version 5.29.4 and above.

Questions, Comments, Issues?

For questions, please start a conversation on the discussions page!

For feature requests or bugs, please open an issue and assign it the appropriate tag.

Maintainers

ChangeLog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

0.1.21 - 2025-03-22

Fixed

  • Added support for Async Iterators in Async Clients
  • Set default for asyncio fixture loop scope
  • Updated dependency versions
  • Corrected documentation

0.1.20 - 2024-08-15

Added

  • Noxfile for testing combinations of supported versions Python and protobuf
  • Specifications around support targets for Python and protobuf for the library

Fixed

  • Fixed a bug wherein attempting to retrieve a dependency of a FileDescriptor could result thrown an exception if the dependency was not being served via reflection by the server.

0.1.19 - 2024-07-18

Added

  • Tools for developers to measure complexity of the code base
  • Integrations with mypy

Removed

Support for Python 3.7

0.1.18 - 2024-05-18

Added

  • Support for lazy loading of services in async clients

0.1.17 - 2024-04-22

Added

  • Support for custom message parsing in both async and sync clients

Removed

  • Removed singular FileDescriptor getter methods and Method specific field descriptor methods as laid out previously.

0.1.16 - 2024-03-03

Added

  • Additional usage examples

Fixed

  • Put deprecation warnings in the correct place for old get_descriptor methods, so they do not warn at all times.

0.1.15 - 2024-02-17

Added

  • Add methods to return FileDescriptors and their transistive dependencies as requested by either a name or symbol
  • Add option to skip automatic checking of method availability

Deprecated

  • Due to the possibility of transient dependencies being missed, or other name or symbol collisions, methods to access singular FileDescriptors are deprecated and will be removed in version 0.1.17
  • The method to retrieve fields of a method's descriptor input type alone will be removed in version 0.1.17

0.1.14 - 2024-01-06

Added

  • MethodMetaData accessible to clients
  • MethodDescriptors accessible via MethodMetaData
  • When using ReflectionClients, FileDescriptors accessible by name and symbol
  • New examples documented

0.1.13 - 2023-12-03

Added

  • Added channel interceptors for standard and async clients

Fixed

  • Refactored how methods and services are added to description pool to better avoid cases where FileDescriptors may be added twice.

0.1.12 - 2023-11-26

Added

  • Method to print out a generic descriptor added to utils collection
  • Helper methods to print out a method's request and responses in a human readable format

Changed

  • Documentation revamped
  • Version checks to avoid using deprecated methods added to async client

Fixed

  • Include requirements.txt in build manifest

Deprecated

  • Method to retrieve fields for the descriptor of a method's input type.

0.1.11 - 2023-10-05

Added

  • Method to retrieve fields for the descriptor of a method's input type.

Changes

  • Updates to minimum versons of requirements to address vulnerabilities

0.1.10 - 2023-03-07

Fixed

  • Corrected pin of protobuf version in requirements.txt

0.1.9 - 2023-02-14

Changes

  • Reimplementation of test case framework
  • Restoration of reflection client test cases
  • Updates to continuous integration pipeline

0.1.8 - 2023-01-24

Changes

  • Update project and dev dependencies to versions that require Python >= 3.7
  • Update project documentation and examples

0.1.7 - 2022-12-16

Deprecated

  • homi dependency, as the project has been archived
  • homi dependent test code

0.1.6 - 2022-11-10

Fixed

  • Ignore repeat imports of protobufs and reflecting against a server

0.1.3 - 2022-7-14

Fixed

  • remove click

Issues

  • ignore test before deploy

0.1.2 - 2022-7-7

0.1.1 - 2022-6-13

Changes

  • remove unused package : click #35

0.1.0 - 2021-8-21

Added

  • Full TLS connection support

Fixed

  • Ignore reflection if service already registered

Changed

  • Update grpcio version

0.0.10 - 2021-2-27

Fixed

  • Fix 3.6 compatibility issue : await is in f-string

0.0.9 - 2020-12-25

Added

  • Support AsyncIO API

0.0.8 - 2020-11-24

Added

  • Add StubClient

Fixed

  • Bypasss kwargs to base client

0.0.7 - 2020-10-4

Added

  • Support Compression

0.0.6 - 2020-10-3

Added

  • Support TLS connections

0.0.5 - 2020-9-9

Changed

  • Response filled gets original proto field name rather than(before returned lowerCamelCase)

0.0.4 - 2020-7-21

0.0.3 - 2020-7-21

Added

  • Dynamic request method
  • Service client

0.0.2 - 2020-7-20

Added

  • Support all method types
  • Add request test case

0.0.1 - 2020-7-20

Added

  • Sync proto using reflection
  • Auto convert request(response) from(to) dict
  • Support unary-unary

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grpc_requests-0.1.21.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grpc_requests-0.1.21-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file grpc_requests-0.1.21.tar.gz.

File metadata

  • Download URL: grpc_requests-0.1.21.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for grpc_requests-0.1.21.tar.gz
Algorithm Hash digest
SHA256 9525bcbc5439f334b39248b9bd867313631e74530cfde1aaf43e76be0298bf20
MD5 e933897ca5e3ad723b17e2e46a957f84
BLAKE2b-256 97587e2be40bad0964f7d6f1c11f72be941c19575ab426c10e1b97e17aa1e42f

See more details on using hashes here.

Provenance

The following attestation bundles were made for grpc_requests-0.1.21.tar.gz:

Publisher: package.yaml on grpc-requests/grpc_requests

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grpc_requests-0.1.21-py3-none-any.whl.

File metadata

  • Download URL: grpc_requests-0.1.21-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for grpc_requests-0.1.21-py3-none-any.whl
Algorithm Hash digest
SHA256 404548236df4af0f6a4d8a46841d3697b78037aa4cb3750326ddc226a3b58a0c
MD5 00cc01a57fb504ee99d1d0d3a24c86d4
BLAKE2b-256 e019bdd6aea13bad40f125d305e99401385a3edce3631c69fa9d546468f04f10

See more details on using hashes here.

Provenance

The following attestation bundles were made for grpc_requests-0.1.21-py3-none-any.whl:

Publisher: package.yaml on grpc-requests/grpc_requests

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page