GithubHelp home page GithubHelp logo

odd12258053 / agraffe Goto Github PK

View Code? Open in Web Editor NEW
49.0 49.0 4.0 325 KB

Agraffe, build API with ASGI in Serverless services (e.g AWS lambda, Google Cloud Functions and Azure Functions).

License: MIT License

Makefile 0.17% Python 99.83%
asgi async asyncio aws-lambda azure-functions fastapi gcp-cloud-functions python python3 serverless serverless-services starlette web

agraffe's People

Contributors

itok01 avatar odd12258053 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

agraffe's Issues

It stopped working with Google Cloud Functions.

It stopped working with Google Cloud Functions after 2021-08-15 09:00.
I didn't change the application code at the occurrences time.

The occurrences error is below.

Traceback (most recent call last): File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py", line 402, in run_http_function result = _function_handler.invoke_user_function(flask.request) File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py", line 268, in invoke_user_function return call_user_function(request_or_event) File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py", line 261, in call_user_function return self._user_function(request_or_event) File "/env/local/lib/python3.7/site-packages/agraffe/__init__.py", line 38, in _entry_point4gcf return cls(app, GCPHttpCycle)(request=request) File "/env/local/lib/python3.7/site-packages/agraffe/__init__.py", line 27, in __call__ cycle(app=self.app) File "/env/local/lib/python3.7/site-packages/agraffe/services/base.py", line 21, in __call__ loop.run_until_complete(task) File "/opt/python3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete return future.result() File "/env/local/lib/python3.7/site-packages/agraffe/services/base.py", line 39, in run await app(self.scope, self.receive, self.send) File "/env/local/lib/python3.7/site-packages/fastapi/applications.py", line 208, in __call__ await super().__call__(scope, receive, send) File "/env/local/lib/python3.7/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/env/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in __call__ raise exc from None File "/env/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__ await self.app(scope, receive, _send) File "/env/local/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__ raise exc from None File "/env/local/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__ await self.app(scope, receive, sender) File "/env/local/lib/python3.7/site-packages/starlette/routing.py", line 580, in __call__ await route.handle(scope, receive, send) File "/env/local/lib/python3.7/site-packages/starlette/routing.py", line 241, in handle await self.app(scope, receive, send) File "/env/local/lib/python3.7/site-packages/starlette/routing.py", line 52, in app response = await func(request) File "/env/local/lib/python3.7/site-packages/fastapi/routing.py", line 220, in app dependant=dependant, values=values, is_coroutine=is_coroutine File "/env/local/lib/python3.7/site-packages/fastapi/routing.py", line 152, in run_endpoint_function return await dependant.call(**values) File "/user_code/monitapi/__init__.py", line 28, in monitoring_with_get await watch() File "/user_code/monitapi/monitoring/monitor.py", line 178, in watch results = await asyncio.gather(*monitors) File "/user_code/monitapi/monitoring/monitor.py", line 81, in monitor_http response=await response.text() if response else error) File "/env/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 1076, in text await self.read() File "/env/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 1032, in read self._body = await self.content.read() File "/env/local/lib/python3.7/site-packages/aiohttp/streams.py", line 370, in read block = await self.readany() File "/env/local/lib/python3.7/site-packages/aiohttp/streams.py", line 392, in readany await self._wait("readany") File "/env/local/lib/python3.7/site-packages/aiohttp/streams.py", line 306, in _wait await waiter File "/env/local/lib/python3.7/site-packages/aiohttp/helpers.py", line 656, in __exit__ raise asyncio.TimeoutError from None concurrent.futures._base.TimeoutError

An error was sent from API Gateway by AWS Lambda.

When I deployed to AWS Lambda and request to API Gateway, the following error was sent.

[ERROR] KeyError: 'multiValueQueryStringParameters'
Traceback (most recent call last):
  File "/var/task/agraffe/__init__.py", line 57, in _entry_point4aws_lambda
    request={'event': event, 'context': context}
  File "/var/task/agraffe/__init__.py", line 39, in __call__
    cycle(app=self.app)
  File "/var/task/agraffe/services/base.py", line 20, in __call__
    loop.run_until_complete(task)
  File "/var/lang/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/var/task/agraffe/services/base.py", line 38, in run
    await app(self.scope, self.receive, self.send)
  File "/var/task/agraffe/services/aws_lambda.py", line 21, in scope
    query_string = '&'.join(gene_query_string()).encode()
  File "/var/task/agraffe/services/aws_lambda.py", line 16, in gene_query_string
    params = event['multiValueQueryStringParameters'] or 
{}

Displayed settings of API gateway in AWS Lambda is below.

API endpoint: ****
Authorization: NONE
Method: GET
Resource path: /monitoring
Stage: default

The response message by API is below.

{}

Do I have the resolve method?

Support for Python 3.9.

When the following service support python3.9, Agraffe will be supporting python3.9.

  • Google Cloud Functions
  • AWS lambda
  • Azure Functions

Support for Python 3.12

When the following service support python3.11, Agraffe will be supporting python3.12.

  • Google Cloud Functions
  • AWS lambda
  • Azure Functions

The response cannot be serialized normally.

If return the response using Dict or jsonable_encoder, the following error will be sent.

[ERROR] Runtime.MarshalError: Unable to marshal response: b'{}' is not JSON serializable

Do I have the resolve method?

can deploy to google cloud 2nd generation, but cannot run locally with uvicorn

I can deploy to google cloud 2nd generation, but cannot run locally with uvicorn.

from agraffe import Agraffe
from fastapi import FastAPI
from agraffe.services.google_cloud_functions import HttpCycle

app = FastAPI(
title="RAG API",
description="RAG Microservice",
version="2.0.0",
root_path="/api_rag_v3/",
servers=[
{"url": "/"}
]
)

.... ....

api_rag_v3 = Agraffe.entry_point(app)

def api_rag_v3(request):
return Agraffe(app, HttpCycle)(request=request)

running

uvicorn main:app --reload

got

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/XXXX/back-rag/./main.py", line 1, in
from agraffe import Agraffe
ModuleNotFoundError: No module named 'agraffe'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.