pythondaily | Education

Telegram-канал pythondaily - Python Daily

1102

Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels

Subscribe to a channel

Python Daily

Is it bad to display primarykeys on the client side?

Let's say I put the primary\
key of an object inside of the URL or inside a hidden form field of, as an example, a form that deletes an object selected by the user. In that case, the user would be able to access it very easily. Is it a bad thing to do and why?

/r/django
https://redd.it/1fnzwu0

Читать полностью…

Python Daily

P I built a live AI sports commentator that can talk in any language


It detects key frames in the video and talks without prompting. In the backend, I use Whisper for STT, Gemini Flash for vision and ElevenLabs for voice.

Demo: https://www.veed.io/view/b19f452b-9589-4270-b11f-e041f2065713?panel=share

GitHub: https://github.com/outspeed-ai/outspeed/tree/main/examples/sports\_commentator

/r/MachineLearning
https://redd.it/1fnry1x

Читать полностью…

Python Daily

Fantasy Premier League - Mini-League History

**Repo/Dashboard Links:**

* [Github Repo Link](https://github.com/EdwardAnalytics/fpl-league-history)
* [Streamlit dashboard Link](https://fpl-league-history.streamlit.app/)

**What My Project Does:**

The FPL League History dashboard creates tables for FPL leagues showing past winners, and team records. This data is not available directly on the FPL league website, and utilises the FPL API to create it.

**Features**

* Allows user to input specific league ID to get historical data from the FPL API
* Creates a Streamlit dashboard which is hosted on the Streamlit Community Cloud
* There's also a script to generate it as a dashboard with Dash
* A caveat is that it looks at who is in the league at the moment, and looks back at their past season records.
* It's for smaller sized leagues (up to \~100 teams max).

**Comparison**

* [https://www.livefpl.net/league\_history/](https://www.livefpl.net/league_history/) - Not the primary objective of the dashboard but it does show individual season history. It does not show the summary aggregated stats (e.g. most winners etc.)

**Target Audience:**

* Fantasy Premier League players

Any feedback on the GitHub repo or dashboard would be appreciated!

/r/Python
https://redd.it/1fnolxe

Читать полностью…

Python Daily

PyTrilogy adds typing and a semantic layer to SQL

PyTrilogy lets you define strongly typed interfaces for your SQL (think TypeScript vs JavaScript) and directly write queries in that same syntax. It's written in Python and can be used from python directly or compile to SQL to be used by other tools. The unified model definition and query language means you can iterate on the model and your queries in realtime. It aims to be more concise, composable, and reusable than SQL, without sacrificing the best parts of the language.

# What My Project Does

* Provides a lightweight, SQL-like language for defining a semantic layer and writing queries against it
* Supports composing/reusing models and through a python-like import syntax
* Automatic join resolution that provides correctness across grains/aggregation/nulls
* Backends for compiling and executing against DuckDB, Bigquery, Snowflake, SQL Server
* Type-checking + other static validation to surface errors sooner in the development cycle

Links:

* [Interactive Demo/Docs](https://trilogydata.dev/)
* [Github](https://github.com/trilogy-data/pytrilogy)

# Target Audience

Do you work with data analytics and love the declarative nature of SQL, but hate some of the sharp corners? Trilogy's opinionated about a workflow where you get your data model accurate, and can then query expressively and confidently. It's not well suited to transactional work, and isn't an ORM.

Aspirationally, for professional data teams it

/r/Python
https://redd.it/1fn9bxp

Читать полностью…

Python Daily

Haystack and Solr

Hello guys, this is just a general question, nothing specific. But I'm currently building a search engine for my Django project. My question is, are there any resources where I can Haystack coupled with Solr?

Anything would help, thank you. Please let me know if you need more details

company.py

from django.db import models
from django.conf import settings
from.user import User


# Create your models here.
class ArboristCompany(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True, related_name='arborist_company')
arborist = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
company_name = models.CharField(max_length=30)
company_logo = models.ImageField(upload_to='company_logo', blank=True)

def __str__(self):
return f'{self.company_name} ArboristCompany'

```

arborist_model.py

from django.db import models
# Create your models here.
# Model Arborist
class Arborist(models.Model):
arboristcity = models.CharField(maxlength=30)
arboriststate = models.CharField(maxlength=30)
yearsexperience = models.CharField(maxlength=30)
price = models.IntegerField(null='True')

class Meta:
ordering = 'arborist_city',

/r/django
[
https://redd.it/1fnaae2

Читать полностью…

Python Daily

is oauth verification required if you're just using non sensitive scopes and want more than 100 users?

I am integrating oauth to my django project and I'm only using non sensitive scopes, also no brand logo or anything. It even says that no Verification is required for my app but still I'm seeing the 100 user cap there.

Edit: I forgot to mention, I'm using Google's OAuth consent screen

/r/django
https://redd.it/1fn6k3y

Читать полностью…

Python Daily

Hy 1.0.0, the Lisp dialect for Python, has been released

- Announcement post
- Official website
- Source code

# What My Project Does

Hy (or "Hylang" for long) is a multi-paradigm general-purpose programming language in the Lisp family. It's implemented as a kind of alternative syntax for Python. Compared to Python, Hy offers a variety of new features, generalizations, and syntactic simplifications, as would be expected of a Lisp. Compared to other Lisps, Hy provides direct access to Python's built-ins and third-party Python libraries, while allowing you to freely mix imperative, functional, and object-oriented styles of programming. (More on "Why Hy?")

Okay, admittedly it's a bit much to refer to Hy as "my project". I'm the maintainer, but AUTHORS is up to 113 names now.

# Target Audience

Do you think Python's syntax is too restrictive? Do you think Common Lisp needs more libraries? Do you like the idea of a programming language being able to extend itself with as little pain and as much flexibility as possible? Then I've got the language for you.

After nearly 12 years of on-and-off development and lots of real-world use, I think I can finally say that Hy is production-ready.

# Comparison

Within the very specific niche of Lisps implemented in Python, Hy is to my knowledge the most feature-complete and generally

/r/Python
https://redd.it/1fmur2b

Читать полностью…

Python Daily

D Simple Questions Thread

Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!

Thread will stay alive until next one so keep posting after the date in the title.

Thanks to everyone for answering questions in the previous thread!

/r/MachineLearning
https://redd.it/1fmv9zi

Читать полностью…

Python Daily

What Project should i made to gain knowledge of industry and real life project?

I am just recently completed my btech and i didn't get job. Because of experience . So how can i get a experience?? so suggest project which support my CV
Than

/r/django
https://redd.it/1fmlytf

Читать полностью…

Python Daily

D Last Week in Medical AI: Top Research Papers/Models 🏅(September 14 - September 21, 2024)


Last Week in Medical AI: Top Research Papers\/Models 🏅\(September 14 - September 21, 2024\)



Medical AI Paper of the Week

How to Build the Virtual Cell with Artificial Intelligence: Priorities and Opportunities
This paper proposes a vision for "AI-powered Virtual Cells," aiming to create robust, data-driven representations of cells and cellular systems. It discusses the potential of AI to generate universal biological representations across scales and facilitate interpretable in-silico experiments using "Virtual Instruments."

Medical LLM & Other Models

GP-GPT: LLMs for Gene-Phenotype Mapping
This paper introduces GP-GPT, the first specialized large language model for genetic-phenotype knowledge representation and genomics relation analysis. Trained on over 3 million terms from genomics, proteomics, and medical genetics datasets and publications.
HuatuoGPT-II, 1-stage Training for Medical LLMs
This paper introduces HuatuoGPT-II, a new large language model (LLM) for Traditional Chinese Medicine, trained using a unified input-output pair format to address data heterogeneity challenges in domain adaptation.
HuatuoGPT-Vision: Multimodal Medical LLMs
This paper introduces PubMedVision, a 1.3 million sample medical VQA dataset created by refining and denoising PubMed image-text pairs using MLLMs (GPT-4V).
Apollo: A Lightweight Multilingual Medical LLM


/r/MachineLearning
https://redd.it/1fmkhok

Читать полностью…

Python Daily

Sunday Daily Thread: What's everyone working on this week?

# Weekly Thread: What's Everyone Working On This Week? 🛠️

Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!

## How it Works:

1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.

## Guidelines:

Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.

## Example Shares:

1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!

Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟

/r/Python
https://redd.it/1fmgft6

Читать полностью…

Python Daily

How do I get the role's permisssion insted of the role_id

So i have this role based access permission. but when i am trying to get the users role it is showing me permission insted.

decorators.py

def permission_required(permission):
    print("..")
    print(permission)
    """Restrict a view to users with the given permission."""
    def decorator(f):
        u/wraps(f)
        def decorated_function(*args, **kwargs):
            if not current_user.is_authenticated:
                abort(403)
            print(current_user)
               
            permissions = db.session.query(Role.permission).join(Permission.permission).filter_by(permission=permission).first()
            print(permission)
            print(permissions)
            if permission != permissions:
                abort(403)
         

/r/flask
https://redd.it/1fmala1

Читать полностью…

Python Daily

Deploying flask app for free

Hey,
I wanna know a way to deploy a flask app for free.
My use case is, i wanna allow few of my friends to change the variable for my ML model so that i can get the perfect parameter.
So the hosting service must be able to handle few request and train my ml model with about 50k text inputs at maximum.

/r/flask
https://redd.it/1fm7tbf

Читать полностью…

Python Daily

D How do researchers in hot topics keep up?

Yesterday night I was reading "Training Language Models to Self-Correct via Reinforcement Learning" (https://arxiv.org/abs/2409.12917) from Deepmind folks, which was released 2 days ago. The paper is about using RL to pre-train LLMs, but that is somehow irrelevant for my question.

The paper is interesting, but while I was reading I wondered: how do they have time to do all that is mentioned there? With this I mean:

- Based on the pretrained models that are used, most likely they only started working on it like 2-3 months ago

- Most references and citations are from the second half of 2024 (from May-June onwards), so less than 3 months old as well

So, during the course of those few months, they had to: read and thoroughly study all cited papers (which are around 45 in this case, and again: most of them are extremely recent), come up with the new idea, develop it, do experiments (which nowadays SFT is not a matter or 15 mins either), compile results, and write the actual paper. And this assumes that they are not concurrently working on other papers/endeavors…

As a solo researcher, I cannot even imagine doing something similar in that period of time, but even with a small

/r/MachineLearning
https://redd.it/1flz1vo

Читать полностью…

Python Daily

App to upload to an s3 bucket

/r/djangolearning
https://redd.it/1flttnw

Читать полностью…

Python Daily

Simplify OAuth2 token capture in your Django apps without the overhead of django-allauth.

Hey everyone,

I’m glad to share `django-oauth2-capture`, a Django package designed to simplify the process of capturing OAuth2 tokens for non-login purposes.


**Why did I create this?**

While working on projects that require acting on behalf of users on external platforms like GitHub, LinkedIn, and X (Twitter), I found that existing solutions like `django-allauth` weren’t suitable. `django-allauth` is fantastic for authentication and user management, but using it solely for token capture without user authentication feels like working against the grain of both the framework and the package. It introduces unnecessary complexity when you just need to obtain an OAuth2 token.


**What does** `django-oauth2-capture` **offer?**

By removing unnecessary abstractions, the complexity of handling OAuth2 melts away into **three important flows**:

1. **Initiate OAuth2 Authorization**: Start the authorization process with the external platform.
2. **Handle the Callback and Capture the Token**: Receive the token securely without extra overhead.
3. **Refresh Tokens as Needed**: Maintain token validity seamlessly.

This streamlined approach makes it easier to integrate with various external platforms without the bloat.


**Why is this important?**

This package is a cornerstone of all my **LLM (Large Language Model) projects** across healthcare, finance, publishing, and sh*t-posting. It enables these applications to interact with external services efficiently and securely.


**Check it out on GitHub:**

[github.com/heysamtexas/django-oauth2-capture](https://github.com/heysamtexas/django-oauth2-capture)

I'm still

/r/django
https://redd.it/1fnn6nl

Читать полностью…

Python Daily

I've just released v1.0.0 of my first Django package!

Hi everyone! 👋

I've been working with Django for the last 5 years and I've finally released my first package! It is called [django-auto-actions](https://github.com/Flexonze/django-auto-actions).

By adding it to your ModelAdmins, it will automatically generate basic Django admin actions based on your models' fields. For example, if your model has a nullable `is_approved` BooleanField, it will create the following admin actions:

* Set *is\_approved* to True
* Set *is\_approved* to False
* Set *is\_approved* to None

Right now, it works with **BooleanFields**, **DateTimeFields**, **DateField** and **TimeField**.

This idea came to me because of a client who kept asking me for a way to bulk update a bunch of objects. I had to create very similar admin actions for each time. I figured I'd extract this logic into a more generic mixin that would work with every model. I then decided to make a package out of it.

I would **LOVE** for you to try it and give me some feedback. Thanks in advance!

/r/django
https://redd.it/1fnc8vr

Читать полностью…

Python Daily

A PyQt TodoMVC cross-OS desktop app

https://github.com/Jeff-Mott-OR/pyqt-todomvc

What My Project Does and A brief comparison: From project’s readme:

> In the spirit of TodoMVC, I used PyQt (Python + Qt) to create a cross-OS desktop todo app. And I used the fman build system (aka fbs) to package the Python runtime and the Qt library binaries into a standalone executable and installer for each of the big three OSes.

> But why?
For fun and no profit. When I learned C++, at first I put off learning a GUI library. But I was interested in and always meant to learn the Qt GUI library. It lets you write desktop GUIs once that will look native for each of the various OSes. Later, after I did a hobby project in Python, I stumbled upon PyQt -- a project that exposes the Qt C++ library in Python -- and I decided to dive in.

/r/Python
https://redd.it/1fnl415

Читать полностью…

Python Daily

ComiQ: Comic-Focused Hybrid OCR Library


What My Project Does:

ComiQ is an advanced Optical Character Recognition (OCR) library specifically designed for comics. It combines traditional OCR engines like EasyOCR and PaddleOCR with Google's Gemini Flash-1.5 model to provide accurate text detection and translation in comic images.

Features

Hybrid OCR approach for improved accuracy of Bounding Box of Comics
Utilizes Gemini Flash-1.5 model, for fixing errors generated by the OCR Engines.
Gemini Flash-1.5 model, which is free, and allows 1,500 requests per day(As of 23-09-2024).
Specialized in detecting text within comic bubbles and panels
Support for multiple OCR engines
Easy-to-use Python interface

Comparison

[Speech-Bubble-Aware-Automatic-Colorization](https://github.com/Rabbit1010/Speech-Bubble-Aware-Automatic-Comic-Colorization) : Has Downside of Mis-Detection of Text Bubbles, and Does not Extract Text.
Bubble-Detector-YOLOv4 : Has Downsides, with detection of Directional Text, and Background text bubble, and also dosen't extract Text

Capabilities

Please Visit the [Examples](https://github.com/StoneSteel27/ComiQ/tree/main/examples) Section in the GitHub Page.

Target Audience:

ComiQ, was built for people, who wants to extraxct text and process from Comics image,


Your Feedback, and advice are welcome 😊

Github: https://github.com/StoneSteel27/ComiQ

/r/Python
https://redd.it/1fnchtz

Читать полностью…

Python Daily

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/1fn7daq

Читать полностью…

Python Daily

Between Render platform and AWS

I’m working on my startup idea and wondering what is better option for me between render and aws.

Overall, render unload some parts of works and take care of it. On the other hand AWS looks cheaper, and once I have one web app deployed on AWS, I can just copy or replicate for another web app.

My question is Is AWS really cheaper with side project that hasn’t found PMF yet? How complex will it be to deploy on AWS instead of render. Anything particular I need to know about render?

I’m a backend engineer, learning frontend. My web app tech stack will be:

1. Django main framework
2. Either django celery for async task or another container to run long time async task
3. Influx database
4. Postgres database
5. uwsgi
6. Redis might or might not needed for celery
7. JavaScript
8. React
9. Cloudflare for DNS
10. TLS
11. Stripe payment
12. No other authentication needed as Django already has battery for authentication

I guess the render solves some problems like TLS and postgres, static site part… how about other parts and how hard will it be with AWS and their cost



/r/django
https://redd.it/1fn55hq

Читать полностью…

Python Daily

Choosing the Right Authentication API for Django REST Framework
https://www.django-rest-framework.org

/r/django
https://redd.it/1fmuxyx

Читать полностью…

Python Daily

D Understanding 1.58-bit Large Language Models

Hi all, I wrote an arunnanda/understanding-1-58-bit-large-language-models-88373010974a">article about ternary (trinary) models to summarize what I read on the topic. It's more like a high level literature review. The target audience is the developer who is curious about the research but doesn't have the time to dig into the papers themselves. It is a free article on Medium.


Appreciate any feedback and inputs on it.

/r/MachineLearning
https://redd.it/1fmnkar

Читать полностью…

Python Daily

Shpuld i go for advance concepts if i am going to work in Ai in future?

Okay so i was learning Machine learning and decided to stop and focus on Django

I have built projects and have good understanding of Django at this point

I wanna ask if i should go for more advance concepts if i am going to work in Machine learning in future

I think i wont be working in Machine learning atleast for an year(will be learning in this year)

So should i learn advance concepts? Like will they help me even if i start working as a ML engineer

It would be good if someone who worked in django and now is working in ML can guide me

Thanks in advance

/r/django
https://redd.it/1fmpc3d

Читать полностью…

Python Daily

D 4x 4090 vs H100 in JAX

Does anyone have experience with multi-GPU JAX? I know there is this guide which discusses data-parallel, but what if at some point I want to finetune a large model that cannot fit in 24GB (e.g. LLM or large vision model)? Can anyone elaborate on the real-world performance hit for data-sharding and model-sharding in JAX? Would a 4x 4090/5090 setup be significantly slower than an H100 in these cases? Is there a large development-time overhead for model/data sharding in JAX? There also seem to be multiple avenues to achieve parallelism. In practice, do most people tend to use`pmap`, sharding, or some other approach?

My research tends to focus on RL, so I am not sure whether HBM of the H100 is as big as a factor as it is with transformer/LLMs.

/r/MachineLearning
https://redd.it/1fmiunf

Читать полностью…

Python Daily

firebase firestore populator

Alright, so I had this issue: when I wanted to use algorithms in a Python backend script that would later need Firestore, I didn't know what to do. I would always use the same script that would automatically generate filler data for me in the database. Then, I realized that I could create a package that does this.


So, I created a package that fixes that issue. It has saved me a lot of time recently, and you can do so much more with it. Here's the link: https://pypi.org/project/firebase-populator/

/r/flask
https://redd.it/1fm8fe1

Читать полностью…

Python Daily

Latent Diffusion in pure-torch (no huggingface dependencies) P

Been fiddling with diffusion for the last year and I decided to release a package with my implementation from scratch of DDPM latent diffusion models. It includes implementations for both the denoising UNet and the VAE+GAN used to embed the image.

It's pure torch, as I find Huggingface diffuser's good for simple tasks but if you want to learn how the inners work or to hack the model a bit, it falls short as the codebase is humongous and not geared towards reusability of components (but I insist is a good library for its purposes). To install it simply run

pip install tiny-diff

I aimed to create a reusable implementation, without any ifs in the forward methods (squeezing polymorphism as much as I could so the forward is as clear as possible) and modular components (so if you don't want to use the whole model but parts of it you can grab what you want)

Repo Link: https://github.com/AlejandroBaron/tiny-diff

/r/MachineLearning
https://redd.it/1flxs7d

Читать полностью…

Python Daily

How can i get better at asking better questions so i can build better software with less meetings

Hey guys I'm a junior developer currently working in banking and I want to know how can i learn to ask better questions so i can take business requirements and make the required software with as little meetings as possible

I believe im a decent developer but i struggle to ask the right questions therefore there is alot of changes that happen throughout the duration of development, ive been fortunate enough to be allowed to build whole features alone but i feel my bad communication will hinder my growth. Any tips

/r/django
https://redd.it/1fllt76

Читать полностью…

Python Daily

Google chrome crashing when using drf and react

Has anyone else faced this issue when working on drf and react project in vscode.
How to resolve this?

/r/django
https://redd.it/1fm37js

Читать полностью…

Python Daily

Django vs Laravel

What is something you would only develop with Django and not Laravel, and vice versa?

Edit: Been working with Django for several years but never Laravel so I'm trying to differentiate between the two by example. Thanks

/r/django
https://redd.it/1flx0xd

Читать полностью…
Subscribe to a channel