aio-libs / aiohttp-demos Goto Github PK
View Code? Open in Web Editor NEWDemos for aiohttp project
Home Page: https://demos.aiohttp.org
License: Other
Demos for aiohttp project
Home Page: https://demos.aiohttp.org
License: Other
Hello,
I'm currently referring polls demo for developing aiohttp server app.
One question is, there are guide about defining model in tutorial document, and it said model can be defined as class instead of using table.
class Question(Base):
__tablename__ = 'question'
id = Column(Integer, primary_key=True)
question_text = Column(String(200), nullable=False)
pub_date = Column(Date, nullable=False)
Is there any sample to develop in this way?
Thanks.
The model in moderator/moderator_bot appears to be a pickled object, but this no longer works on the latest scikit-learn releases due to a module restructuring. Does anybody know how to rebuild the model? (@jettify?)
Some of our database code will fail on sqlalchemy 2 and needs updating, for example: https://github.com/aio-libs/aiohttp-demos/blob/master/demos/blog/db_helpers.py
On a side note, we should also remove the autocommit from that.
./docs/conf.py
etc. sphinx-quickstart
could help./docs/conf.py
from aiohttp)./Makefile
with make doc
and make doc-spelling
. Borrow implementation from aiohttp./.travis.yml
with docs checkI bet someone has code to share, would be nice to see blog demo here.
Hi.
I have carefully followed the document instruction and when I execute the "sudo make prepare_database" command then I am getting the below error.
deeplearning@XXX: ~/Desktop/ML_Practise/aiohttp-demos/demos/graphql$ sudo make start_database
Starting graphql_postgres_1 ... done
deeplearning@XXX: ~/Desktop/ML_Practise/aiohttp-demos/demos/graphql$ sudo make start_redis
Starting graphql_redis_1 ... done
deeplearning@XXX: ~/Desktop/ML_Practise/aiohttp-demos/demos/graphql$ sudo make prepare_database
Start to generate a new data...
Traceback (most recent call last):
File "prepare_database.py", line 153, in
loop.run_until_complete(main())
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "prepare_database.py", line 142, in main
users = await generate_users(conn, 20)
File "prepare_database.py", line 88, in generate_users
return [user[0] for user in response]
TypeError: 'ResultProxy' object is not iterable
/usr/local/lib/python3.6/dist-packages/aiopg/pool.py:310: ResourceWarning: Unclosed 1 connections in <aiopg.pool.Pool object at 0x7f5b4ad8ac18>
Makefile:26: recipe for target 'prepare_database' failed
make: *** [prepare_database] Error 1
also when I execute the Make Run command I am getting below error.
deeplearning@XXX :~/Desktop/ML_Practise/aiohttp-demos/demos/graphql$ sudo make run
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/deeplearning/Desktop/ML_Practise/aiohttp-demos/demos/graphql/graph/main.py", line 3, in
from .app import init_app
File "/home/deeplearning/Desktop/ML_Practise/aiohttp-demos/demos/graphql/graph/app.py", line 10, in
from graph.routes import init_routes
File "/home/deeplearning/Desktop/ML_Practise/aiohttp-demos/demos/graphql/graph/routes.py", line 3, in
from graph.api.views import (
File "/home/deeplearning/Desktop/ML_Practise/aiohttp-demos/demos/graphql/graph/api/views.py", line 3, in
import graphene
File "/usr/local/lib/python3.6/dist-packages/graphene/init.py", line 3, in
from .types import (
File "/usr/local/lib/python3.6/dist-packages/graphene/types/init.py", line 2, in
from graphql import ResolveInfo
ImportError: cannot import name 'ResolveInfo'
Makefile:8: recipe for target 'run' failed
make: *** [run] Error 1
please advise.
GraphQl is very popular, so i think it is good idea show how look simple GraphQL api.
What i want to do:
create graphQl api
add graphIQl view for interactive work with data
add tests
Does anyone have a suggestion before I start?
Also add make test
command etc -- as we have for aiohttp.
Tags as in usual blogs, so it is possible to sort records by it.
Hi.
I am trying to run the aiohttp - demo (ImageTagger) project in PyCharm 2019.x but it throwing some errors like below,
Error 1 :
Using TensorFlow backend.
C:\Users\saddam.X.XXXX\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
Error 2:
ImportError: cannot import name 'routes'
etc...
Can anyone guide me on how to run this ImageTagger app?
Environment"
Ubuntu on Vmware.
python3.6
In https://aiohttp-demos.readthedocs.io/en/latest/tutorial.html
Databse section
# polls/init_db.py
from sqlalchemy import create_engine, MetaData
from settings import config
from db import question, choice
from settings import config
from db import question, choice
both statements should be:
from aiohttpdemo_polls.settings import config
from aiohttpdemo_polls.settings import question, choice
Hi.
Long story in short:
I carefully followed the instruciton provided in the document and when I run the Make run command then I am getting the below error.
aiohttp-keras-demo$ make run
python -m image tagger
make: python: Command not found
Makefile:34: recipe for target 'run' failed
make: *** [run] Error 127
environment:
python 3.6.8
ubuntu os onb VMware.
please advise .
The shortify demo has no tests, and probably doesn't work anymore.
We should add a couple of basic tests to verify it is atleast somewhat working with future updates.
Lots of people using aiohttp client to crawl internet [1], I think to encourage good practices and idiomatic approach it is good idea to have specific demo for this purposes. Good starting point is [2]
[1] https://medium.com/@cgarciae/making-an-infinite-number-of-requests-with-python-aiohttp-pypeln-3a552b97dc95
[2] http://www.aosabook.org/en/500L/a-web-crawler-with-asyncio-coroutines.html
so confuse.
the polls example,why run 'python init_db.py' show information that 'ModuleNotFoundError: No module named 'utils''??
Would be nice to have an ability to run the demo under gunicorn.
Need a gunicorn entrypoint file.
See https://stackoverflow.com/questions/47266296/running-aiohttp-server-using-gunicorn
I have working code of very simple API with react UI, that classifies offensive and toxic comments. I think it should be good addition for aiohttp use cases. I still need to do some clean up, after will copy app here.
"services" is missing in docker-compose file as below
redis:
image: redis:6
ports:
- 6379:6379
Because of which im getting error while bringing up redis container
Should be easy to do and good exercise. Would be cool to have some sort of social auth via github/twitter/google integration.
Some examples:
https://github.com/skftn/flask-pastebin
https://github.com/mitsuhiko/flask-pastebin
While seeding the polls data in polls app the population is not getting reflected in database. Seems like the the auto-commit is not enabled by default because when I am doing conn.commit()
the seeding works.
Code line: https://github.com/aio-libs/aiohttp-demos/blob/master/docs/tutorial.rst?plain=1#L350 (Adding conn.commit()
above this line, before doing conn.close()
populates the data correctly.)
Commit as you go reference: https://docs.sqlalchemy.org/en/20/core/connections.html#commit-as-you-go
I am happy to contribute if this is an issue and would love to know your thought on this.
Thank you!
It would probably a good idea to replace trafaret/trafaret-config with pydantic. Trafaret seems somewhat unmaintained and doesn't have any static typing support. Pydantic is likely a better option to use here.
PRs currently require TravisCI to pass, but it no longer runs.
This presumably needs to be updated to github workflows.
Running the example moderator with aiohttp=3.8.3
rise a error when POST:
ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
File "/Users/kunshu/opt/anaconda3/envs/aio38/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/Users/kunshu/opt/anaconda3/envs/aio38/lib/python3.8/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/Users/Kunshu/Work/aiohttp-demos/demos/moderator/moderator/handlers.py", line 26, in moderate
results = await run(self._executor, predict_probability, features)
RuntimeError: Task <Task pending name='Task-8' coro=<RequestHandler._handle_request() running at /Users/kunshu/opt/anaconda3/envs/aio38/lib/python3.8/site-packages/aiohttp/web_protocol.py:433> cb=[<TaskWakeupMethWrapper object at 0x103d47ca0>()]> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /Users/kunshu/opt/anaconda3/envs/aio38/lib/python3.8/asyncio/futures.py:360]> attached to a different loop
While I tried to use aiohttp==3.7.4
, it worked without the error.
By the way, the model example used rises a ModuleNotFoundError: No module named 'sklearn.linear_model.logistic'
error with sciki-learn==1.1.2
. Downgrade to scikit-learn==0.23.2
solves the problem.
The motortwit demo has no tests, and probably doesn't work anymore.
We should add a couple of basic tests to verify it is atleast somewhat working with future updates.
I would like to update/fix tests for demo polls app.
Let's start with simplest test scenarios:
res = await conn.execute(choice.count())
)But there are a couple of questions I need to clarify first.
Could anyone with experience in testing async code share his view or examples I can look at? Thanks.
Hi,
Any plans to add typing to all demos?
So far, it hasn't been too hard to add typing to my code using aiohttp's websockets. However, it is a bit tricky to navigate aiohttp's code to find what and where the types are.
I think that adding typing to all demos would help new comers.
На этой странице https://aiohttp-demos.readthedocs.io/en/latest/tutorial.html
Начиная с раздела Databases::Creating connection engine непонятно в какие файлы вставлять код, приходится смотреть сюда. И с раздела Templates все сыпется.
Это специально чтобы отпугнуть начинающих изучать фреймворк?
Create basic REST API demo that can be used as template to bootstrap project quickly.
Hi!
I'm trying to run chat demo with python main.py
command, and getting this is my traceback :
Traceback (most recent call last):
File "main.py", line 40, in <module>
main()
File "main.py", line 36, in main
web.run_app(app)
File "C:\Program Files\Python36\lib\site-packages\aiohttp\web.py", line 54, in run_app
loop.run_until_complete(runner.setup())
File "C:\Program Files\Python36\lib\asyncio\base_events.py", line 467, in run_until_complete
return future.result()
File "C:\Program Files\Python36\lib\site-packages\aiohttp\web_runner.py", line 170, in setup
self._server = await self._make_server()
File "C:\Program Files\Python36\lib\site-packages\aiohttp\web_runner.py", line 262, in _make_server
self._app._set_loop(loop)
AttributeError: 'coroutine' object has no attribute '_set_loop'
sys:1: RuntimeWarning: coroutine 'init_app' was never awaited
How can i fix this??
I try command
python3 aiohttpdemo_blog/main.py -c config/user_config.toml
and get the error/ What i must to do
AttributeError: 'coroutine' object has no attribute '_set_loop'
sys:1: RuntimeWarning: coroutine 'init_app' was never awaited
moderator_bot depends on the abandoned aioslacker library.
We should migrate to https://github.com/slackapi/python-slack-sdk
Alternatively, it might be an idea to migrate to something that integrates with Matrix instead of Slack, as the open source community seems to have largely migrated in that direction.
The repository has no sensitive data, it is a set of demo projects.
Event accidental commit cannot harm much and can be reverted easily.
On another hand, keeping the repo in the good shape is super important.
A few individuals cannot do it well enough as I can see but lowering the bar can attract help from contributors around the world.
Ideally, we can have post-commit hook in GitHub workflow; but even manual step can be good enough if we have a general agreement on this question.
@aio-libs/admins @aio-libs/aiohttp-committers @aio-libs/aiohttp-demos-writers @aio-libs/triagers -- what do you think?
We should replace aiopg[sa] with sqlalchemy 1.4+ in the demos and tutorial.
I am working one aiohttp app that serves Keras model. Basically app doing simple image recognition. Code is here:
https://github.com/jettify/aiohttp-keras-demo
I have REST API ready, can use some help with frontend to speed thing up.
We have 4 demos now but only polls
is documented.
It would be nice to have something for others too.
I think new docs should not be as comprehensive as polls, no need to describe boring chapters about preparation and folder structure again and again.
Perhaps a page for demo should be enough.
Mentioning all existing demos in docs increase their visibility and teaching effect.
We need volunteers for the task. Sorry, I personally too busy by aiohttp itself.
It is very easy to deploy aiohttp app to heroku, and best part it is completely free. I think we should deploy few demos so users can play with apps.
Process is strait forward basically create Procfile
with:
web: mlserve -c models.yml -H 0.0.0.0 -P $PORT
And deploy app with git:
$ heroku create
$ git push heroku master
$ heroku open
Size of the gif file is 11.8 MB and dimensions are 3360x2100 pixels
Initial bug report is here: aio-libs/aiohttp#2789
The fix is really trivial. @gyermolenko could you manage the issue?
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.