Monday Daily Thread: Project ideas!
# Weekly Thread: Project Ideas 💡
Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.
## How it Works:
1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.
## Guidelines:
* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.
# Example Submissions:
## Project Idea: Chatbot
**Difficulty**: Intermediate
**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar
**Description**: Create a chatbot that can answer FAQs for a website.
**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)
# Project Idea: Weather Dashboard
**Difficulty**: Beginner
**Tech Stack**: HTML, CSS, JavaScript, API
**Description**: Build a dashboard that displays real-time weather information using a weather API.
**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)
## Project Idea: File Organizer
**Difficulty**: Beginner
**Tech Stack**: Python, File I/O
**Description**: Create a script that organizes files in a directory into sub-folders based on file type.
**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)
Let's help each other grow. Happy
/r/Python
https://redd.it/1cqlqq7
# Weekly Thread: Project Ideas 💡
Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.
## How it Works:
1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.
## Guidelines:
* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.
# Example Submissions:
## Project Idea: Chatbot
**Difficulty**: Intermediate
**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar
**Description**: Create a chatbot that can answer FAQs for a website.
**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)
# Project Idea: Weather Dashboard
**Difficulty**: Beginner
**Tech Stack**: HTML, CSS, JavaScript, API
**Description**: Build a dashboard that displays real-time weather information using a weather API.
**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)
## Project Idea: File Organizer
**Difficulty**: Beginner
**Tech Stack**: Python, File I/O
**Description**: Create a script that organizes files in a directory into sub-folders based on file type.
**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)
Let's help each other grow. Happy
/r/Python
https://redd.it/1cqlqq7
YouTube
Build & Integrate your own custom chatbot to a website (Python & JavaScript)
In this fun project you learn how to build a custom chatbot in Python and then integrate this to a website using Flask and JavaScript.
Starter Files: https://github.com/patrickloeber/chatbot-deployment
Get my Free NumPy Handbook: https://www.python-engi…
Starter Files: https://github.com/patrickloeber/chatbot-deployment
Get my Free NumPy Handbook: https://www.python-engi…
error deploying to railway
Hello everyone,
i have a DRF project which i added it to a container along with redis,postgres and nginx,
all containerized and when i deploy my project to railway it detect the dockerfile automatically but i get this error
>`Error: '${PORT}' is not a valid port number.`
in railway logs , it keep repeating the server crashes,
been 4 days trying to solve this,
im trying to deploy my project as a container which i have .
here is my config files:
DockerFile
...
RUN python manage.py collectstatic --no-input
# Set the command to run the Django development server
CMD ["gunicorn", "--bind", ":${PORT}","--workers","4", "project.wsgi" , "python manage.py migrate"]
**":${PORT}" >> tried both 0.0.0.0:${PORT} and 0.0.0.0:$PORT same error**
docker compose:
...
djangoapp:
build: .
command: gunicorn project.wsgi:application --bind :${PORT}
volumes:
- xxxxx
- xxxxx
environment:
- PORT
expose:
- $PORT
env_file:
/r/django
https://redd.it/1cqt96f
Hello everyone,
i have a DRF project which i added it to a container along with redis,postgres and nginx,
all containerized and when i deploy my project to railway it detect the dockerfile automatically but i get this error
>`Error: '${PORT}' is not a valid port number.`
in railway logs , it keep repeating the server crashes,
been 4 days trying to solve this,
im trying to deploy my project as a container which i have .
here is my config files:
DockerFile
...
RUN python manage.py collectstatic --no-input
# Set the command to run the Django development server
CMD ["gunicorn", "--bind", ":${PORT}","--workers","4", "project.wsgi" , "python manage.py migrate"]
**":${PORT}" >> tried both 0.0.0.0:${PORT} and 0.0.0.0:$PORT same error**
docker compose:
...
djangoapp:
build: .
command: gunicorn project.wsgi:application --bind :${PORT}
volumes:
- xxxxx
- xxxxx
environment:
- PORT
expose:
- $PORT
env_file:
/r/django
https://redd.it/1cqt96f
Reddit
From the django community on Reddit
Explore this post and more from the django community
Python & Django REST API Bootcamp - Build A Python Web API | Free Udemy Course for limited enrolls
https://www.webhelperapp.com/python-django-rest-api-bootcamp-build-a-python-web-api-2/
/r/djangolearning
https://redd.it/1cppg41
https://www.webhelperapp.com/python-django-rest-api-bootcamp-build-a-python-web-api-2/
/r/djangolearning
https://redd.it/1cppg41
Free Udemy Coupons
Python & Django REST API Bootcamp – Build A Python Web API
Do you want to build a complete Python RESTful API that is not only secure and stable but also deployed to a production ready environment ready to serve
How to upload files larger than 2 mb
when uploading 1 mb files or 2 it uploaded successfully, files over 50mb fails to upload on django? how to solve that
2- i want to point url to active domain not to address such as 100.100.10.10 ex.
/r/django
https://redd.it/1cqyuzy
when uploading 1 mb files or 2 it uploaded successfully, files over 50mb fails to upload on django? how to solve that
2- i want to point url to active domain not to address such as 100.100.10.10 ex.
/r/django
https://redd.it/1cqyuzy
Reddit
From the django community on Reddit
Explore this post and more from the django community
Undo an objects save? Database transactions?
I know enough Django to have a reasonably straight forward app with some complexity, with a dozen models, several dozen CBV and FBV, etc. But I don't know much about databases under the hood of Django. A friend was commenting on how a similar program/app to mine did not have an undo feature. From his perspective, when he changes a value on the website (and object save), he thinks the user should be able to undo the change. For example, a django app could have a form with 10 fields on it, where the form/view is using htmx and the fields are pre-filled with existing data. A user enters in some new values. My friend thinks a user should be able to undo any changes to revert to a previous value. My initial thought was that this would require a huge number of objects to be created. I then learned a bit about database transactions. My friend was essentially saying that database transactions are saved so that things can be rolled back, and that this is one of the primary features of a modern database. He gave an example of banks needing to
/r/django
https://redd.it/1cr3cs5
I know enough Django to have a reasonably straight forward app with some complexity, with a dozen models, several dozen CBV and FBV, etc. But I don't know much about databases under the hood of Django. A friend was commenting on how a similar program/app to mine did not have an undo feature. From his perspective, when he changes a value on the website (and object save), he thinks the user should be able to undo the change. For example, a django app could have a form with 10 fields on it, where the form/view is using htmx and the fields are pre-filled with existing data. A user enters in some new values. My friend thinks a user should be able to undo any changes to revert to a previous value. My initial thought was that this would require a huge number of objects to be created. I then learned a bit about database transactions. My friend was essentially saying that database transactions are saved so that things can be rolled back, and that this is one of the primary features of a modern database. He gave an example of banks needing to
/r/django
https://redd.it/1cr3cs5
Reddit
From the django community on Reddit
Explore this post and more from the django community
Making my filrst serious ecommerce website, need help....
Iam going to develop an ecommerce site from scratch all by myself to refresh my knowledge.
I have experience in handling amazon seller central and shopify at my current sales related job and wants to implement its features into my site as much as my abilities will allow me,
My current plan is to add 3 apps which are,
shop
contains list and display view of products will contain models for product, category
order
handles ordering , tracking etc...
will contain order table
seller
this is like an admin section, in which the sellers can schedule orders, add products, updatet its quantities, decide the categories it will fall into etc ...
but iam confsed about these things right now.
1. Should i add products manually to the database or call an api.
2. How can i add main and subcategories, iam clueless on this.
3. should i add a seplerate model for product images and add it as a foreign key to the product table and later many to many field to display them?
/r/django
https://redd.it/1cr1ii1
Iam going to develop an ecommerce site from scratch all by myself to refresh my knowledge.
I have experience in handling amazon seller central and shopify at my current sales related job and wants to implement its features into my site as much as my abilities will allow me,
My current plan is to add 3 apps which are,
shop
contains list and display view of products will contain models for product, category
order
handles ordering , tracking etc...
will contain order table
seller
this is like an admin section, in which the sellers can schedule orders, add products, updatet its quantities, decide the categories it will fall into etc ...
but iam confsed about these things right now.
1. Should i add products manually to the database or call an api.
2. How can i add main and subcategories, iam clueless on this.
3. should i add a seplerate model for product images and add it as a foreign key to the product table and later many to many field to display them?
/r/django
https://redd.it/1cr1ii1
Reddit
From the django community on Reddit
Explore this post and more from the django community
Frame - a new language for programming state machines in Python
Hey,
I am (re)releasing a project called Frame that I've been working on to create a language and transpiler to easily create state machines/automata in Python. It also is able to generate UML documentation as well.
This project is for people who are interested in programming state machines for a wide range of purposes such as game programming, workflows, MBSE modeling as well as school projects for comp sci theory. It is also useful simply for generating flow documentation.
The Framepiler (Frame transpiler) is in beta at this time. It would be great to get feedback from the Python community on any gaps in key functionality or bugs.
Low-code/no-code workflow tools are often problematic for creating state machine like flows. Frame is intended to give a textual way to accomplish the same thing, but without having to "draw" your software and with the ability to use all the standard devops tooling and processes for "normal" development processes.
There is also a VSCode extension and a playground environment to experiment in.
Very much hoping to connect with people who might find this interesting and useful. If that is you, please take a look at the Overview and the Getting Started articles. Here is a link to the GitHub
/r/Python
[https://redd.it/1cqoyuq
Hey,
I am (re)releasing a project called Frame that I've been working on to create a language and transpiler to easily create state machines/automata in Python. It also is able to generate UML documentation as well.
This project is for people who are interested in programming state machines for a wide range of purposes such as game programming, workflows, MBSE modeling as well as school projects for comp sci theory. It is also useful simply for generating flow documentation.
The Framepiler (Frame transpiler) is in beta at this time. It would be great to get feedback from the Python community on any gaps in key functionality or bugs.
Low-code/no-code workflow tools are often problematic for creating state machine like flows. Frame is intended to give a textual way to accomplish the same thing, but without having to "draw" your software and with the ability to use all the standard devops tooling and processes for "normal" development processes.
There is also a VSCode extension and a playground environment to experiment in.
Very much hoping to connect with people who might find this interesting and useful. If that is you, please take a look at the Overview and the Getting Started articles. Here is a link to the GitHub
/r/Python
[https://redd.it/1cqoyuq
Visualstudio
Frame System Designer - Visual Studio Marketplace
SQLPage - a Python library to add string token based pagination easily
What My Project Does - This is a Python package to easily add string token based pagination. Currently it supports SQLModel and SQLAlchemy ORMs.
Recently I wanted to add pagination in one of my Python projects and in the API response, I had to return a string next page token. Now I could not find a straight-forward way of doing this in Python. All of the tutorials or blog posts I saw, there in the response the server always returned a
Comparison - The current packages and methods requires some changes in the app layer as well. I tried using a few but those did not satisfy the use case and were also a bit harder to implement. I could not find a easy to use option. The present ones returned integers instead of a string token
I wanted it to be simpler, just like OpenSearch - you call its search API and it returns 10 elements and a
/r/Python
https://redd.it/1cqzf6o
What My Project Does - This is a Python package to easily add string token based pagination. Currently it supports SQLModel and SQLAlchemy ORMs.
Recently I wanted to add pagination in one of my Python projects and in the API response, I had to return a string next page token. Now I could not find a straight-forward way of doing this in Python. All of the tutorials or blog posts I saw, there in the response the server always returned a
page_number, page_size, and total_elements and then the onus was on the calling service to adjust this accordingly. Comparison - The current packages and methods requires some changes in the app layer as well. I tried using a few but those did not satisfy the use case and were also a bit harder to implement. I could not find a easy to use option. The present ones returned integers instead of a string token
I wanted it to be simpler, just like OpenSearch - you call its search API and it returns 10 elements and a
next_page_token and then for the next 10 (or you configure this using the size parameter) you use the next_page_token in the subsequent request to get to/r/Python
https://redd.it/1cqzf6o
Reddit
From the Python community on Reddit: SQLPage - a Python library to add string token based pagination easily
Explore this post and more from the Python community
UXsim 1.3.0 released with vehicle tracking and improved vehicle routing
Main Changes
Add GUI functions
Vehicle tracking: You can now track a specific vehicle to see their route
Dataframe viewer: Stats can be confirmed
Improve vehicle routing functions
Add [example of routing optimization](https://github.com/toruseo/UXsim/blob/main/demos_and_examples/demo_notebook_07en_optimal_routing.ipynb)
Change documentation's theme for better indexing
UXsim
UXsim is a free, open-source macroscopic and mesoscopic network traffic flow simulator written in Python. It simulates the movements of car travelers and traffic congestion in road networks. It is suitable for simulating large-scale (e.g., city-scale) traffic phenomena. UXsim is especially useful for scientific and educational purposes because of its simple, lightweight, and customizable features, but users are free to use UXsim for any purpose.
/r/Python
https://redd.it/1cqstyd
Main Changes
Add GUI functions
Vehicle tracking: You can now track a specific vehicle to see their route
Dataframe viewer: Stats can be confirmed
Improve vehicle routing functions
Add [example of routing optimization](https://github.com/toruseo/UXsim/blob/main/demos_and_examples/demo_notebook_07en_optimal_routing.ipynb)
Change documentation's theme for better indexing
UXsim
UXsim is a free, open-source macroscopic and mesoscopic network traffic flow simulator written in Python. It simulates the movements of car travelers and traffic congestion in road networks. It is suitable for simulating large-scale (e.g., city-scale) traffic phenomena. UXsim is especially useful for scientific and educational purposes because of its simple, lightweight, and customizable features, but users are free to use UXsim for any purpose.
/r/Python
https://redd.it/1cqstyd
GitHub
UXsim/demos_and_examples/demo_notebook_07en_optimal_routing.ipynb at main · toruseo/UXsim
Vehicular traffic flow simulator in road network, written in pure Python - toruseo/UXsim
Automatic face registration using python and face_recognition library.
We have achieved good accuracy of face recognition and after registration of faces of people captured in frames only if played high quality video, However, we get very low accuracy when video quality goes down. What can be done?
Your suggestion will be appreciable.
/r/Python
https://redd.it/1cr5ggr
We have achieved good accuracy of face recognition and after registration of faces of people captured in frames only if played high quality video, However, we get very low accuracy when video quality goes down. What can be done?
Your suggestion will be appreciable.
/r/Python
https://redd.it/1cr5ggr
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
collectstatic command not detecting new changes using s3 bucket
hello everyone i am facing an issue. when i first moved all my staticfiles to s3 bucket it all went fine but as time went on and i started adding new files or making changes to my css i noticed that whenever i push and try to run collectstatic command it shows no 0 static files copied which then leads me to start manually uploading new files to my bucket every time i make a change. please how can i solve this issue.
/r/djangolearning
https://redd.it/1crb068
hello everyone i am facing an issue. when i first moved all my staticfiles to s3 bucket it all went fine but as time went on and i started adding new files or making changes to my css i noticed that whenever i push and try to run collectstatic command it shows no 0 static files copied which then leads me to start manually uploading new files to my bucket every time i make a change. please how can i solve this issue.
/r/djangolearning
https://redd.it/1crb068
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community
Issue testing view function w/SQLAlchemy and pytest
Hey all, I'm having an issue with a user route to soft delete the user. My goal is to append '\_deleted' to the username and email, and set the active status to zero. Here's the route:
@users.route("/delete-account", methods=['GET', 'POST'])
@login_required
def delete_account():
current_user.active = 0
current_user.email = current_user.email + '_deleted'
current_user.username = current_user.username + '_deleted'
db.session.commit()
logout_user()
flash("Your account has been deleted.", category='info')
return redirect(url_for('users.login'))
My conftest.py file mimics the blog post from Alex Michael ([here](http://alexmic.net/flask-sqlalchemy-pytest/)) and contains the following:
import pytest
from application import create_app, db as _db
from application.config import UnitTestConfig
from application.models import User
from werkzeug.security import generate_password_hash
@pytest.fixture(scope='session')
def app(request):
/r/flask
https://redd.it/1crdtr2
Hey all, I'm having an issue with a user route to soft delete the user. My goal is to append '\_deleted' to the username and email, and set the active status to zero. Here's the route:
@users.route("/delete-account", methods=['GET', 'POST'])
@login_required
def delete_account():
current_user.active = 0
current_user.email = current_user.email + '_deleted'
current_user.username = current_user.username + '_deleted'
db.session.commit()
logout_user()
flash("Your account has been deleted.", category='info')
return redirect(url_for('users.login'))
My conftest.py file mimics the blog post from Alex Michael ([here](http://alexmic.net/flask-sqlalchemy-pytest/)) and contains the following:
import pytest
from application import create_app, db as _db
from application.config import UnitTestConfig
from application.models import User
from werkzeug.security import generate_password_hash
@pytest.fixture(scope='session')
def app(request):
/r/flask
https://redd.it/1crdtr2
alexmic.net
Delightful testing with pytest and Flask-SQLAlchemy | Alex Michael
Software Engineer @tictail, founder @hackcyprus. Startups, code, beer. #yolo
Tuesday Daily Thread: Advanced questions
# Weekly Wednesday Thread: Advanced Questions 🐍
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
## How it Works:
1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.
## Guidelines:
* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.
## Recommended Resources:
* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.
## Example Questions:
1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the
/r/Python
https://redd.it/1crefjo
# Weekly Wednesday Thread: Advanced Questions 🐍
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
## How it Works:
1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.
## Guidelines:
* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.
## Recommended Resources:
* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.
## Example Questions:
1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the
/r/Python
https://redd.it/1crefjo
Discord
Join the Python Discord Server!
We're a large community focused around the Python programming language. We believe that anyone can learn to code. | 412982 members
Implementing your own pypi clone
Hi,
Just want to know how difficult is it to manage your own pypi clone and how do you recommend to create a seperation between dev and prod systems.
/r/Python
https://redd.it/1crksf7
Hi,
Just want to know how difficult is it to manage your own pypi clone and how do you recommend to create a seperation between dev and prod systems.
/r/Python
https://redd.it/1crksf7
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
D Full causal self-attention layer in O(NlogN) computation steps and O(logN) time rather than O(N^2) computation steps and O(1) time, with a big caveat, but hope for the future.
*Update*: Actually O(N) computation steps(not O(Nlog N)) and O(log N) time.
I think I figured out how to do self-attention in transformer models in O(NlogN) computation steps rather than O(N\^2), with a caveat. I'm not trying to be an academic, so I don't care to publish this formally, but I thought that some people might be interested. My construction is not efficient or practical, but the fact that it can be done at all might motivate further work to find efficient alternatives.
tl;dr Use the parallel scan[1\] technique to compute taylor series basis functions needed to compute the causal self-attention layer and sum these together weighted by the values vector and 1 to get the numerator and denominator of the softmax activation of the full causal self-attention layer. The basis functions that you have to compute are both the basis functions for the numerator of the self-attention layer, $$\\sum_{i=0}\^{j-1} k(i)_a\^n q(j)_b\^m v(i)$$ and the normalization $\\sum_{i=0}\^{j-1} k(i)_a\^n q(j)_b\^m$. k(i)_a\^n is component-a of the ith key vector raised to the power of n multiplied by q(j)_b\^m which is component-b of the jth query vector raised to the power of m, which is multiplied by the value vector at position i in the first
/r/MachineLearning
https://redd.it/1cri6h6
*Update*: Actually O(N) computation steps(not O(Nlog N)) and O(log N) time.
I think I figured out how to do self-attention in transformer models in O(NlogN) computation steps rather than O(N\^2), with a caveat. I'm not trying to be an academic, so I don't care to publish this formally, but I thought that some people might be interested. My construction is not efficient or practical, but the fact that it can be done at all might motivate further work to find efficient alternatives.
tl;dr Use the parallel scan[1\] technique to compute taylor series basis functions needed to compute the causal self-attention layer and sum these together weighted by the values vector and 1 to get the numerator and denominator of the softmax activation of the full causal self-attention layer. The basis functions that you have to compute are both the basis functions for the numerator of the self-attention layer, $$\\sum_{i=0}\^{j-1} k(i)_a\^n q(j)_b\^m v(i)$$ and the normalization $\\sum_{i=0}\^{j-1} k(i)_a\^n q(j)_b\^m$. k(i)_a\^n is component-a of the ith key vector raised to the power of n multiplied by q(j)_b\^m which is component-b of the jth query vector raised to the power of m, which is multiplied by the value vector at position i in the first
/r/MachineLearning
https://redd.it/1cri6h6
Reddit
From the MachineLearning community on Reddit: [D] Full causal self-attention layer in O(NlogN) computation steps and O(logN) time…
Explore this post and more from the MachineLearning community
modern_colorthief - Modified Median Cut Quantization algorithm in rust + python
* [github](https://github.com/baseplate-admin/modern_colorthief)
* [documentation](https://modern-colorthief.readthedocs.io/en/latest/)
## What my project does :
It gets the dominant color/color palette from given image.
## Target Audience:
Anyone
## Usage
modern_colorthief exposes two functions get_color and get_palette
Here is how to use get_color:
```python
from modern_colorthief import get_color
# Path to any image
path = ...
print(get_color(path)) # returns tuple[int,int,int]
```
Here is how to use get_palette:
```python
from modern_colorthief import get_color
# Path to any image
path = ...
print(get_palette(path)) # returns list[tuple[int,int,int]]
```
# Goals:
- Bring [color-thief-rs](https://github.com/RazrFalcon/color-thief-rs/) to python
# Benchmarks:
[Written in deatils](https://modern-colorthief.readthedocs.io/en/latest/benchmarks.html)
Gist:
```python
Python Took: 0.09976800000004005
CPP Took: 0.008461299999908078
RUST Took: 0.008549499994842336
Python Took: 0.0960583999985829
CPP Took: 0.008564600000681821
RUST Took: 0.007692700004554354
```
# Differences
## With fast-colorthief
- Supports more architectures. ( pybind11 vs pyo3 )
- Doesn't have a hard dependency on numpy
- Code is simple compared to fast-colorthief's CPP codebase
- Automated tooling powered by maturin and github-actions
- The size
/r/Python
https://redd.it/1crouri
* [github](https://github.com/baseplate-admin/modern_colorthief)
* [documentation](https://modern-colorthief.readthedocs.io/en/latest/)
## What my project does :
It gets the dominant color/color palette from given image.
## Target Audience:
Anyone
## Usage
modern_colorthief exposes two functions get_color and get_palette
Here is how to use get_color:
```python
from modern_colorthief import get_color
# Path to any image
path = ...
print(get_color(path)) # returns tuple[int,int,int]
```
Here is how to use get_palette:
```python
from modern_colorthief import get_color
# Path to any image
path = ...
print(get_palette(path)) # returns list[tuple[int,int,int]]
```
# Goals:
- Bring [color-thief-rs](https://github.com/RazrFalcon/color-thief-rs/) to python
# Benchmarks:
[Written in deatils](https://modern-colorthief.readthedocs.io/en/latest/benchmarks.html)
Gist:
```python
Python Took: 0.09976800000004005
CPP Took: 0.008461299999908078
RUST Took: 0.008549499994842336
Python Took: 0.0960583999985829
CPP Took: 0.008564600000681821
RUST Took: 0.007692700004554354
```
# Differences
## With fast-colorthief
- Supports more architectures. ( pybind11 vs pyo3 )
- Doesn't have a hard dependency on numpy
- Code is simple compared to fast-colorthief's CPP codebase
- Automated tooling powered by maturin and github-actions
- The size
/r/Python
https://redd.it/1crouri
GitHub
GitHub - baseplate-admin/modern_colorthief: Colorthief but with modern codes
Colorthief but with modern codes. Contribute to baseplate-admin/modern_colorthief development by creating an account on GitHub.
Changing flask session in a middleware
Hi,
I would like to change the flask session to set a default value whenever the user is authenticated and if there isn't a value yet:
class VersionSessionMiddleware:
def init(self, app):
= app
def call(self, environ, startresponse):
if not constants.SESSIONVERSIONNAME in session:
session[constants.SESSIONVERSIONNAME] = constants.DEFAULTVERSION
return self.app(environ, startresponse)self.app
This fails with `RuntimeError: Working outside of request context`. And I can access to current\user from Flask-Login, it is None.
From these results, I think a middleware is not the solution I'm looking for. What tool can I use to do that?
Thanks.
/r/flask
https://redd.it/1crq4wu
Hi,
I would like to change the flask session to set a default value whenever the user is authenticated and if there isn't a value yet:
class VersionSessionMiddleware:
def init(self, app):
= app
def call(self, environ, startresponse):
if not constants.SESSIONVERSIONNAME in session:
session[constants.SESSIONVERSIONNAME] = constants.DEFAULTVERSION
return self.app(environ, startresponse)self.app
This fails with `RuntimeError: Working outside of request context`. And I can access to current\user from Flask-Login, it is None.
From these results, I think a middleware is not the solution I'm looking for. What tool can I use to do that?
Thanks.
/r/flask
https://redd.it/1crq4wu
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Flask MySQL database session best practice – resolve Broken Pipe Error
My question for this post: Is my approach for using and relying before\_request and after\_request to handle opening and closing database sessions ok or just a mess?
# Background
I have a Python Flask Website, a different Flask app that is the API, and a service Python app that the API can call when needed that connect to the same MySQL database. They all use SQLAlchemy to communicate with the same MySQL database.
Every morning, I find a similar Broken Pipe Error which prevents the first user for the day from logging in right away. They will need to try a few times to rollback and close the session. This is the problem I am ultimately trying to resolve.
My approach has been, instead of trying to find the loose end database session, I thought I could cut off an expiring database session by using the before_request decorator to instantiate a db session. Then after_request decorator to close the session after each request.
This doesn’t seem to be working. I have not prevented Broken Pipe errors.
Should I just create a database session when I need it and close it? Then if I find Broken Pipe error try to find the source of the problem.
Diagram of
/r/flask
[https://redd.it/1cqus6q
My question for this post: Is my approach for using and relying before\_request and after\_request to handle opening and closing database sessions ok or just a mess?
# Background
I have a Python Flask Website, a different Flask app that is the API, and a service Python app that the API can call when needed that connect to the same MySQL database. They all use SQLAlchemy to communicate with the same MySQL database.
Every morning, I find a similar Broken Pipe Error which prevents the first user for the day from logging in right away. They will need to try a few times to rollback and close the session. This is the problem I am ultimately trying to resolve.
My approach has been, instead of trying to find the loose end database session, I thought I could cut off an expiring database session by using the before_request decorator to instantiate a db session. Then after_request decorator to close the session after each request.
This doesn’t seem to be working. I have not prevented Broken Pipe errors.
Should I just create a database session when I need it and close it? Then if I find Broken Pipe error try to find the source of the problem.
Diagram of
/r/flask
[https://redd.it/1cqus6q
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Why isn't IPython more popular?
In the past years, I've had a lot of frustration with the python console:
- pasting multiline is complicated
- editing is impossible
- no syntax highligthing etc
Now I discover the IPython console...
It's wonderful... I use it all the time to try snippets, which I used to run in colab or in yupyter.
Why isn't this shell more used and more known?
/r/IPython
https://redd.it/1crp70l
In the past years, I've had a lot of frustration with the python console:
- pasting multiline is complicated
- editing is impossible
- no syntax highligthing etc
Now I discover the IPython console...
It's wonderful... I use it all the time to try snippets, which I used to run in colab or in yupyter.
Why isn't this shell more used and more known?
/r/IPython
https://redd.it/1crp70l
Reddit
From the IPython community on Reddit
Explore this post and more from the IPython community
D How do you get better at reading proof in the ML papers, with background in CS only?
Hi everyone, as the title, how do you get better at reading proof in the ML papers? The ML papers I mentioned are those in adversarial ML, e.g. Certified Adversarial Robustness via Randomized Smoothing. For context, I have basic knowledge of calculus, linear algebra, but most of the time when reading the proof, sometime I feel that one line just come out of nowhere, and I can't reason why or how they do it. Maybe because my background is CS, with focus on software, so I'm lacking of the rigorous proof-based math stuff. Please help!!
/r/MachineLearning
https://redd.it/1crr0fa
Hi everyone, as the title, how do you get better at reading proof in the ML papers? The ML papers I mentioned are those in adversarial ML, e.g. Certified Adversarial Robustness via Randomized Smoothing. For context, I have basic knowledge of calculus, linear algebra, but most of the time when reading the proof, sometime I feel that one line just come out of nowhere, and I can't reason why or how they do it. Maybe because my background is CS, with focus on software, so I'm lacking of the rigorous proof-based math stuff. Please help!!
/r/MachineLearning
https://redd.it/1crr0fa
Reddit
From the MachineLearning community on Reddit
Explore this post and more from the MachineLearning community