Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
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
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
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
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
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
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
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:

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 loop

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
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
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
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
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
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
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
[P] A Proof-of-Concept of an AI Assistant Designer using UnrealEngine's Metahuman, stable diffusion, OpenAI's Whisper and GPT3
https://twitter.com/imcharleslo/status/1580591523447844865

/r/MachineLearning
https://redd.it/y4pzsv
flask sqlalchemcy models tips on direction and where to find documentation

Hi all, I have two primary questions. I am not new to programing as I have a background in CS but I am new to Python/Flask/Flask-squalchemy. Though I am EXTREMELY rusty as I've spent the past 6 years working on embedded systems.


That being said, my first is on documentation for flask and sqlalchemy. When I need to know the details about a class in Java, I can go right to the website and see what methods and fields said class have. But I can't seem to find that for flask-sqlalchemy. I'm not sure if I am looking in the wrong places but every time I google fu or search a relevant website I just get a tutorial or overarching explanation.


My second question will highlight why the first question is important to me. I am wondering if I am going in the right direction for my project and if I am not would appreciate someone pointing me in the right direction. I started off following a tutorial to build a basic "notes" website. It's mostly python with a little html and JS for front end stuff.

/r/flask
https://redd.it/y4rnw8