{"id":18547595,"url":"https://github.com/kensho-technologies/eagr","last_synced_at":"2025-04-09T20:31:16.022Z","repository":{"id":55986791,"uuid":"232904801","full_name":"kensho-technologies/eagr","owner":"kensho-technologies","description":"Python gRPC servers and clients, made friendlier","archived":false,"fork":false,"pushed_at":"2020-12-02T19:51:01.000Z","size":94,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T10:44:41.036Z","etag":null,"topics":["grpc","grpc-client","grpc-server","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kensho-technologies.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-09T20:59:40.000Z","updated_at":"2025-03-28T15:37:32.000Z","dependencies_parsed_at":"2022-08-15T10:50:43.014Z","dependency_job_id":null,"html_url":"https://github.com/kensho-technologies/eagr","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kensho-technologies%2Feagr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kensho-technologies%2Feagr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kensho-technologies%2Feagr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kensho-technologies%2Feagr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kensho-technologies","download_url":"https://codeload.github.com/kensho-technologies/eagr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107298,"owners_count":21048896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grpc","grpc-client","grpc-server","python"],"created_at":"2024-11-06T20:30:05.388Z","updated_at":"2025-04-09T20:31:15.511Z","avatar_url":"https://github.com/kensho-technologies.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eagr\n\n\u003ca href=\"https://travis-ci.com/kensho-technologies/eagr\"\u003e\u003cimg alt=\"Build Status\" src=\"https://travis-ci.com/kensho-technologies/eagr.svg?branch=master\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\u003cimg alt=\"License: Apache 2.0\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/eagr/\"\u003e\u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/eagr\"\u003e\u003c/a\u003e\n\nEasy and Abstracted gRPC. A collection of utilities for making GRPC easier to use in python. This package is widely used within Kensho.\n\n`pip install eagr`\n\n## Server\n\nFunctionality to simplify running grpc services. Provides a common set of metrics and logging\n\n\n### Sample usage:\n\n```python\nimport time\nfrom eagr import (\n    GRPCBase,\n    run_grpc_servers,\n)\n\n\n# UserServicer is from generated proto\nclass UserService(GRPCBase, UserServicer):\n    # Set to generated proto add_\u003c\u003e_to_server function\n    _REGISTRAR = None\n\n    def Create(self, request, context):\n        return User(name='louis')\n\n\ndef start_server():\n    user_service = UserService()\n    with run_grpc_servers((user_service,), grpc_port=9000, metrics_port=9001):\n        while True:\n            print(\"Server running.\")\n            time.sleep(100)\n```\n\n\n## Client\n\nFunctionality to simplify instantiating a client as well as wrapping it with metrics, logging, etc\n\n### Sample usage:\n\n```python\nfrom eagr import make_grpc_client\n\nfrom your_service_pb2_gprc import YourServiceStub\n\n\nclient = make_grpc_client(\n    \"client group for metrics\", \"service name\", \"service url\", YourServiceStub\n)\n```\n\n\n## REST Passthrough\n\n[Functionality to bind unary grpc methods to Flask handlers](eagr/flask_bridge/Readme.md)\n\n\n## Unittest Server\n\n\nFunctionality to create an in-process server for unittesting\n\n\n### Sample usage:\n\n\n```python\nimport unittest\nfrom unittest.mock import MagicMock\n\nfrom eagr import inprocess_grpc_server, make_grpc_client\n\nfrom your_service_pb2_gprc import YourServicer, YourServiceStub, add_YourServicer_to_server\n\n\nclass TestMyClient(unittest.TestClient):\n\n    def test_something(self):\n        mock_servicer = MagicMock(YourServicer)\n        mock_servicer.FooBar = lambda x, _: x\n        with inprocess_grpc_server(mock_servicer, add_YourServicer_to_server) as address:\n            client = make_grpc_client(\"foo\", \"bar\", address, YourServiceStub)\n            baz = \u003cyour input here\u003e\n            self.assertEqual(baz, client.FooBar(baz))\n```\n\n\n## GRPC Reflection Interface\n\nFunctionality to create a generic GRPC client based on a GRPC server that has reflection enabled.\n\n### Sample usage:\n\n```python\nfrom eagr.reflection import grpc_reflection_interface\n\n\nhost = \"myhost\"\nservice = \"MyService\"\nparams = {\n    \"keyfoo\": \"valuebar\"\n}\ngeneric_myservice_client = grpc_reflection_interface.make_json_grpc_client(host, service)\n\nmy_grpc_response = generic_myservice_client[\"my_grpc_method\"](params)\n```\n\nNote: This currently only works for unary-unary method types. Adding functionality for stream methods is being looked into and is in the pipeline for future development.\n\n\n# License\n\nLicensed under the Apache 2.0 License. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright 2020-present Kensho Technologies, LLC. The present date is determined by the timestamp of the most recent commit in the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkensho-technologies%2Feagr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkensho-technologies%2Feagr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkensho-technologies%2Feagr/lists"}