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
Discussion: Mark Zuckerberg on Meta's Strategy on Open Source and AI during the earnings call

During the recent earnings call, Mark Zuckerberg answered a question from Eric Sheridan of Goldman Sachs on Meta's AI strategy, opportunities to integrate into products, and why they open source models and how it would benefit their business.

I found the reasoning to be very sound and promising for the OSS and AI community.

The biggest risk from AI, in my opinion, is not the doomsday scenarios that intuitively come to mind but rather that the most powerful AI systems will only be accessible to the most powerful and resourceful corporations.

Quote copied from Ben Thompson's write up on Meta's earning in his Stratechery blog post which goes beyond AI. It's behind a paywall but I highly recommend it personally.

Some noteworthy quotes that signal the thought process at Meta FAIR and more broadly

We’re just playing a different game on the infrastructure than companies like Google or Microsoft or Amazon
We would aspire to and hope to make even more open than that. So, we’ll need to figure out a way to do that.
...lead us to do more work in terms of open sourcing, some of the lower level models and tools
Open

/r/MachineLearning
https://redd.it/1373nhq
D Oblivus Cloud | Scalable GPU servers from $0.29/hr

Greetings r/MachineLearning!

This is Doruk from Oblivus, and I'm excited to announce the launch of our platform, Oblivus Cloud. After more than a year of beta testing, we're excited to offer you a platform where you can deploy affordable and scalable GPU virtual machines in as little as 30 seconds! We believe that Oblivus Cloud is the perfect alternative to other cloud service providers when it comes to training your ML models.

https://oblivus.com/cloud

🤔 What sets Oblivus Cloud apart?

At the start of our journey, we had two primary goals in mind: to democratize High-Performance Computing and make it as straightforward as possible. We understand that maintaining GPU servers through major cloud service providers can be expensive, with hidden fees adding to the burden of running and maintaining servers.

Additionally, the cloud can sometimes be overly complex for individuals who don't have much knowledge but still require powerful computing resources.

That's why we decided to create a platform that offers affordable pricing, easy usability, and high-quality performance. Oblivus Cloud provides just that - a simple, affordable, and high-quality alternative for anyone in need of powerful computing resources.

 Features

Oblivus Cloud comes packed with a wide range of features to make your experience smooth, seamless, and fully customizable. Here are some

/r/MachineLearning
https://redd.it/1370xg9
Build a full stack social network - Django/DRF/Vue3/Tailwind - Free YouTube Series

Hey guys,
a few weeks ago I started publishing my newest course on my YouTube channel.

In this course, you will learn how to build a social network from scratch using Django with Django Rest Framework for the backend, and the frontend will be built using Vue and Tailwind.

Some of the features of the social network:
\-Authentication with jwt
\-Posts with attachments (showing on your feed, your profile and similar).
\-Direct messaging
\-Friends (sending/accepting friend requests)
\-Liking/discussing posts

So far, I have posted 4 parts with a total of almost 4 hours of content. And much more are coming :-D
I hope this sounds interesting and that it can help some of you.

If you're interested, you can find the playlist here:
https://www.youtube.com/playlist?list=PLpyspNLjzwBlobEvnZzyWP8I-ORQcq4IO


PS, I would love it if you subscribed to my channel if you want more content like this :-D

/r/djangolearning
https://redd.it/137c38x
ML model RAM over usage issue

Hi everyone, I am having an issue of RAM over usage with my ML model. My model is based on Tfidf+Kmeans algo, and uses flask + gunicorn architecture.

I have multiple gunicorn workers running on my server to handle parallel requests. The issue is that the model is not being shared b/w workers. Instead, it makes a copy of itself for each worker.

Since the model is quite big in size, this is consuming a lot of RAM. How do I solve this issue such that the model is shared between workers without being replicated?

/r/flask
https://redd.it/137ec9y
Are there any working examples I can download?

I know there are a number of tutorials but I was wondering if there are any working examples I can download of say, a basic bootstrap form.

Thanks

/r/flask
https://redd.it/137ko94
(Failed - but working 100%) Interview challenge

Recently I did not even make it to the interview due to the technical team not approving of my one-way directory sync solution.

I want to mention that I did it as requested and yet I did not even get a feedback over the rejection reason.

Can someone more experienced take a glance and let me know where \\ what I did wrong? pyAppz/dirSync.py at main · Eleuthar/pyAppz (github.com)

Thank you in advance!

​

LE: I much appreciate everyone's feedback and I will try to modify the code as per your advice and will revert asap with a new review, to ensure I understood your input.

/r/Python
https://redd.it/137gvt9
Creating 2fa with pyotp

I have a flask app that I'm trying to add a 2fa option to. I'm using pyotp to generate a code that will be sent via email.

The user signs in normally (email, password) and and if they've opted-in to 2fa they are then redirected to a page asking them to submit the security code they received in an email.

The challenge I'm facing is figuring out how I can carry the user object info to the 2fa route so that if they enter the correct code I can login\_user(user)

If they enter the correct email and password but the wrong code I need to retain the fact that they entered the email and password correctly on their following attempts.

There's a login route, and a 2fa code route.

Currently I have the 2fa code generated when the user lands on the 2fa route, there's a function called otp() that creates the one time password:


```
@app.route("/twofactor", methods=\['GET', 'POST'\])
def twofactor():
if current\_user.is\_authenticated:
return redirect(url\_for('login'))
else:
x = otp()
form=TwoFactor()
if form.validate\_on\_submit():


/r/flask
https://redd.it/137lqpb
Tutorial: Deploying a Django & django-q application with Kubernetes at Digital Ocean with CI/CD Github actions and SSL certificate using HTTPS communication.

Let me know if you have any thoughs about this, I'll try to keep the article updated. I've had issues deploying to Digital Ocean when having a django-q application, so I opted for using Kubernetes, but didn't found a good guide for this, so here is one! Hope you'll enjoy it.

https://medium.com/@alexanderlindgren\_17992/deploying-a-django-django-q-application-with-kubernetes-at-digital-ocean-with-ci-cd-github-e1580cc96ea5

If you enjoy this article and want to keep track of my future articles regarding Django, web-development and entrepreneurship, click here: https://medium.com/@alexanderlindgren\_guttae/subscribe

/r/django
https://redd.it/137kwt1
Noob Question: How to validate form when one button is pressed but not the other?

I have a very simple application going that allows you to either search a pokemon by name or get one randomly. I would like it so that my form is validated when submitting a name, but not when clicking 'random'. Currently, the form IS validated even when clicking the 'random' button. For example, if the field is empty and I click 'random' it complains about the DataRequired() validator. Here is the relevant code:


class PokemonNameForm(FlaskForm):
name = StringField('Enter a pokemon name...', validators=[DataRequired(), Length(3, 40)])
submit_button= SubmitField('Submit')
random_button = SubmitField('Random')

...

@app.route("/", methods=['GET', 'POST'])
def home():
form = PokemonNameForm()
pokemon = get_pokemon()

if form.is_submitted():

if form.submit_button.data:


/r/flask
https://redd.it/1379f46
Selenium over scrapy

I keep seeing posts about using selenium to scrape pages and I’m curious why people prefer that over a library like scrapy

I’ve worked with both and absolutely prefer scrapy — just wondering out loud

Thank you

/r/Python
https://redd.it/137zeq8
What IDE do y’all use

I’m the process of learning python. I used net beans for Java

/r/Python
https://redd.it/1383eox
Behave Driven Development Python library

There are Python BDD frameworks out there, most notably `behave` (https://github.com/behave/behave).

They are nice. However, from time to time I find myself fighting against some design choices made by their authors. I thought that things can be made more lightweight, flexible and less constrained.

I thought that a tool with more of a library-like architecture, rather than a framework, might be fit for the purpose.

`Rumex` is my work-in-progress implementation of such a tool: https://github.com/uigctaw/rumex

I would appreciate any feedback. Be it minor things or fundamental ones - like perhaps I'm misguided in my assessment of perceived inflexibility of the existing tools.

/r/Python
https://redd.it/13874wi
Hosting recommendation

Hi all. I have a couple of dedi servers at inmotion, but they all lack the "Linux Cloud" feature and want to charge me rather high amounts to enable this feature. Ideally I was going to deploy via the "Setup Python App' in cpanel, but of course, this requires Cloud Linux.

Trying to do this without it via WHM has proven to be a nightmare and I was hoping somebody could recommend a suitable alternative for a domain (with sub domains), static IP and easy deployment of django apps?

/r/django
https://redd.it/138h1y4
Concantantion of strings from fields of model

I'm trying to combine values passed to fields name and surname to create a string to be stored in full\_name field. When l was looking for solutions, I found suggestion to overwrite Django's save method. I tried, but get no expected results. Instead after making a few instances of Author class and trying to loop over them in Django shell. I get following results:

> \--snip--/models.py", line 13, in __str__
>
> """Override save method."""
>
>AttributeError: 'Author' object has no attribute 'full_name'

​

Code is here:

https://pastebin.com/Kx9ea6x4

/r/djangolearning
https://redd.it/138f5wx
When do you use Q?

A question that just came to my mind. I wrote:

etfs = ETF.objects.filter(Q(updated_at__lte=timezone.now() -timezone.timedelta(days=1)))

but to be honest, it's not a complex query. However, I am tending to automatically use a Q object. When do you use it, would you use it here?

I hope to read some opinions

/r/django
https://redd.it/138kki6
Can you monitor multiple urlpatterns with Django's runserver autoreload

In the project I'm working on, I'd like to have it run 2 apps on one runserver for development purposes (standalone in production), to utilize amongs others autoreload options.

What I'd like to do is have wsgi application, and asgi application by implementing Django channels next to it. For that, I feel like I need to have 2 ROOT_URLCONFs basically, as one would apply to wsgi, and other to asgi application. I am interested is there a way to make runserver pay attention to multiple ROOT_URLCONFs or urlpatterns whatever you want to name them? And does this approach make sense in the first place, as from what I've seen on the web, it's not such an uncommon setup, but I haven't seen anyone placing it under one runserver.

For the ease of development setup it would be one server, as there's already an overhead on startup of the project development.

/r/django
https://redd.it/138x6u5
Deploy Django app using Docker or not...

So on my previous project (which right now has 300,000 page views per month) I tried using docker but kept having issues so I quickly gave up.

Instead, I ended up deploying it in AWS by using an EC2 Launch Template, so whenever a new instance is needed the template will launch and set up the instance (updates yum, installs Python, and Code Deploy agent). Then the Code Pipeline will deploy and run my application using the Code Deploy agent.

I also have a NextJs frontend application that gets deployed in the same EC2 instance. So whenever there is any autoscaling, both Django and Nextjs get scaled at the same time.


All the infrastructure is set up using a Cloudformation template which took me almost 1 month to figure out since it was the first time I was dealing CloudFormation, Code Pipeline, Launch templates, autoscaling, etc.


Okay that's it for my current architecture for deploying my Django Application.

​

For my current project I'm considering using Docker to deploy it on ECS. Here are the current reasons why I'm reconsidering Docker once again.


1. People have mentioned that deploying Django directly in EC2 server (manually or through launch template)

/r/django
https://redd.it/138xurn
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/1395uno