Starlite: v1.27.0 updates
Hi Pythonistas!
Been 3 weeks since my last post here and a lot of new stuff happened in Starlite land.
First off, lemme start with the usual intro for those who don't know what im talking about: Starlite is an ASGI (async Python) API framework. It started out as an alternative to FastAPI - built on the same foundations: the Starlette ASGI Kit and pydantic. It evolved and has been intensely developed over the past year+ and is now a sophisticated and powerful API framework with a vibrant community and several (currently 4) maintainers.
Note regarding the name: The framework is called Starlite to show the relation to Starlette. This was important to me when starting this project, although to be honest Starlite now uses Starlette only in several select places and is almost completely distinct.
With this part out of the way - lemme give some updates:
1. We implemented a new on_app_init hook that allow plugins to set all elements of application configuration (more on this lower).
2. Building on the point above, we updated the
/r/Python
https://redd.it/y2w6fl
Hi Pythonistas!
Been 3 weeks since my last post here and a lot of new stuff happened in Starlite land.
First off, lemme start with the usual intro for those who don't know what im talking about: Starlite is an ASGI (async Python) API framework. It started out as an alternative to FastAPI - built on the same foundations: the Starlette ASGI Kit and pydantic. It evolved and has been intensely developed over the past year+ and is now a sophisticated and powerful API framework with a vibrant community and several (currently 4) maintainers.
Note regarding the name: The framework is called Starlite to show the relation to Starlette. This was important to me when starting this project, although to be honest Starlite now uses Starlette only in several select places and is almost completely distinct.
With this part out of the way - lemme give some updates:
1. We implemented a new on_app_init hook that allow plugins to set all elements of application configuration (more on this lower).
2. Building on the point above, we updated the
SQLAlchemyPlugin to now support creating a DB connection and injection sessions using dependency injection. This is completely optional, but it also allows using Starlite with SQLAlchemy as an/r/Python
https://redd.it/y2w6fl
GitHub
GitHub - litestar-org/litestar: Light, flexible and extensible ASGI framework | Built to scale
Light, flexible and extensible ASGI framework | Built to scale - litestar-org/litestar
Instructor split us into teams to turn a percentage into a letter grade "using as few lines of code as possible"; here is the monstrosity our team came up with.
Had to share this because I thought it was funny; I'm currently in a programming 101 course at my university, and the challenge given today was to write a program which can turn an input percentage into a standard letter grade. He only specified "in as few lines as possible". Not sure if it is PEP compliant... any feedback?
grade = "A+" if (percentage := float(input("Enter the percentage grade: "))) >= 100 else "F"
if 60 <= percentage < 100: grade = chr(-int(percentage // 10) + 74) + '-', '', '+'((final_digit := int(percentage % 10)) >= 4) + (final_digit >= 7)
print(f"Your letter grade is {grade}!")
/r/Python
https://redd.it/y3dzhu
Had to share this because I thought it was funny; I'm currently in a programming 101 course at my university, and the challenge given today was to write a program which can turn an input percentage into a standard letter grade. He only specified "in as few lines as possible". Not sure if it is PEP compliant... any feedback?
grade = "A+" if (percentage := float(input("Enter the percentage grade: "))) >= 100 else "F"
if 60 <= percentage < 100: grade = chr(-int(percentage // 10) + 74) + '-', '', '+'((final_digit := int(percentage % 10)) >= 4) + (final_digit >= 7)
print(f"Your letter grade is {grade}!")
/r/Python
https://redd.it/y3dzhu
reddit
Instructor split us into teams to turn a percentage into a letter...
Had to share this because I thought it was funny; I'm currently in a programming 101 course at my university, and the challenge given today was to...
Having issues with flask behind httpd proxy
I'm unable to successfully pass static files from flask through httpd without having to have the root "/" proxies to my flask server which isn't an option as I have to proxy that elsewhere.
/r/flask
https://redd.it/y3hjl9
I'm unable to successfully pass static files from flask through httpd without having to have the root "/" proxies to my flask server which isn't an option as I have to proxy that elsewhere.
/r/flask
https://redd.it/y3hjl9
reddit
Having issues with flask behind httpd proxy
I'm unable to successfully pass static files from flask through httpd without having to have the root "/" proxies to my flask server which isn't...
Let's assume I am making a web app that will be used in the real world outside of development. Is the admin page still meant to be used?
Imagine I have an e-commerce store and on the admin page I want to have graph displaying sales.
Is using the admin page for this kind of stuff the correct way or is the right way to do it different?
/r/django
https://redd.it/y3bfm9
Imagine I have an e-commerce store and on the admin page I want to have graph displaying sales.
Is using the admin page for this kind of stuff the correct way or is the right way to do it different?
/r/django
https://redd.it/y3bfm9
reddit
Let's assume I am making a web app that will be used in the real...
Imagine I have an e-commerce store and on the admin page I want to have graph displaying sales. Is using the admin page for this kind of stuff...
What's new in the upcoming JupyterLab 4
https://blog.jupyter.org/accelerating-jupyterlab-68942bb8d602
/r/Python
https://redd.it/y3m7oj
https://blog.jupyter.org/accelerating-jupyterlab-68942bb8d602
/r/Python
https://redd.it/y3m7oj
Medium
Accelerating JupyterLab
How JupyterLab is switching to second gear for Version 4
MutableAI, AI Coding Assistant for Jupyter
https://www.orchest.io/blog/mutableai-ai-coding-assistant
/r/JupyterNotebooks
https://redd.it/vy69vp
https://www.orchest.io/blog/mutableai-ai-coding-assistant
/r/JupyterNotebooks
https://redd.it/vy69vp
www.orchest.io
MutableAI, AI Coding Assistant for Jupyter
Do you really need callback routes in flask?
Hi everyone, I recently started working on a new project that uses Flask for the backend. For this project, we need to interact with an external service(Netsuite): unfortunately, the calls to this service can take up to a couple of seconds to complete, and the external service seems to handle just a couple of requests in parallel. So we decided to implement a queue with redis(through the use of python rq) in order to limit the number of requests made to the external service. The problem is that we use this queue for almost every endpoint of the API: from my understanding(I'm kind of new to python and flask) since the jobs enqueued take a while to be processed, we are considering having a separate call for every endpoint(doubling, in fact, the number of total endpoints) in order to check on the status of the job. Is it really the only way to handle this type of situation in Flask?
I come from node.js, and there we use promises to handle asynchronous calls without blocking the server, but from some examples I've found online, that doesn't seem to be the preferred way of doing things in python. What would be the
/r/flask
https://redd.it/y3qf9r
Hi everyone, I recently started working on a new project that uses Flask for the backend. For this project, we need to interact with an external service(Netsuite): unfortunately, the calls to this service can take up to a couple of seconds to complete, and the external service seems to handle just a couple of requests in parallel. So we decided to implement a queue with redis(through the use of python rq) in order to limit the number of requests made to the external service. The problem is that we use this queue for almost every endpoint of the API: from my understanding(I'm kind of new to python and flask) since the jobs enqueued take a while to be processed, we are considering having a separate call for every endpoint(doubling, in fact, the number of total endpoints) in order to check on the status of the job. Is it really the only way to handle this type of situation in Flask?
I come from node.js, and there we use promises to handle asynchronous calls without blocking the server, but from some examples I've found online, that doesn't seem to be the preferred way of doing things in python. What would be the
/r/flask
https://redd.it/y3qf9r
reddit
Do you really need callback routes in flask?
Hi everyone, I recently started working on a new project that uses Flask for the backend. For this project, we need to interact with an external...
Jupyter Notebook competition - 2 weeks left to enter!
Are you passionate about \#coding, \#DataScience or \#EarthObservation? 📷
Don't miss out on the chance to showcase your skills and develop new Jupyter Notebooks using \#Copernicus data, whilst also being in with a chance of winning cash 📷 prizes!
Sign up before 31 July at: https://notebook.wekeo.eu/
https://preview.redd.it/ddy750xg4bb91.png?width=1920&format=png&auto=webp&s=ac315546d7fa35fd8a99e1c834ef0d3aea3c877f
/r/JupyterNotebooks
https://redd.it/vxzbw3
Are you passionate about \#coding, \#DataScience or \#EarthObservation? 📷
Don't miss out on the chance to showcase your skills and develop new Jupyter Notebooks using \#Copernicus data, whilst also being in with a chance of winning cash 📷 prizes!
Sign up before 31 July at: https://notebook.wekeo.eu/
https://preview.redd.it/ddy750xg4bb91.png?width=1920&format=png&auto=webp&s=ac315546d7fa35fd8a99e1c834ef0d3aea3c877f
/r/JupyterNotebooks
https://redd.it/vxzbw3
Facebook
#coding – Explore
explore #coding at Facebook
Cloning a Django project from Git how to set up the environment
I just cloned a Django project from Github and I want to know how to set-up the project to run in my Pycharm IDE. Do I have to create a new venv? And how to download all of the external libraries in the Github project with PyCharm?
​
Basically, I want to set it up to a point where I can run it.
/r/djangolearning
https://redd.it/y3vkmd
I just cloned a Django project from Github and I want to know how to set-up the project to run in my Pycharm IDE. Do I have to create a new venv? And how to download all of the external libraries in the Github project with PyCharm?
​
Basically, I want to set it up to a point where I can run it.
/r/djangolearning
https://redd.it/y3vkmd
reddit
Cloning a Django project from Git how to set up the environment
I just cloned a Django project from Github and I want to know how to set-up the project to run in my Pycharm IDE. Do I have to create a new venv?...
Underwater image and video color correction with Python
https://github.com/bornfree/dive-color-corrector
/r/Python
https://redd.it/y3onmb
https://github.com/bornfree/dive-color-corrector
/r/Python
https://redd.it/y3onmb
GitHub
GitHub - bornfree/dive-color-corrector: Dive and underwater image and video color correction
Dive and underwater image and video color correction - bornfree/dive-color-corrector
Moving from wsgi gunicorn to asgi gunicorn with uvicorn workers doubled my average response time in Django 4. Is this normal?
Basically, I'm wondering if this is par-for-the-course or if instead I have issues with my codebase that cause it to be slow when moving to `asgi`. What are other people's experience here? Did anyone get a speed up.
/r/django
https://redd.it/y3r8o7
Basically, I'm wondering if this is par-for-the-course or if instead I have issues with my codebase that cause it to be slow when moving to `asgi`. What are other people's experience here? Did anyone get a speed up.
/r/django
https://redd.it/y3r8o7
reddit
Moving from wsgi gunicorn to asgi gunicorn with uvicorn workers...
Basically, I'm wondering if this is par-for-the-course or if instead I have issues with my codebase that cause it to be slow when moving to...
I want your opinion on the e-commerce API I designed using DRF(still working on it)
I initially got this as a job assessment. To build an ecommerce API I couldn't meet up with the deadline so I decided to finish it and just add it to my GitHub repo as part of my projects. I've been working on this since last months. I want to know what you think about this and how to make it better. I'm currently working on addjng jwt authentication and swagger docs etc.
Repo: https://github.com/Klvxn/ecommerce-API
/r/djangolearning
https://redd.it/y43eme
I initially got this as a job assessment. To build an ecommerce API I couldn't meet up with the deadline so I decided to finish it and just add it to my GitHub repo as part of my projects. I've been working on this since last months. I want to know what you think about this and how to make it better. I'm currently working on addjng jwt authentication and swagger docs etc.
Repo: https://github.com/Klvxn/ecommerce-API
/r/djangolearning
https://redd.it/y43eme
GitHub
GitHub - Klvxn/ecommerce-API: Using django/django rest framework to design an API for an e-commerce store 🛒 with payment gateway…
Using django/django rest framework to design an API for an e-commerce store 🛒 with payment gateway integration 💳 - Klvxn/ecommerce-API
auto reload browser when editing templates/css
Hi,
when editing .html templates, manually reloading the page (F5) is required to see the changes. This is absolutely annoying and I want this to happen automatically. Everytime I edit a .html template or my .css files, I want the browser window to refresh automatically and show the changes immediately.
I came across livereload and "implemented" it as described in the docs. But I'm using the factory pattern so its not completely clear to me if I did it right:
I run it with
- In the terminal I see only the output from livereload, but not the output from Flask.
- When editing
While this is an 'okay solution' when working only on html/css files, it is basically unusable when also editing .py files.
Is there a way to integrate this better,
/r/flask
https://redd.it/y41bnw
Hi,
when editing .html templates, manually reloading the page (F5) is required to see the changes. This is absolutely annoying and I want this to happen automatically. Everytime I edit a .html template or my .css files, I want the browser window to refresh automatically and show the changes immediately.
I came across livereload and "implemented" it as described in the docs. But I'm using the factory pattern so its not completely clear to me if I did it right:
def create_app()
app = Flask(__name__)
...
from livereload import Server
server = Server(app.wsgi_app)
server.serve(host='127.0.0.1', port=5000)
return app
I run it with
flask --debug run. It works as far as it reloads the webpage when editing templates. Nice! But its far from perfect:- In the terminal I see only the output from livereload, but not the output from Flask.
- When editing
.py files, Flask reloads the app and the livereload server crashes with RuntimeError: Cannot close a running event loopWhile this is an 'okay solution' when working only on html/css files, it is basically unusable when also editing .py files.
Is there a way to integrate this better,
/r/flask
https://redd.it/y41bnw
PyPI
livereload
Python LiveReload is an awesome tool for web developers
calling all python users to respond to the 2022 Python Devs Survey!
The 2022 survey is now open: https://surveys.jetbrains.com/s3/c1-python-developers-survey-2022
The survey is run by JetBrains for the PSF, and getting responses from a wide range of users is very helpful for knowing who is using Python and how, and what is helpful to you:)
They're also offering a $100 gift card giveaway for responding.
/r/Python
https://redd.it/y43gag
The 2022 survey is now open: https://surveys.jetbrains.com/s3/c1-python-developers-survey-2022
The survey is run by JetBrains for the PSF, and getting responses from a wide range of users is very helpful for knowing who is using Python and how, and what is helpful to you:)
They're also offering a $100 gift card giveaway for responding.
/r/Python
https://redd.it/y43gag
Jetbrains
Python Developers Survey 2022
The official Python Developers Survey 2022. Join and contribute to the community knowledge!
P Easy finetuning diffusion models
Hello the community,
Since the release of diffusion models we saw many posts on that.
The one made by Lambdalabs was very interesting and fun.
However I found it personally difficult to finetune on my own data. This is why I created a repository that simplifies a bit the process https://github.com/YaYaB/finetune-diffusion.
It breaks down into several steps:
- Dataset creation and how to actually create a dataset using HuggingFace's datasets library
- Captioning if you do not have any using BLIP similarly to lambdalabs
- Finetuning based on a script released by HuggingFace on their diffusers repository
I've added a few functionalities in the whole process:
- Simplify the captioning and dataset creation in a few scripts
- Finetuning can be done on a local dataset (if you do not want or can not share your dataset on HuggingFace Hub)
- Validation prompts can be set at every epoch (to verify when the model begins to overfit)
- Model can be uploaded to HuggingFace hub every X epochs
- A script to test your model locally has been added
- A dataset card template is available
- A space app can be copied an modified
In the Results section of the README you'll find some examples of prompts based on a model finetuned on One Piece
/r/MachineLearning
https://redd.it/y3usrj
Hello the community,
Since the release of diffusion models we saw many posts on that.
The one made by Lambdalabs was very interesting and fun.
However I found it personally difficult to finetune on my own data. This is why I created a repository that simplifies a bit the process https://github.com/YaYaB/finetune-diffusion.
It breaks down into several steps:
- Dataset creation and how to actually create a dataset using HuggingFace's datasets library
- Captioning if you do not have any using BLIP similarly to lambdalabs
- Finetuning based on a script released by HuggingFace on their diffusers repository
I've added a few functionalities in the whole process:
- Simplify the captioning and dataset creation in a few scripts
- Finetuning can be done on a local dataset (if you do not want or can not share your dataset on HuggingFace Hub)
- Validation prompts can be set at every epoch (to verify when the model begins to overfit)
- Model can be uploaded to HuggingFace hub every X epochs
- A script to test your model locally has been added
- A dataset card template is available
- A space app can be copied an modified
In the Results section of the README you'll find some examples of prompts based on a model finetuned on One Piece
/r/MachineLearning
https://redd.it/y3usrj
Lambdalabs
How to fine tune stable diffusion: how we made the text-to-pokemon model at Lambda
How to fine tune Stable Diffusion on a Pokemon dataset to create a text to Pokemon image model. Use the guide to train your own Stable Diffusion models.
Behavior-driven development (BDD)
Hi guys I’m looking for some differences between Cucumber, FitNesse and TestLink. Since I want to determine with which tool I should work.
What make the one of them the best tool to use for test automation?
/r/django
https://redd.it/y47ynu
Hi guys I’m looking for some differences between Cucumber, FitNesse and TestLink. Since I want to determine with which tool I should work.
What make the one of them the best tool to use for test automation?
/r/django
https://redd.it/y47ynu
reddit
Behavior-driven development (BDD)
Hi guys I’m looking for some differences between Cucumber, FitNesse and TestLink. Since I want to determine with which tool I should work. What...
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/y4981u
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/y4981u
reddit
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...
I wrote a tool for running tests 100x - 1000x slower
While looking at my test coverage reports, I noticed that they only measure which lines were executed while running the test suite, but don't prove if they were in fact *tested* in any meaningful way.
So I wrote a crude tool which takes a source file, and for every line in the file, temporarily removes the line and runs the test suite. In the end you get a report showing which lines can be removed and the tests would still pass. Here's the tool:
import subprocess
path = "hc/api/models.py" # the file we're analyzing
test_cmd = "python manage.py test --keepdb --parallel=8 -v 0 --failfast"
original = open(path, "r").read()
report = open("report-%s.txt" % path.replace("/", "."), "w")
lines = original.split("\n")
for idx in range(0, len(lines)):
print("Processing %d / %d" % (idx, len(lines)))
# Optimization: skip empty lines and comments
if not lines[idx].strip() or lines[idx].strip().startswith("#"):
report.write(" %s\n" % lines[idx])
/r/Python
https://redd.it/y3w4ss
While looking at my test coverage reports, I noticed that they only measure which lines were executed while running the test suite, but don't prove if they were in fact *tested* in any meaningful way.
So I wrote a crude tool which takes a source file, and for every line in the file, temporarily removes the line and runs the test suite. In the end you get a report showing which lines can be removed and the tests would still pass. Here's the tool:
import subprocess
path = "hc/api/models.py" # the file we're analyzing
test_cmd = "python manage.py test --keepdb --parallel=8 -v 0 --failfast"
original = open(path, "r").read()
report = open("report-%s.txt" % path.replace("/", "."), "w")
lines = original.split("\n")
for idx in range(0, len(lines)):
print("Processing %d / %d" % (idx, len(lines)))
# Optimization: skip empty lines and comments
if not lines[idx].strip() or lines[idx].strip().startswith("#"):
report.write(" %s\n" % lines[idx])
/r/Python
https://redd.it/y3w4ss
reddit
I wrote a tool for running tests 100x - 1000x slower
While looking at my test coverage reports, I noticed that they only measure which lines were executed while running the test suite, but don't...
This media is not supported in your browser
VIEW IN TELEGRAM
[R] MotionDiffuse: Text-Driven Human Motion Generation with Diffusion Model + Gradio Demo
https://redd.it/y4eehd
@pythondaily
https://redd.it/y4eehd
@pythondaily
Installing anaconda on a new MacBook Pro M2 chip
https://youtu.be/YoEs6DU_Vtk
/r/JupyterNotebooks
https://redd.it/vsg3sd
https://youtu.be/YoEs6DU_Vtk
/r/JupyterNotebooks
https://redd.it/vsg3sd
YouTube
Installing Anaconda on a Mac M2 & Windows
This is our initial video in our series of #datascience with #python /R #tutorials coming up next.
We will be daily uploading videos and content related to AI/ML, #data #analytics, #cloud Computing.
Watch this space for more such tutorials and don't to…
We will be daily uploading videos and content related to AI/ML, #data #analytics, #cloud Computing.
Watch this space for more such tutorials and don't to…