Skip to main content

homi

PyPI - Python Version PyPI PyPI download month codecov ViewCount

micro grpc framework like flask

install

pip install homi

Feature

  • config less to run server
  • use decorator pattern to connect service method
  • auto parse request data to dict, you don't use grpc request object
  • auto set argument what you want
  • support all grpc service type(unary-unary,unary-stream,stream-unary,stream-stream)
  • TLS support
  • you just return dict type, not grpc object
  • support async grpc server
  • test your server very easy(HomiRealServerTestCase(support sync & async server), HomiTestCase(only sync server))

Example

check more example

from homi import App, Server
from homi.extend.service import reflection_service, health_service


from helloworld_pb2 import DESCRIPTOR

svc_desc = DESCRIPTOR.services_by_name['Greeter']

app = App(
    services=[
        svc_desc,
        reflection_service,
        health_service,
    ]
)

# unary-unary method
@app.method('helloworld.Greeter')
def SayHello(name, **kwargs):
    print(f"{name} is request SayHello")
    return {"message": f"Hello {name}!"}


# or 
@app.method('helloworld.Greeter','SayHello')
def hello(request,context):
    print(f"{request.name} is request SayHello")
    return {"message": f"Hello {request.name}!"}

# or
def hello_func(request,context):
    return {"message":"hi"}

app.register_method('helloworld.Greeter','SayHello',hello_func)

if __name__ == '__main__':
    server = Server(app)
    server.run()

Service Example

The service class is similar to the blueprint of flask. You can separate files on a service basis or add services created by others. Also, we will be able to override the method already registered in the future.

from homi import App, Server,Service
from homi.extend.service import reflection_service, health_service

from helloworld_pb2 import DESCRIPTOR

app = App(services=[reflection_service,health_service,])

greeter = Service(DESCRIPTOR.services_by_name['Greeter'])

@greeter.method()
def SayHello(name, **kwargs):
    print(f"{name} is request SayHello")
    return {"message": f"Hello {name}!"}

# you can share service to pypi
app.add_service(greeter)

run server

# if app file name is app.py
homi run

# run ohter app file
homi run other_app.py

# change port
homi run -p 50055

# change total worker
homi run -w 5

# run TLS server
homi run --private_key server.key --certificate server.crt

Relation Project

  • grpc_requests : GRPC for Humans! python grpc reflection support client

Change Logs

  • 0.2.2

    • HotFix for TypedDict compatibility issue
  • 0.2.1

    • Feature - 3.6, 3.7 compatibility support
  • 0.2.0

    • Feature
      • #37 : support AsyncIO API Server! example
  • 0.1.7

    • Fix Bugs
      • remove HomiRealServerTestCase, HomiTestCase from init.py, please import test class direct
      • add cryptography dependency
  • 0.1.6

    • Feature
      • #30 : support atls server [Experimental]
  • 0.1.5

    • Feature
      • #29 : support tls server
  • 0.1.1

    • Fix Bugs
      • #23 : change support python version >= 3.8 (for TypedDict)
      • #22 : remove handler wrapper self arguments
  • 0.1.0

    • Breaking Change!!! #19
      • Add App
        • now you must make server using App class!
      • Add Service
        • You can separate the code by service or method.
      • Add Config
        • now you can use service config and overwrite in app
  • 0.0.4.alpha

    • add real server testcase
    • support grpc-health
  • 0.0.3

    • support all method type
    • add flak8 lint
    • add test case
    • #9 auto parse response message
  • 0.0.1 (init project)

    • run server using cli
    • helloworld example

Release files for homi 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for homi 0.2.2
File Size Uploaded
homi-0.2.2.tar.gz 19.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for homi 0.2.2
File Interpreter ABI Platform
homi-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size:56.9 kB

Release files / homi-0.2.2.tar.gz

Download URL homi-0.2.2.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
76a44ab2e99d61be6d6610f31ab6ba964a555d8ade35fd47affa0dfaa4223949
BLAKE2b-256 checksum
How to use checksums
c2a4ed01f047f129f1f2389fd957a9a480aaae278fe945ae0dee1ef0f5237bfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Release files / homi-0.2.2-py3-none-any.whl

Download URL homi-0.2.2-py3-none-any.whl
Size 37.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb8e5cc9f7592dac40075da4e2aa6772cb4d3d20ab0f2c8a8e5d1ba16616b418
BLAKE2b-256 checksum
How to use checksums
546e3a58ead490525cdc89a3d26103d28df2ac077f2873a6efa56eac740d6046
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page