odd12258053 / agraffe Goto Github PK
View Code? Open in Web Editor NEWAgraffe, build API with ASGI in Serverless services (e.g AWS lambda, Google Cloud Functions and Azure Functions).
License: MIT License
Agraffe, build API with ASGI in Serverless services (e.g AWS lambda, Google Cloud Functions and Azure Functions).
License: MIT License
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
We may be able to detect a service (GCP, AWS, and Azure) using an environment.
ref[Azure]: none...;;
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?
Google Cloud Function pre-release the runtime with python 3.9.
Thus, Agraffe will test with python 3.9 in Google Cloud Function.
The below URL is a claim about The event invoked to call a lambda.
I'll improve HttpCycle
in aws_lambda.py
to support the event.
Hi,
Is it possible to add support for request forms and files as used in FastAPI ? https://fastapi.tiangolo.com/tutorial/request-forms-and-files/
Thank you.
I'd be happy if could use AWS Lambda with agraffe, for programming without being aware of the environment.
Are you considering the support?
When the following service support python3.9, Agraffe will be supporting python3.9.
When the following service support python3.11, Agraffe will be supporting python3.12.
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?
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.