vortico / flama Goto Github PK
View Code? Open in Web Editor NEWFire up your models with the flame 🔥
Home Page: https://flama.dev
License: Apache License 2.0
Fire up your models with the flame 🔥
Home Page: https://flama.dev
License: Apache License 2.0
PyYAML is used for parsing route functions docstrings, so it's mandatory to install it along with flama as a proper python requirement.
When using class-based endpoints, if no methods are explicitly passed to add_route
, this will raise an error when generating the schema. (using starlette==0.11.4
, starlette-api==0.6.2
)
from starlette.requests import Request
from starlette.responses import Response
from starlette_api.applications import Starlette
from starlette_api.endpoints import HTTPEndpoint
app = Starlette(
title="Test",
version="1.0",
description="Test",
schema="/schema/",
docs="/docs/",
redoc="/redoc/",
)
class FooEndpoint(HTTPEndpoint):
async def get(self, request: Request):
return Response()
async def post(self, request: Request):
return Response()
app.add_route("/", FooEndpoint, name="foo")
Traceback:
INFO: ('127.0.0.1', 53618) - "GET /schema/ HTTP/1.1" 500
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 372, in run_asgi
result = await asgi(self.receive, self.send)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/uvicorn/middleware/debug.py", line 83, in __call__
raise exc from None
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/uvicorn/middleware/debug.py", line 80, in __call__
await asgi(receive, self.send)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette/middleware/errors.py", line 125, in asgi
raise exc from None
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette/middleware/errors.py", line 103, in asgi
await asgi(receive, _send)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette/exceptions.py", line 74, in app
raise exc from None
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette/exceptions.py", line 63, in app
await instance(receive, sender)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette_api/routing.py", line 174, in awaitable
response = await run_in_threadpool(injected_func)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette/concurrency.py", line 24, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette_api/schemas.py", line 223, in schema
return OpenAPIResponse(self.schema)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette_api/schemas.py", line 219, in schema
return self.schema_generator.get_schema(self.routes)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette_api/schemas.py", line 175, in get_schema
self.spec.add_path(path=path, operations={e.method: self.get_endpoint_schema(e) for e in endpoints})
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette_api/schemas.py", line 175, in <dictcomp>
self.spec.add_path(path=path, operations={e.method: self.get_endpoint_schema(e) for e in endpoints})
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette_api/schemas.py", line 156, in get_endpoint_schema
self.get_endpoint_parameters_schema(endpoint, schema)
File "/Users/test/.virtualenvs/play/lib/python3.7/site-packages/starlette_api/schemas.py", line 114, in get_endpoint_parameters_schema
for field in itertools.chain(endpoint.query_fields.values(), endpoint.path_fields.values())
AttributeError: 'NoneType' object has no attribute 'values'
The link at https://pypi.org/project/starlette-api/ still points to https://starlette-api.perdy.io/. Maybe you can add a permanent redirect to the new homepage.
Create a BackgroundTask that doesn't run in main process to avoid the issue that emerges from encode/starlete#919.
Add BackgroundTasks via an injectable.
Hi, I'm investigating the feasibility of implementing the JSON API specification with Flama.
It's probably easy to add a JSON API codec to Flama using marshmallow-jsonapi.
The other parts, like which status codes to return and what query parameters should look like, are possibly harder to achieve without messing with Flama internals.
Would you agree with this quick assessment or do you think it would be easier than I'm currently thinking?
Example view list_puppies
on Readme doesn't work as expected according function description.
When parameter name
is None
the list comprehension results in an empty list instead of returning the entire puppies
list.
Self-explanatory
Do you have a way or have a way planned on how to document multiple responses from an endpoint?
I would like to be able to document, for example, error responses from an endpoint such as BadRequest or validation errors and have that openapi information show up in the schema served to the swagger/redoc ui. It would also be nice to allow the @output_validation
decorator could "validate" these as well if possible.
For reference, another somewhat similar framework has the same open question: tiangolo/fastapi#16
Thanks for any info!
It would be desirable to allow creating routes like this:
@app.get("/foo/")
def foo():
return {"message": "foo"}
as a shortcut for:
@app.route("/foo/", methods=["GET"])
def foo():
return {"message": "foo"}
Currently Flama applications provide a way to mount Router
and any other ASGI application, but it's not possible to mount another Flama
instance as a child.
Sorry, but I can't fix one issue because there is an issue with the dependencies and I don't know why.
poetry install
for the installation of the dependencies, it tries to install marshmallow 3.0.0rc4, but in the pyproject.toml
file, it's 2.19.0
.poetry.lock
file.and because I don't know poetry
I have to learn the project and try to fix the issue with the dependency.
Which version of marshmallow
do you want to use? 3.0.0rc4 or 2.19.0 ?
Thanks you
Create a modules system that allows to extend Flama's default application.
Create Issue templates for:
Split make file into multiple bash scripts, one for each action. Also generate a Makefile to run those scrips.
Follow scripts to rule them all:
https://github.com/github/scripts-to-rule-them-all
Here is an example of Python’s implementation of those scripts:
@perdy do you use a communication channel? IRC or whatever, I have some questions for you
The branding/logo of this project is great and "Flama" is a nicer name than its FastAPI competitor. However, the "with this flamethrower" tagline is overly narrow. Why is an API like a flamethrower? Just ends up sounding weird.
I suggest you just make the tagline "Fire up your API". Simple.
Here we can follow the resolution of uvloop building issue in Python 3.8: MagicStack/uvloop#266 and MagicStack/uvloop#277
Improve the package interface by exporting the basics in main __init__.py
Add typesystem as a new lib available for generating schemas.
Integrate mypy with Flama, fix all typing errors and modify the github actions flow to include it.
Specify how to:
objective
can have api from cli
e.g.
request.headers['api_key']
curl -X GET -i http://localhost:8000/api/http_api_key/instrument/ -H 'api_key: stifix'
request.query_params
curl -X PUT -i "http://localhost:8000/api/put/instrument/2?name=name0&strings=0"
request.form()
curl -X PUT -d "name=name1&strings=1" -i http://localhost:8000/api/put/instrument/2
request.json()
curl -X PUT -d '{"name": "name2", "strings": 2}' -i http://localhost:8000/api/put_json/instrument/2
in starlette we can use request
e.g.
def test(request):
request.headers['api_key']
request.query_params
request.form()
request.json()
since flama is base on starlette, what is equivalent of starlette request above ?
thanks
Currently FLM files include both the model binary and the metadata associated to such model. This is OK for ML projects where models are self-sufficient, i.e. there is no additional dependency on other resources. However, there are situations in which the models might need additional data to be loaded with them. Such data is typically referred to as artifacts. Thus, there is value in making possible the packing of the model along with the additional artifacts needed by them for their correct working.
Using type annotations to define the schema messes with IDEs in cases where the schema's post_load returns a different object.
Example:
import marshmallow as ma
import marshmallow.fields as mf
@dataclass
class Foo:
foo: str
bar: int
class FooSchema(ma.Schema):
foo = mf.String()
bar = mf.Integer(missing=2)
@ma.post_load
def make_object(self, data, **kwargs):
return Foo(**data)
@app.route('/', methods=['GET'])
def endpoint(data: FooSchema) -> FooSchema:
logger.info(f'{type(data)} - {data}')
return data
In this case, data would be and instance of Foo, but the IDE would give type hints for FooSchema.
The same would be true for the response. I'd like to be able to return the instance of Foo, and it be automatically serialized using FooSchema.
Additionally, marshmallow-dataclass allows us to create a dataclass that has an additional Schema field that we can use to automatically get the schema.
I suggest something like the following:
import logging
from dataclasses import dataclass
from typing import Dict
import marshmallow as ma
import marshmallow.fields as mf
from flama import Flama
from marshmallow_dataclass import dataclass as ma_dataclass
logger = logging.getLogger(__name__)
# Application
app = Flama(
components=[], # Without custom components
title="Foo", # API title
version="0.1", # API version
description="Bar", # API description
schema="/schema/", # Path to expose OpenAPI schema
docs="/docs/", # Path to expose Swagger UI docs
redoc="/redoc/", # Path to expose ReDoc docs
)
@ma_dataclass
class Foo2:
foo: str
bar: int
@dataclass
class Foo:
foo: str
bar: int
class FooSchema(ma.Schema):
foo = mf.String()
bar = mf.Integer(missing=2)
@ma.post_load
def make_object(self, data, **kwargs):
return Foo(**data)
# Add decorator to add the schemas to the function, we can then use this during doc generation and data serialization.
def schemas(
response_schema: ma.Schema = None,
**request_schemas: Dict[str, ma.Schema]
):
def decorator(fn):
fn._request_schemas = request_schemas
fn._response_schema = response_schema
return fn
return decorator
@app.route('/1', methods=['GET'])
def endpoint(data: FooSchema) -> FooSchema:
logger.info(f'{type(data)} - {data}')
return data
@app.route('/2', methods=['GET'])
@schemas(data=FooSchema, response_schema=FooSchema)
def endpoint2(data: Foo) -> Foo:
logger.info(f'{type(data)} - {data}')
return data
@app.route('/3', methods=['GET'])
def endpoint3(data: Foo2) -> Foo2:
logger.info(f'{type(data)} - {data}')
return data
apispec is marked optional in the pyproject.toml
file and this one is not installed via pip
See https://github.com/PeRDy/starlette-api/blob/master/pyproject.toml#L17
But in this https://github.com/PeRDy/starlette-api/blob/master/starlette_api/schemas.py#L9 , there is an import where the package is not optional.
At the moment, the model serialisation builds a binary which contains:
Whilst this is OK, and it's allowed us keep making progress, we might highly benefit from having a much richer structure. Our previous discussion seems to point at something like:
{
"data": {
"binary": b"...",
},
"meta": {
"id": ...,
"timestamp": ...,
"framework": {
"lib": "...",
"version": "...",
},
"model": {
"class": "...",
"info": {**info},
"params": {**hyperparams},
"metrics": {**metrics},
},
"extra": {
**free_info
},
},
}
This will change the current implementation in model.py. Essentially, it will have to extend the dataclass:
@dataclasses.dataclass(frozen=True)
class Model:
"""ML Model wrapper to provide mechanisms for serialization and deserialization using Flama format."""
lib: ModelFormat
model: typing.Any
to accomodate the previous JSON structure.
Helpful links:
model.output_shape # model summary representation
model.summary() # model configuration
model.get_config() # list all weight tensors in the model
model.get_weights() # get weights and biases
Current HTTPException init method is too specific for it s detail parameter types:
def __init__(
self,
status_code: int,
detail: t.Optional[t.Union[str, t.Dict[str, t.List[str]]]] = None,
headers: t.Optional[dict] = None,
) -> None:
...
It could be the more generic t.Optional[t.Union[str, t.Dict[str, t.Any]]]
.
I have added this test in tests/test_endpoints
You can check here:
master...matrixise:test_resources_many
def test_nested_api(self, app, client):
class Resource(marshmallow.Schema):
name = marshmallow.fields.String()
@app.route('/resources', methods=['GET'])
class ResourcesHTTPEndpoint(HTTPEndpoint):
async def get(self) -> Resource(many=True):
return [{'name': 'Name'}]
response = client.get('/resources')
assert response.status_code == 200
but I get this exception because you are waiting for a class and not an instance, but in the case of Resource(many=True)
it's an instance.
Do you know why?
tests/test_endpoints.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/requests/sessions.py:546: in get
return self.request('GET', url, **kwargs)
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/starlette/testclient.py:382: in request
json=json,
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/requests/sessions.py:533: in request
resp = self.send(prep, **send_kwargs)
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/requests/sessions.py:646: in send
r = adapter.send(request, **kwargs)
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/starlette/testclient.py:211: in send
raise exc from None
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/starlette/testclient.py:208: in send
loop.run_until_complete(connection(receive, send))
/usr/lib64/python3.7/asyncio/base_events.py:584: in run_until_complete
return future.result()
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/starlette/middleware/errors.py:125: in asgi
raise exc from None
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/starlette/middleware/errors.py:103: in asgi
await asgi(receive, _send)
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/starlette/exceptions.py:74: in app
raise exc from None
../../../../.virtualenvs/tempenv-713715370977/lib/python3.7/site-packages/starlette/exceptions.py:63: in app
await instance(receive, sender)
starlette_api/endpoints.py:37: in __call__
response = await self.dispatch(request, state, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.test_endpoints.TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint object at 0x7f0193c775c0>, request = <starlette.requests.Request object at 0x7f0193c776a0>
state = {'app': <starlette_api.applications.Starlette object at 0x7f0193c52cf8>, 'exc': None, 'path_params': {}, 'receive': <function _ASGIAdapter.send.<locals>.receive at 0x7f0193ca7bf8>, ...}
kwargs = {}, handler_name = 'get'
handler = <bound method TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint.get of <tests.test_endpoints.TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint object at 0x7f0193c775c0>>
app = <starlette_api.applications.Starlette object at 0x7f0193c52cf8>
injected_func = functools.partial(<bound method TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint.get of <tests.test_endpoints.TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint object at 0x7f0193c775c0>>)
response = [{'name': 'Name'}], return_annotation = <Resource(many=True)>
async def dispatch(self, request: Request, state: typing.Dict, **kwargs) -> Response:
handler_name = "get" if request.method == "HEAD" else request.method.lower()
handler = getattr(self, handler_name, self.method_not_allowed)
app = state["app"]
injected_func = await app.injector.inject(handler, state)
if asyncio.iscoroutinefunction(handler):
response = await injected_func()
else:
response = injected_func()
return_annotation = inspect.signature(handler).return_annotation
> if issubclass(return_annotation, marshmallow.Schema):
E TypeError: issubclass() arg 1 must be a class
app = <starlette_api.applications.Starlette object at 0x7f0193c52cf8>
handler = <bound method TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint.get of <tests.test_endpoints.TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint object at 0x7f0193c775c0>>
handler_name = 'get'
injected_func = functools.partial(<bound method TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint.get of <tests.test_endpoints.TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint object at 0x7f0193c775c0>>)
kwargs = {}
request = <starlette.requests.Request object at 0x7f0193c776a0>
response = [{'name': 'Name'}]
return_annotation = <Resource(many=True)>
self = <tests.test_endpoints.TestCaseHTTPEndpoint.test_nested_api.<locals>.ResourcesHTTPEndpoint object at 0x7f0193c775c0>
state = {'app': <starlette_api.applications.Starlette object at 0x7f0193c52cf8>, 'exc': None, 'path_params': {}, 'receive': <function _ASGIAdapter.send.<locals>.receive at 0x7f0193ca7bf8>, ...}
starlette_api/endpoints.py:54: TypeError
Thank you,
Great work! I guess it'd make sense to add Flama to the "Frameworks" section of https://www.starlette.io/third-party-packages/ right?
Because the following version constraints are defined:
apispec = {version = "^1.0",optional = true}
pyyaml = {version = "^3.13",optional = true}
Only apispec 1.x
and pyyaml 3.13.x
will be used/tested when flama[schema]
is installed.
apispec
is on version 3 and pyyaml
is at 5 now. There are numerous useful changes in those projects that can be integrated into flama
.
Hi there,
I just try to plugin authentication from Starlette, but looks like this is not possible.
From Starlette doc
from starlette.authentication import requires
@requires('authenticated')
async def foobar(request, schema: Schema):
pass
This will raise error AttributeError: 'OpenAPIConverter' object has no attribute 'field2parameter'
from flama/schemas.py
Can't omit first parameter request
cause that is required from the requires
decorator for authentication.
Any work around?
Thanks
In order to allow Flama to use multiple schema libs it's necessary to:
Hi,
Here is a very small example when I try to construct an API with starlette-api but I get an error, could you tell me where my error is?
Thank you
import pytest
from marshmallow import Schema
from marshmallow import fields
from starlette.testclient import TestClient
from starlette_api.applications import Starlette
from starlette_api.endpoints import HTTPEndpoint
from starlette_api.routing import Router
class RunnerSchema(Schema):
id = fields.Integer()
name = fields.String()
token = fields.String()
class RunnerEndpoint(HTTPEndpoint):
async def get(self) -> RunnerSchema():
return {"id": 1, "name": "name", "token": "token"}
def create_app():
app = Starlette(
components=[],
title="Foo",
version="0.1",
description="Foo",
schema=False,
docs=False,
debug=False,
)
api = Router()
api.add_route("/runners", RunnerEndpoint, methods=["GET"])
app.mount("/api/v4", api)
return app
@pytest.fixture(scope="function")
def app():
return create_app()
@pytest.fixture(scope="function")
def client(app):
return TestClient(app)
def test_get_runners(client):
response = client.get("/api/v4/runners")
assert response.status_code == 200
assert response.json() == {"id": 1, "name": "name", "token": "token"}
Result of pytest
self = <test_app.RunnerEndpoint object at 0x7f5dcb6c5588>, receive = <function _ASGIAdapter.send.<locals>.receive at 0x7f5dcb16d8c8>
send = <function ExceptionMiddleware.__call__.<locals>.app.<locals>.sender at 0x7f5dcb6c7620>
async def __call__(self, receive: Receive, send: Send):
request = Request(self.scope, receive=receive)
app = self.scope["app"]
kwargs = self.scope.get("kwargs", {})
route, route_scope = app.router.get_route_from_scope(self.scope)
state = {
"scope": self.scope,
"receive": receive,
"send": send,
"exc": None,
"app": app,
> "path_params": route_scope["path_params"],
"route": route,
"request": request,
}
E TypeError: 'NoneType' object is not subscriptable
app = <starlette_api.applications.Starlette object at 0x7f5dcb6ab860>
kwargs = {}
receive = <function _ASGIAdapter.send.<locals>.receive at 0x7f5dcb16d8c8>
request = <starlette.requests.Request object at 0x7f5dcb702a90>
route = <bound method Router.not_found of <starlette_api.routing.Router object at 0x7f5dcb6ab978>>
route_scope = None
self = <test_app.RunnerEndpoint object at 0x7f5dcb6c5588>
send = <function ExceptionMiddleware.__call__.<locals>.app.<locals>.sender at 0x7f5dcb6c7620>
Version of starlette
starlette==0.11.3
starlette-api==0.5.0
Add flake8-mypy to current flake8 configuration to remove the necessity of running mypy on CI.
Modify how Routes and Routers are initialized and how are handling the main application to allow declarative routing for all Routes types.
An example of the goal syntax:
class PuppyResource(BaseResource, metaclass=CRUDResource):
name = "puppy"
model = puppy_model
schema = puppy_schema
routes = [
Route("/", root_mock),
ResourceRoute("/", PuppyResource),
Mount("/foo", routes=[
Route("/", foo_mock, methods=["GET"]),
Route("/view", foo_view_mock, methods=["GET"])
])
]
app = Flama(routes=routes)
The response serialization process (converting it to json) is not allowing to encode uuid objects. It could be desirable to add a transformation of those uuid objects to their string representation as part of the json encoding process.
Hey, folks! :]
It would be great if we had a basic example on how to run this, so it's easier to jump into and contribute as well.
If I have the time, I can do it, but if someone had that already set up, it would be nice!
Thanks!
It's not possible to run a Flama application in debug mode using flama start
command. It could be a good addition to allow flama config files to specify debug mode for applications.
AttributeError: 'MarshmallowPlugin' object has no attribute 'openapi'
apispec==3.1.0
flama==0.11.0
marshmallow==3.3.0
starlette==0.12.13
uvicorn==0.10.8
uvloop==0.14.0
It could be desirable to integrate SQLAlchemy resources (database connection and metadata) as attributes of Flama applications.
Currently encode/databases is a dependency for using Resources. The same behavior could be achieved using SQLAlchemy core instead of databases, reducing the number of dependencies. It could allow the user to choice it own database lib.
Copy-pasting the example from readme produces this:
INFO: ('127.0.0.1', 33118) - "GET / HTTP/1.1" 500
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "<venv>/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 372, in run_asgi
result = await asgi(self.receive, self.send)
File "<venv>/lib/python3.7/site-packages/starlette/middleware/errors.py", line 125, in asgi
raise exc from None
File "<venv>/lib/python3.7/site-packages/starlette/middleware/errors.py", line 103, in asgi
await asgi(receive, _send)
File "<venv>/lib/python3.7/site-packages/starlette/exceptions.py", line 74, in app
raise exc from None
File "<venv>/lib/python3.7/site-packages/starlette/exceptions.py", line 63, in app
await instance(receive, sender)
File "<venv>/lib/python3.7/site-packages/starlette_api/routing.py", line 168, in awaitable
injected_func = await app.injector.inject(endpoint, state)
File "<venv>/lib/python3.7/site-packages/starlette_api/injection.py", line 173, in inject
state[output_name] = resolver(**kw)
File "<venv>/lib/python3.7/site-packages/starlette_api/components/validation.py", line 79, in resolve
query_params = validator().load(dict(query_params), unknown=marshmallow.EXCLUDE)
AttributeError: module 'marshmallow' has no attribute 'EXCLUDE'
UPD: I used starlette-api[full]
for install
Currently there's the extra full
which installs all dependencies. It would nice if I could choose just apispec
and pyyaml
with the correct versions. Would it be possible to provide all optional dependencies as extras?
Hi there,
when trying out the example in the README, I get a strange import error for the typing module:
Traceback (most recent call last):
File "D:/projects/autogram/autogram/api/registrations.py", line 3, in <module>
from flama.applications import Flama
File "C:\Users\joscha.goetzer\.virtualenvs\autogram-PRYPx28t\lib\site-packages\flama\applications.py", line 12, in <module>
from flama.injection import Injector
File "C:\Users\joscha.goetzer\.virtualenvs\autogram-PRYPx28t\lib\site-packages\flama\injection.py", line 8, in <module>
from flama.components.validation import VALIDATION_COMPONENTS
File "C:\Users\joscha.goetzer\.virtualenvs\autogram-PRYPx28t\lib\site-packages\flama\components\validation.py", line 13, in <module>
from flama.routing import Route
File "C:\Users\joscha.goetzer\.virtualenvs\autogram-PRYPx28t\lib\site-packages\flama\routing.py", line 10, in <module>
from starlette.types import ASGIApp, ASGIInstance, Receive, Scope, Send
ImportError: cannot import name 'ASGIInstance'
Am I missing something?
Presumably relates to #12 but it looks like SchemaRegistry
ultimately has a hard dependency on apispec?
https://github.com/perdy/flama/blob/789d140d5ffebcd779c7cbe017ecbf84bdcdaf42/flama/schemas.py#L41
> pip install flama
> pip install uvicorn
> pip freeze
Click==7.0
flama==0.8.0
h11==0.8.1
httptools==0.0.13
marshmallow==3.0.0rc6
starlette==0.11.4
uvicorn==0.7.1
uvloop==0.12.2
websockets==7.0
example file:
from flama.applications import Flama
app = Flama(
components=[], # Without custom components
title="Foo", # API title
version="0.1", # API version
description="Bar", # API description
schema="/schema/", # Path to expose OpenAPI schema
docs="/docs/", # Path to expose Swagger UI docs
redoc="/redoc/", # Path to expose ReDoc docs
)
Run with:
[...]
File "/path/to/python3.6//site-packages/flama/applications.py", line 15, in <module>
from flama.schemas import SchemaMixin
File "/path/to/python3.6//site-packages/flama/schemas.py", line 40, in <module>
class SchemaRegistry(dict):
File "/path/to/python3.6//site-packages/flama/schemas.py", line 41, in SchemaRegistry
def __init__(self, spec: apispec.APISpec, *args, **kwargs):
AttributeError: 'NoneType' object has no attribute 'APISpec'
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.