Testing flask socketio
Hi! I'm trying to write test cases for Flask socket io using pytest. But it seems we can't test the emitted messages from namespaces using pytest only. What would be a good approach to test it?
Also, I am trying to figure out resources for flask socketio testing, I tried writing tests using some repos but there's not much explanation on what is being done. So it would be really helpful if anyone could point me towards any resources.
These are the repos I was talking about
1. https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/test\_socketio.py
2. https://github.com/julianYaman/bitcoinPriceApp\_python/tree/master
/r/flask
https://redd.it/13lssox
Hi! I'm trying to write test cases for Flask socket io using pytest. But it seems we can't test the emitted messages from namespaces using pytest only. What would be a good approach to test it?
Also, I am trying to figure out resources for flask socketio testing, I tried writing tests using some repos but there's not much explanation on what is being done. So it would be really helpful if anyone could point me towards any resources.
These are the repos I was talking about
1. https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/test\_socketio.py
2. https://github.com/julianYaman/bitcoinPriceApp\_python/tree/master
/r/flask
https://redd.it/13lssox
GitHub
Flask-SocketIO/test_socketio.py at main · miguelgrinberg/Flask-SocketIO
Socket.IO integration for Flask applications. Contribute to miguelgrinberg/Flask-SocketIO development by creating an account on GitHub.
Propan - is a new python framework for building messaging services
Hello everyone!
I have accumulated a critical mass of stuffed bumps in the development of RabbitMQ based services. The amount of boilerplate forced me to drag the same code from project to project. So I decided to put all this code in a separate package, spice it up with a small pinch of FastAPI concepts and scale my experience to other message brokers.
The only purpose of the framework is to make interaction with message brokers as simple and comfortable as possible: one decorator, launch via the CLI - and your application is ready to production.
Please take a look at the project and give me your feedback: maybe you have some ideas for improvement. Also, I really need your help as a developers, as it becomes difficult for me alone with a project of this scale.
https://github.com/Lancetnik/Propan
/r/Python
https://redd.it/13lncci
Hello everyone!
I have accumulated a critical mass of stuffed bumps in the development of RabbitMQ based services. The amount of boilerplate forced me to drag the same code from project to project. So I decided to put all this code in a separate package, spice it up with a small pinch of FastAPI concepts and scale my experience to other message brokers.
The only purpose of the framework is to make interaction with message brokers as simple and comfortable as possible: one decorator, launch via the CLI - and your application is ready to production.
Please take a look at the project and give me your feedback: maybe you have some ideas for improvement. Also, I really need your help as a developers, as it becomes difficult for me alone with a project of this scale.
https://github.com/Lancetnik/Propan
/r/Python
https://redd.it/13lncci
GitHub
GitHub - Lancetnik/Propan: Propan is a powerful and easy-to-use Python framework for building event-driven applications that interact…
Propan is a powerful and easy-to-use Python framework for building event-driven applications that interact with any MQ Broker - Lancetnik/Propan
NoDoze - smart sleep for Linux computers
If you find yourself periodically disabling sleep on your computer, NoDoze may be useful for you. NoDoze is a service that temporarily blocks sleep under certain conditions.
The conditions which have been implemented are:
Process Running: While specified processes (i.e. make, apt etc.) are running, sleep is prevented until they complete.
qBittorrent Downloading: While download rate remains above a certain threshold, sleep is prevented.
qBittorrent Seeding: While upload rate remains above a certain threshold, sleep is prevented.
Plex Streaming: While a Plex server is actively streaming media to clients, sleep is prevented. After playback completes, sleep is allowed to resume.
If there's something you'd like to add, a pretty simple plugin interface is available. The service has a YAML config file to enable, disable or tweak plugins and a plugin auto discovery to allow adding plugins without touching the core codebase.
Install and Uninstall scripts are provided to make setup fast.
Currently only Linux is supported.
/r/Python
https://redd.it/13lftqi
If you find yourself periodically disabling sleep on your computer, NoDoze may be useful for you. NoDoze is a service that temporarily blocks sleep under certain conditions.
The conditions which have been implemented are:
Process Running: While specified processes (i.e. make, apt etc.) are running, sleep is prevented until they complete.
qBittorrent Downloading: While download rate remains above a certain threshold, sleep is prevented.
qBittorrent Seeding: While upload rate remains above a certain threshold, sleep is prevented.
Plex Streaming: While a Plex server is actively streaming media to clients, sleep is prevented. After playback completes, sleep is allowed to resume.
If there's something you'd like to add, a pretty simple plugin interface is available. The service has a YAML config file to enable, disable or tweak plugins and a plugin auto discovery to allow adding plugins without touching the core codebase.
Install and Uninstall scripts are provided to make setup fast.
Currently only Linux is supported.
/r/Python
https://redd.it/13lftqi
GitHub
GitHub - ericghara/no-doze: Extensible service to conditionally prevent a Linux system from sleeping
Extensible service to conditionally prevent a Linux system from sleeping - GitHub - ericghara/no-doze: Extensible service to conditionally prevent a Linux system from sleeping
Writing a chat application in Django 4.2 using async StreamingHttpResponse, Server-Sent Events and PostgreSQL LISTEN/NOTIFY
https://valberg.dk/django-sse-postgresql-listen-notify.html
/r/django
https://redd.it/13ls3dd
https://valberg.dk/django-sse-postgresql-listen-notify.html
/r/django
https://redd.it/13ls3dd
Reddit
r/django on Reddit: Writing a chat application in Django 4.2 using async StreamingHttpResponse, Server-Sent Events and PostgreSQL…
Posted by u/pauloxnet - 20 votes and no comments
Self keyword
How comes in Django classes you don't have to pass self as the first argument when making a class?
/r/djangolearning
https://redd.it/13lww43
How comes in Django classes you don't have to pass self as the first argument when making a class?
/r/djangolearning
https://redd.it/13lww43
Reddit
r/djangolearning on Reddit: Self keyword
Posted by u/SamB7334 - 1 vote and 7 comments
Best video resource to learn django
Hello guys, the question is simply the title i want to learn django and I hope you guys could recommend some good resources for it. I don't like learning from documentation specially when i learn a new tech.
There are so many tutorials on YouTube but not sure if they will cover the important things and i am concerned about the quality of the tutorial since i do not want to waste my time.
Hope you could help me this and have a nice day.
/r/djangolearning
https://redd.it/13jxwfo
Hello guys, the question is simply the title i want to learn django and I hope you guys could recommend some good resources for it. I don't like learning from documentation specially when i learn a new tech.
There are so many tutorials on YouTube but not sure if they will cover the important things and i am concerned about the quality of the tutorial since i do not want to waste my time.
Hope you could help me this and have a nice day.
/r/djangolearning
https://redd.it/13jxwfo
Reddit
r/djangolearning on Reddit: Best video resource to learn django
Posted by u/irritatedfck - No votes and 5 comments
🌍EOmaps v6.5 released!
I just released EOmaps v6.5!
EOmaps is a python module to create maps of of geographical datasets and use them as interactive data-analysis widgets.
Now you can add GridLabels in arbitrary projections!
https://preview.redd.it/dt6gkryb8v0b1.png?width=1423&format=png&auto=webp&v=enabled&s=2d60c11c4830ead873cbc50221530a0154d3da6b
/r/Python
https://redd.it/13ma54g
I just released EOmaps v6.5!
EOmaps is a python module to create maps of of geographical datasets and use them as interactive data-analysis widgets.
Now you can add GridLabels in arbitrary projections!
https://preview.redd.it/dt6gkryb8v0b1.png?width=1423&format=png&auto=webp&v=enabled&s=2d60c11c4830ead873cbc50221530a0154d3da6b
/r/Python
https://redd.it/13ma54g
GitHub
GitHub - raphaelquast/EOmaps: A library to create interactive maps of geographical datasets
A library to create interactive maps of geographical datasets - raphaelquast/EOmaps
Password form style not working
I am trying to change the basic sign in form and did the following style
widgets = {
'username': forms.TextInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
'placeholder': 'Nume utilizator',
}),
'email': forms.EmailInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
'placeholder': 'exemplu@email.com',
}),
'password1': forms.PasswordInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
}),
'password2': forms.PasswordInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
}),
}
Now my problem is that the field for both password did not change while the other two did. How can I make them work?
/r/djangolearning
https://redd.it/13jaqpn
I am trying to change the basic sign in form and did the following style
widgets = {
'username': forms.TextInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
'placeholder': 'Nume utilizator',
}),
'email': forms.EmailInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
'placeholder': 'exemplu@email.com',
}),
'password1': forms.PasswordInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
}),
'password2': forms.PasswordInput(attrs={
'class': 'w-100 p-3 rounded-4 border border-success shadow',
}),
}
Now my problem is that the field for both password did not change while the other two did. How can I make them work?
/r/djangolearning
https://redd.it/13jaqpn
Reddit
r/djangolearning on Reddit: Password form style not working
Posted by u/Fit-Refrigerator495 - 2 votes and 7 comments
GenForum, a django forum maker and and my first personal project that's been in development hell
https://www.youtube.com/watch?v=w8SCwsgxiyw
/r/django
https://redd.it/13luaz0
https://www.youtube.com/watch?v=w8SCwsgxiyw
/r/django
https://redd.it/13luaz0
YouTube
GenForum showcase
How do you make a non-unique, repeating id in flask?
I am making a notes-type app, and there are three database models-the user, documents, and chapters. Chapters have a parent Document and Documents have a parent User.
If I want to print the id's of one users documents, I would like it to start from 1,2,3,etc, for EACH user. If I have 3 users, and user 3 only has 1 document, I would like the id to be 1, and the next 2, etc, but instead it starts from like, 5, because it's including the other users. Does that make sense?
​
My Models
class Document(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
documents = db.relationship('Document')
​
This User has only three documents, and I would like the id to start from 1, not continue from previous users.
I have the same issue with chapters. Any help would be greatly greatly appreciated!! I am very new to Flask.
/r/flask
https://redd.it/13meib0
I am making a notes-type app, and there are three database models-the user, documents, and chapters. Chapters have a parent Document and Documents have a parent User.
If I want to print the id's of one users documents, I would like it to start from 1,2,3,etc, for EACH user. If I have 3 users, and user 3 only has 1 document, I would like the id to be 1, and the next 2, etc, but instead it starts from like, 5, because it's including the other users. Does that make sense?
​
My Models
class Document(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
documents = db.relationship('Document')
​
This User has only three documents, and I would like the id to start from 1, not continue from previous users.
I have the same issue with chapters. Any help would be greatly greatly appreciated!! I am very new to Flask.
/r/flask
https://redd.it/13meib0
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?
Use this thread to chat about and share Python resources!
/r/Python
https://redd.it/13mc34l
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?
Use this thread to chat about and share Python resources!
/r/Python
https://redd.it/13mc34l
Reddit
r/Python on Reddit: Saturday Daily Thread: Resource Request and Sharing! Daily Thread
Posted by u/Im__Joseph - 1 vote and 1 comment
I want to host my django application on Ubantu. Any good blogs?
I want to host my django application on Ubantu VPS, can anyone link me to a blog that shows what configurations I have to do as well as how to actually host?
/r/djangolearning
https://redd.it/13iyhz0
I want to host my django application on Ubantu VPS, can anyone link me to a blog that shows what configurations I have to do as well as how to actually host?
/r/djangolearning
https://redd.it/13iyhz0
Reddit
r/djangolearning on Reddit: I want to host my django application on Ubantu. Any good blogs?
Posted by u/Creepy_Rooster - 3 votes and 11 comments
PromptOptimizer -- Save Money on OpenAI (and more) LLM API costs by Minimizing the Token Complexity
LLMs work by breaking down text into tokens. Their computational complexity is usually quadratic in terms of token length.
**Why bother?**
* **Minimize Token Complexity:** Token Complexity is the amount of prompt tokens required to achieve a given task. Reducing token complexity corresponds to linearly reducing API costs and quadratically reducing computational complexity of usual transformer models.
* **Save Money:** For large businesses, saving 10% on token count can lead to saving 100k USD per 1M USD.
* **Extend Limitations:** Some models have small context lengths, prompt optimizers can help them process larger than context documents.
This project is completely written in python and is easily extendable to include more custom optimizers for experiments: [https://promptoptimizer.readthedocs.io/en/latest/extend/custom\_optims.html](https://promptoptimizer.readthedocs.io/en/latest/extend/custom_optims.html)
Open source code: [https://github.com/vaibkumr/prompt-optimizer/](https://github.com/vaibkumr/prompt-optimizer/)
Documentations: [https://promptoptimizer.readthedocs.io/en/latest/](https://promptoptimizer.readthedocs.io/en/latest/)
Please consider contributing and let me know your thoughts on this!
/r/Python
https://redd.it/13m75f9
LLMs work by breaking down text into tokens. Their computational complexity is usually quadratic in terms of token length.
**Why bother?**
* **Minimize Token Complexity:** Token Complexity is the amount of prompt tokens required to achieve a given task. Reducing token complexity corresponds to linearly reducing API costs and quadratically reducing computational complexity of usual transformer models.
* **Save Money:** For large businesses, saving 10% on token count can lead to saving 100k USD per 1M USD.
* **Extend Limitations:** Some models have small context lengths, prompt optimizers can help them process larger than context documents.
This project is completely written in python and is easily extendable to include more custom optimizers for experiments: [https://promptoptimizer.readthedocs.io/en/latest/extend/custom\_optims.html](https://promptoptimizer.readthedocs.io/en/latest/extend/custom_optims.html)
Open source code: [https://github.com/vaibkumr/prompt-optimizer/](https://github.com/vaibkumr/prompt-optimizer/)
Documentations: [https://promptoptimizer.readthedocs.io/en/latest/](https://promptoptimizer.readthedocs.io/en/latest/)
Please consider contributing and let me know your thoughts on this!
/r/Python
https://redd.it/13m75f9
GitHub
GitHub - vaibkumr/prompt-optimizer: Minimize LLM token complexity to save API costs and model computations.
Minimize LLM token complexity to save API costs and model computations. - vaibkumr/prompt-optimizer
Writing a chat application in Django 4.2 using SSE
https://valberg.dk/django-sse-postgresql-listen-notify.html
/r/Python
https://redd.it/13mn11q
https://valberg.dk/django-sse-postgresql-listen-notify.html
/r/Python
https://redd.it/13mn11q
Reddit
r/Python on Reddit: Writing a chat application in Django 4.2 using SSE
Posted by u/alicedu06 - 46 votes and 10 comments
Django agGrid
Hello r/django,
I'm new to Django and would like to get some advise on a project I'm working on.
My table returns a list of hotels with CRUD functionality via modal forms utilizing django forms. The problem is that scrolling is quite slow (overflow-auto was used to make the table scrollable). I intend to use agGrid to output the list, but it only accepts JSON response. Is it a bad idea to have a separate view for handling JSON response? Is it possible to just create an app using drf and have separate app for html views that output the forms and send the post to the view created from drf?
Here's the html table.
<tbody>
{% for hotel in hotels %}
<tr class="border-b dark:border-gray-700">
<th scope="row" class="px-4 py-2 font-medium text-gray-900 whitespace-nowrap dark:text-white">{{ hotel.name }}</th>
<td class="px-4 py-2 whitespace-nowrap">{{ hotel.rating }}</td>
/r/djangolearning
https://redd.it/13mytbu
Hello r/django,
I'm new to Django and would like to get some advise on a project I'm working on.
My table returns a list of hotels with CRUD functionality via modal forms utilizing django forms. The problem is that scrolling is quite slow (overflow-auto was used to make the table scrollable). I intend to use agGrid to output the list, but it only accepts JSON response. Is it a bad idea to have a separate view for handling JSON response? Is it possible to just create an app using drf and have separate app for html views that output the forms and send the post to the view created from drf?
Here's the html table.
<tbody>
{% for hotel in hotels %}
<tr class="border-b dark:border-gray-700">
<th scope="row" class="px-4 py-2 font-medium text-gray-900 whitespace-nowrap dark:text-white">{{ hotel.name }}</th>
<td class="px-4 py-2 whitespace-nowrap">{{ hotel.rating }}</td>
/r/djangolearning
https://redd.it/13mytbu
I want to build a chatbot with Openai API
Hello guys! Does someone have a tutorial or an example?
/r/flask
https://redd.it/13n0hly
Hello guys! Does someone have a tutorial or an example?
/r/flask
https://redd.it/13n0hly
Reddit
r/flask on Reddit: I want to build a chatbot with Openai API
Posted by u/Danteurd - No votes and 4 comments
This media is not supported in your browser
VIEW IN TELEGRAM
[R] Video Demo of “Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold”
https://redd.it/13mpxbw
@pythondaily
https://redd.it/13mpxbw
@pythondaily
Sunday Daily Thread: What's everyone working on this week?
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/13nd675
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/13nd675
Reddit
r/Python on Reddit: Sunday Daily Thread: What's everyone working on this week?
Posted by u/Im__Joseph - 1 vote and 2 comments