-
Python
,UV
⚙️ UV with GitHub Actions to run an RSS to README project
For my personal GitHub profile, I list my activities, affiliations, and the latest updates from some of my projects.
Historically, I have used JasonEtco/rss-to-readme GitHub Action to fetch a few RSS feeds or two and to update my README a few times a day.
Overall, I’m happy with this setup. I used it on the Django News GitHub Organization to pull in newsletter issues, jobs, and the latest videos from our various projects. When I tried to install rss-to-readme in our repo, I was getting node12 errors. (Have I mentioned how much I loathe node/npm?).
Instead of forking rss-to-readme and trying to figure out how to upgrade it, I used this as an excuse to “pair program” with Claude. We quickly built out a prototype using Python and the feedparser library.
I would share the chat log, but it’s mostly me trying out a few different ways to invoke it before I settle on the finished approach. See the source code over on GitHub if you are curious: https://github.com/django-news/.github/blob/main/fetch-rss.py
Once I had a working Python script that could fetch an RSS file and modify the README, I decided to run/deploy it using UV to see how minimal I could build out the GitHub Action.
GitHub Action
To run our
fetch-rss.py
script, we have four steps:actions/checkout
Get a git checkout of our project.astral-sh/setup-uv
Setup UV also installs Pythons for us. As a bonus, we enabled UV’s cache support, which will run much faster in the future unless we change something in our fetch-rss.py file.- Run
uv run fetch-rss.py ...
to fetch our RSS feeds and write them to disk.uv run
installs any dependencies and caches them before ourfetch-rss.py
runs. stefanzweifel/git-auto-commit-action
If our README.md file has changed, save our changes and commit them back to git and into our README.
Our
schedule.yml
GitHub Action workflow runs twice daily or whenever we push a new change to our repo. We also setworkflow_dispatch,
which gives us a button to run the script manually.# .github/workflows/schedule.yml name: Update README on: push: branches: - main schedule: # Once a day at 12 AM - cron: 0 12 * * * workflow_dispatch: jobs: update: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v3 with: enable-cache: true cache-dependency-glob: | *.py - name: Fetch our Feeds run: | # Fetch latest Django News Newsletter entries uv run fetch-rss.py \ --section=news \ --readme-path=profile/README.md \ https://django-news.com/issues.rss - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: ":pencil: Updates README"
Results
Overall, I’m pleased with this solution. If I wanted to spend more time on it or re-use this workflow, I might turn it into a GitHub Action workflow so that we can call:
django-news/rss-to-readme
to use in other projects. For now, this is fine.I’m happy with the
astral-sh/setup-uv
anduv run
steps because they save me from having to set up Python and then install our project dependencies as separate steps.I normally shy away from running Python workflows like this in GitHub Actions because they involve a lot of slow steps. This entire workflow takes 16 to 20 seconds to run, which feels fast to me.
-
🎉 Announcing DjangoTV
Friends, I’m launching a half-finished website idea that I have been playing around with for a while. djangotv.com is focused on promoting and searching Django videos to make discovery easier.
I wanted to launch DjangoTV before I left DjangoCon US 2024, so I’m technically announcing it from the airport. Last year, I launched Django News Jobs during the Django sprints because I was annoyed by the state of the various Django job boards.
After a year of hearing people complain about Django and Python YouTube videos not getting enough views, I decided to address the problem by building out a website to help organize and promote them.
DjangoTV is not competing with pyvideo.org. PyVideo is a fantastic resource for the Python community, and one of my goals is to make it easier to get Django content on PyVideo, too.
DjangoTV is incomplete, and I have many ideas to improve it, including backfilling some of our older conferences, adding presenters, and adding some other metadata to make it a useful community resource.
I focused on DjangoCon videos to bootstrap the project, and we’ll slowly expand our archives. I have been extracting good quotes, adding transcriptions, and adding better summaries. Please expect this to change a lot. I even launched the website with DEBUG turned on for a few days before I turned it off.
Your feedback is crucial to us. If you have any ideas or suggestions, please don’t hesitate to share them.
Most importantly, names change, people change, and bodies change. It’s essential to me that we respect each other and handle this with care. If you have a concern or need us to pull a video, please don’t hesitate to reach out; we will take care of it.
-
Django
🧳 DjangoCon US, Black Python Devs Leadership Summit, and Django Girls Durham
I’m heading to Durham, NC, for seven days of DjangoCon US this Friday. This is my 10th year volunteering and the 9th year that DEFNA, the non-profit I co-founded, has run a DjangoCon US event. Here is an overview of the week.
Black Python Devs Leadership Summit (Saturday)
I’m attending and speaking on a discussion panel on Saturday at the Black Python Devs Leadership Summit. Tickets are free, and they will be streaming online in the afternoon. Donations are accepted and appreciated.
Django Girls Durham (Saturday)
Django Girls are hosting a Django workshop and teaching beginners a crash course on building their first website using Django.
DjangoCon US Tutorials (Sunday)
On Sunday morning, I’ll be volunteering and helping out at the tutorials. In the afternoon, we have a tradition of stuffing swag bags, which takes a big group and is a fun way to kick off the conference. You do not need a tutorial ticket or an organizer to help out. Ask at the registration desk, and they can direct you to when and where we are doing this.
Django Social meetup (Sunday)
My company REVSYS is sponsoring a DjangoSocial Raleigh/Durham Pre-DjangoCon Special meetup on Sunday evening before the conference kicks off. The meetup will be great for meeting other attendees the night before the conference.
DjangoCon US Talks (Monday through Wednesday)
The talks are great, but the busiest three days of the conference are also the busiest. There is always a lot going on, from sun up to sun down.
DjangoCon US Sprints (Thursday and Friday)
The sprints are one of my favorite parts of the conference. In past years, I have been so exhausted by the sprints that it’s hard to sit down and focus. It’s one of the best times to discuss Django and the Django ecosystem. If you have a project or want to find a project to help with, the sprints are great for getting your feet wet.
Outro
Tickets are still available if you live near Durham and want to attend. Both events have online and in-person options, so there is no pressure to make last-minute travel plans.
If you live around Durham and want to meet up, please reach out. Let’s see if we can meet for coffee.
-
Django
,Python
,UV
🤠 UV Roundup: Five good articles and a pre-commit tip
I have written quite a bit about UV on my micro blog, and I am happy to see more and more people adopt it. I have stumbled on so many good articles recently that I wanted to share them because every article points out something new or different about why UV works well for them.
If you are new to UV, it’s a new tool written by Astral, the creators of Ruff.
I like UV because it replaces, combines, or complements a bunch of Python tools into one tool and user developer experience without forcing a UV way of doing it. UV effectively solves the question, “Why do I need another Python tool?” to do everyday Python tasks.
Some reason I like UV after using it for months:
- It’s a faster pip and is really, really fast
- It can install and manage Python versions
- It can run and install Python scripts
- It can run single-file Python scripts along with their dependencies
- It can handle project lock files
While some people don’t care about UV being fast, it’s shaved minutes off my CI builds and container rebuilds, which means it has also saved me money and energy resources.
Overall thoughts on UV
Oliver Andrich’s UV — I am (somewhat) sold takes the approach of only using UV to set up a new Python environment. Oliver uses UV to install Python, aliases to call Python, and UV tool install to set up a few global utilities.
Using UV with Django
Anže Pečar’s UV with Django shows how to use UV to set up a new project with Django.
Switching from pyenv to UV
Will Guaraldi Kahn-Greene’s Switching from pyenv to uv was relatable for me because I also use pyenv, but I plan to slowly migrate to using only UV. I’m already halfway there, but I will have pyenv for my legacy projects for years because many aren’t worth porting yet.
Using UV and managing with Ansible
Adam Johnson’s Python: my new uv setup for development taught me to use
uv cache prune
to clean up unused cache entries and shows how he manages his UV setup using Ansible.Some notes on UV
Simon Willison’s Notes on UV is an excellent summary of Oliver’s notes.
A parting UV tip
If you are a pre-commit fan hoping for a version that supports UV, the
pre-commit-uv
project does just that. I started updating my justfile recipes to bakejust lint
to the followinguv run
command, which speeds up running and installing pre-commit significantly.$ uv run --with pre-commit-uv pre-commit run --all-files pre-commit-uv
If you are attending DjangoCon US…
If you are attending DjangoCon US and want to talk UV, Django, Django News, Django Packages, hit me up while you are there.
I’ll be attending, volunteering, organizing, sponsoring, and sprinting around the venue in Durham, NC, for the next week starting this Friday.
We still have online and in-person tickets, but not much longer!
-
Office Hours
📅 Office Hours Fall Update
This Friday, I am hosting Office Hours before I travel to DjangoCon US (organizer) and the Black Python Devs Leadership Summit (speaker) in Durham, NC.
This Friday will be my last session before a two-week break, but I will resume Office Hours again on October 4th.
- Friday, September 13th, 2024, 2:30 pm to 4:30 pm
- Friday, September 20th, 2024 - No office hours
- Friday, September 27th, 2024 - No office hours
- Friday, October 4th, 2024, 2:30 pm to 4:30 pm
High-level details
ℹ️ Anyone can join office hours. Many join because they work remotely, miss seeing faces, and miss the random conversations when a small group hangs out.
ℹ️ Our office hours are a collaborative space where we can discuss our ongoing projects, catch up, and work together to wrap up our week on a productive note.
🙏 As always, everyone is welcome to join, whether you’re a regular attendee or joining for the first time. If you are curious, reach out.
✅ If you need any additional details, feel free to send me a message or check out the gist from our previous sessions, where you’ll always find the most recent Zoom link ⚠️
-
🛌 On travel tips BYOP aka bring your own pillow
🎒 While some of my friends and colleagues can pack everything they need in a small backpack for a week’s travel, I am not that person.
I turned into the person who brings their pillow when they travel, and it changed my stay and quality of sleep by 1000%.
There are many variables you can’t control when you travel, but the pillow is the one variable I can control, and it has the biggest impact on my overall sleep quality. It’s frustrating to pay $200 or more a night for a nice hotel room and then to have a lousy night of sleep because of a flat pillow.
You can’t control the mattress quality you sleep on, but having a decent pillow takes the edge off for me.
It’s also an excellent excuse to buy a new pillow for your home in case your bag gets damaged, something happens to your pillow, and you need to throw your old pillow away. That also eases the burden so you can throw your travel pillow in the wash as soon as you get back without disrupting your first night back home.
In conclusion, you can bring your own pillow if you struggle with sleep while traveling. It’s a relatively cheap life hack that might require a slightly bigger bag, but it might be worth it for improved sleep quality.
-
Django
🚜 On Evolving Django's `auth.User` model
I need to re-read/re-listen to Carlton’s Evolving Django’s
auth.User
Stack Report before I have a firm opinion, but I saw his Mastodon post and I thought it was worth sharing some initial thoughts.On my first read, I fell into the camp that wants
django-unique-user-email
and full name to be the defaults on Django’s built-in User. I have wanted this forever, and my clients do, too.Django should still allow me to create a custom user, but the documentation could be better. Django’s documentation is a topic for another day, but I’m confused by it and find it less and less helpful. I notice the developers I work with get lost in them, too. Docs may be a good DjangoCon US topic if you want to discuss it in a few weeks.
I would love the default User to have a unique email address, full name, and a short name. Optionally, a username is an email address setting. Please don’t take away the ability to have a custom User model. (Update: Carlton is not making a case for removing a custom User model, but others have made that argument. No, thank you.)
Carlton’s “Action points” conclusion seems reasonable to me.
-
Django
,Python
🚫 Stop scheduling security updates and deprecating major features over holidays
I know people outside the US 🙄 at this, but please stop releasing major security updates and backward incompatible changes over major US, international, and religious holidays.
Given that major security updates are embargoed and scheduled weeks and months in advance, it’s essential to coordinate and avoid conflicts. A simple check of the calendar before scheduling announcements can prevent such issues.
Even if you give everyone two weeks' notice, aka what GitHub just did, wait to schedule them for release over a holiday weekend.
Historically, the Python and Django communities have also been guilty of this, so I’m not just finger-pointing at GitHub. We can all do better here.
Update: 100% unrelated to this: Django security releases issued: 5.1.1, 5.0.9, and 4.2.16. Thank you, Natalia (and Sarah) for scheduling this after the US is back from a major holiday.
-
🌡️ How a $20 Camera Outsmarted My Fancy Thermometer
My ThermoWorks Signals thermometer’s battery was dead, so I connected it to my Anker 737 Power Bank (24,000mAh for the curious) to get me by.
Previously, I mounted a Wyze camera on a tripod and pointed it toward my thermometer because its Bluetooth connection wasn’t strong enough. WiFi worked fine for the camera, but our smoker is in our backyard and has to go through two external walls to reach any of our devices.
This worked well during the early pandemic when I was working from home. I could check the camera from my upstairs office or couch without worrying about the weather. As a bonus, I could see the front panel of my Pitbos Smoker to monitor it in case it ran out of wood pellets or the heat source went out. I could have bought the fancy ThermoWorks Signals thermometer, but a $20 Wyze Camera worked better.
Today, I have the fancy thermometer, and I still should have connected the Wyze cam because the smoker ran out of pellets, which delayed dinner by 45 minutes.
Maybe I will use this as an excuse to explore one of Ollama’s Vision libraries like LLaVA to read photos from the Wyze Camera and the smoker to let me know when something goes wrong.
-
Python
,UV
🚜 Using Claude 3.5 Sonnet to refactor one of Brian Okken's Python projects
Brian Okken posted and published his Top pytest Plugins script and then a follow-up post, Finding the top pytest plugins, which was pretty cool.
I have written a few throw-away scripts, which William Vincent wrote about and updated a few times in the Top 10 Django Third-Party Packages (2024) and The 10 Most-Used Django Packages (2024).
These efforts are powered by Hugo van Kemenade’s excellent Top PyPI Packages.
This inspired me to fork Brian’s top-pytest-plugins project, which I updated to support passing in other package names like “django” to get a rough estimate of monthly package downloads.
The refactored project is jefftriplett/top-python-packages.
Please note: Looking at the package name doesn’t scale as well for projects that have their own Trove classifiers. For a project like pytest, it works well. Many of the top packages may not even have Django in their name for a project like Django. Some projects may even actively discourage a project from using their project in their package’s name for trademark reasons. So, YMMV applies here.
Prompts
I added
uv run
support, which I have written about a lot lately.I also copied the
top_pytest.py
file into a Claude 3.5 Sonnet session, and I let it handle the whole refactor. It even handled adding the PEP 723 new package dependencies without me asking it to.In case it’s useful to anyone, here are my prompts:
## Prompt: Please update this script to use a rich table. ## Prompt: Please update the table styles to be ascii so I can copy and paste it into a markdown doc ## Prompt: Please remove the description column ## Prompt: Please change all PyTest and pytest references to Django and django ## Prompt: Please add back `if 'django' in project.lower() and 'django' != project.lower():` ## Prompt: please remove the \*# Export to markdown section. I can just pipe the output \* ## Prompt: Please add the typer library. ## Prompt: Please remove days and limit ## Prompt: Please refactor the script to allow me to pass the package name instead of django. You can default to django though. This way I can pass pytest or flask or other projects. ## Prompt: Please change the default Table box type to MARKDOWN
Outro
I don’t usually write about Claude or prompts, but the tool has been handy lately.
If you have had some similar successes, let me know. I have been exploring some rabbit holes, and it’s changing the way I approach solving problems.
-
Python
,UV
📓 UV Run Django Notes
I wanted to know how hard it would be to turn one of my django-startproject projects into a
uv run
friendly project. As it turns out, it worked, and the steps were more than reasonable.Before the PEP 723’ing…
I started with a fairly vanilla
manage.py
that Django will give you after runningpython -m manage startproject
."""Django's command-line utility for administrative tasks.""" import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == "__main__": main()
shebang
Then we add
#!/usr/bin/env -S uv run
to the top of ourmanage.py
file.Next, we make our
manage.py
executable and try to run it.$ chmod +x manage.py $ ./manage.py ModuleNotFoundError: No module named 'django'
Our script ran, but Python couldn’t find Django. To tell our script to install Django, we can use
uv add—- script
to add it.$ uv add --script manage.py django Updated `manage.py` $ ./manage.py ... Type 'manage.py help <subcommand>' for help on a specific subcommand. Available subcommands: [django] check compilemessages createcachetable dbshell diffsettings dumpdata flush inspectdb loaddata makemessages makemigrations migrate optimizemigration runserver sendtestemail shell showmigrations sqlflush sqlmigrate sqlsequencereset squashmigrations startapp startproject test testserver Note that only Django core commands are listed as settings are not properly configured (error: No module named 'environs').
Django worked as expected this time, but Python could not find a few third-party libraries I like to include in my projects.
To add these, I passed the other four to
uv add --script
which will add them to the project.$ uv add --script manage.py django-click "environs[django]" psycopg2-binary whitenoise Updated `manage.py` ... $ ./manage.py ...
Our Django app’s
manage.py
works when we run it.After the PEP 723’ing…
After we installed our dependencies in our
manage.py
file, they were added to the top of the file between the///
blocks.#!/usr/bin/env -S uv run # /// script # requires-python = ">=3.10" # dependencies = [ # "django", # "django-click", # "environs[django]", # "psycopg2-binary", # "whitenoise", # ] # /// """Django's command-line utility for administrative tasks.""" import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == "__main__": main()
-
Python
,UV
🐍 Python UV run with shebangs
This UV shebang trick that Simon Willison linked up is a nice pattern, and I plan to rebuild some of my one-off scripts in my dotfiles using it.
Here is a demo that will print “hello python” using the Python Branding colors using the Rich library while letting UV install and manage rich for you.
#!/usr/bin/env -S uv run # /// script # requires-python = ">=3.10" # dependencies = [ # "rich", # ] # /// from rich.console import Console from rich.theme import Theme python_theme = Theme( { "pyyellow": "#ffde57", "pyblue": "#4584b6", } ) console = Console(theme=python_theme) console.print("[pyyellow]hello[/pyyellow] [pyblue]python[/pyblue]", style="on #646464")
Assuming you have UV installed, and you save and
chmod +x
this file ashello-python.py
, then you should be able to run it via./hello-python.py.
I suspect I can more easily bootstrap new machines using this trick without fewer worries about polluting my global system packages.
-
Python
,UV
🐍 UV Updates and PEP 723: Simplifying Python Packaging and Scripting
The uv: Unified Python packaging update brings fresh air to the Python community, with several improvements streamlining the development process. One exciting addition is an early preview of PEP 723, also known as Single-file scripts.
The Single-file scripts feature particularly caught my attention due to its potential to simplify the distribution and execution of small Python projects. Streamlining the process is highly appealing to someone who frequently creates GitHub Gists and shares them privately and publicly.
With this new feature, I can now instruct users to run
uv run main.py
without explaining what avenv
orvirtualenv
is, plus a long list of requirements that need to be passed topip install
.I had the opportunity to test this feature over lunch today. While adding libraries to the script was straightforward, I encountered a few hurdles when I forgot to invoke
uv run
in my virtual environment (venv). This makes sense, given that it’s a new habit, but it highlights the importance of adapting to changes in our development workflow.Overall, the UV: Unified Python packaging update and the introduction of Single-file scripts mark a significant step in simplifying Python development. As developers become more familiar with these improvements, we expect increased adoption and smoother collaboration on small-scale projects.
Bonus Example
I looked through some of my recent visits, and one I recently shared with a few conference organizer friends was a one-off script I used to read several YouTube video JSON files that I’m using to bootstrap another project. It was the first time I used DuckDB to make quick work of reading data from a bunch of JSON files using SQL.
Overall, I was happy with DuckDB and what PEP 723 might bring to the future of Python apps, even if my example only does a little.
# To run this application, use: # uv run demo-duckdb.py # # /// script # requires-python = ">=3.10" # dependencies = [ # "duckdb", # "rich", # "typer", # ] # /// import duckdb import typer from rich import print def main(): result = duckdb.sql("SELECT id,snippet FROM read_json('json/*.json')").fetchall() for row in result: id, snippet = row print("-" * 80) print(f"{id=}") print(f"{snippet['channelTitle']=}") print(f"{snippet['title']=}") print(f"{snippet['publishedAt']=}") print(snippet["description"]) print(snippet["thumbnails"].get("maxres") or snippet.get("standard")) print() if __name__ == "__main__": typer.run(main)
Overall, the future is bright with UV and PEP 723 may bring us. I’m excited to have more one-file Python apps that are easier to share and run with others.
PEP 723 also opens the door to turning a one-file Python script into a runnable Docker image that doesn’t even need Python on the machine or opens the door for Beeware and Briefcase to build standalone apps.
-
Enshittification
🔥 Breaking Up Google
Here are my thoughts on John Gruber’s recent article and notes on the Google Monopoly.
I mean, let’s say Google was forced to spin Chrome off. How would Chrome Inc. make money? Clearly, they’d make money through TAC fee payments from Google search. >Also, if they split off Chrome they’d almost have to split off Android.
Chrome Inc will be quite profitable, making $20 billion a year from Alphabet to set Google Search as the default search engine on Chrome. The same model works for Android Inc, too.
The Justice Department doesn’t exist to figure out Alphabet’s business model nor does it care to. The fact that everything is so tied together that it’s hard to split up doesn’t is only further proof that Google is a monopoly.
If Google is disallowed from making its own web browser how in the world can they make an OS? I mean in theory they could make an OS that only offered third-party browsers but that would mean no system-level webview for apps to embed. Some people laughed at Microsoft’s late-1990s argument that Windows needed a built-in browser but that’s obviously true today. It’s no different than including a TCP/IP networking stack or printer drivers.
The OS which is Linux based can go with Chrome. Google doesn’t need their own OS to work on Mac, iOS, Windows, and other operating system they run their products on.
I don’t know what the remedy ought to be for this case, but I don’t think a breakup is it.
A breakup is better for consumers. Google’s stranglehold on the online ad industry will feel painful after it’s broken up. The only reason it feels hard to break Google into so many new companies is because it’s such a one-sided monopoly. However, that doesn’t justify not breaking them up.
Google has a long history of pushing technology that is only good for Google. Does anyone remember AMP and how Google forced the publishing industry to jump to a platform that only benefited them?
It makes sense to chop Alphabet + Google into dozens of smaller companies. Chrome, Android, Gmail, Docs (maybe Maps), and hardware should stand independently. Search and Ads should each be divided into multiple companies. The goal isn’t to make business sense; it is to divide the company into parts that compete against themselves.
-
Music
🎻 Tiny Desk Concert Wednesday with Sierra Ferrell
🎻 Happy Tiny Desk Concert Wednesday, everyone!
If you are new to Sierra Ferrell, you are in a treat.
If you are already a fan, you’ll understand what I mean and still be in for a treat.
I dislike Google but make exceptions for NPR, Tiny Desk Concert, and Sierra Ferrell.
-
Office Hours
💼 Office Hours this Friday, August 9th
I am hosting Office Hours this Friday, August 9th, 2024, from 2:30 pm to 4:30 pm Central Time.
💼 I plan to upgrade some projects to work with Django 5.1 and possibly Python 3.13 as time permits. I have a few Django Packages tasks to finish too.
ℹ️ Anyone can join office hours.
ℹ️ Our office hours are a collaborative space where we can discuss our ongoing projects, catch up, and work together to wrap up our week on a productive note.
🙏 As always, everyone is welcome to join, whether you’re a regular attendee or joining for the first time.
✅ If you need any additional details, feel free to send me a message or check out the gist from our previous sessions, where you’ll find the Zoom link ⚠️
I look forward to seeing everyone.
-
Django
,Python
⬆️ Which Django and Python versions should I be using today?
Django 5.1 was released, and I was reminded of the article I wrote earlier this year about Choosing the Right Python and Django Versions for Your Projects.
While I encouraged you to wait until the second, third, or even fourth patch release of Django and Python before upgrading, I received a bit of pushback. One interesting perspective claimed that if everyone waits to upgrade, we don’t find critical bugs until the later versions. While that may be plausible, I don’t believe that the dozens of people who read my blog will be swayed by my recommendation to wait for a few patch releases.
I could have emphasized the potential risks of not testing early. Please start testing during the alpha and release candidate phase so that when Django 5.1 is released, your third-party applications will be ready and working on launch day, minimizing the risk of last-minute issues.
Today, I tried to upgrade Django Packages to run on Django 5.1 to see if our test suite would run on Django 5.1, and it very quickly failed in CI due to at least one package not supporting 5.1 yet. Even if it had passed, I’m 90% sure another package would have failed because that’s the nature of running a new major Django or Python release on day one. Even if the third-party package is ready, the packaging ecosystem needs time to catch up.
Which version of Django should I use today?
I’m sticking with Django 5.0 until Django 5.1’s ecosystem has caught up. I plan to update the third-party packages I help maintain to have Django 5.1 support. After a few patch releases of Django 5.1 have come out and the ecosystem has time to catch up, I will try to migrate again.
Which version of Python should I use today?
I’m starting new projects on Python 3.12, with a few legacy projects still being done on Python 3.11. While I am adding Django 5.1 support, I plan to add Python 3.13 support in my testing matrixes to prepare everything for Python 3.13’s release this fall.
Office hours
I plan to spend some of my Office Hours this week working on Django 5.1 and Python 3.13 readiness for projects I maintain. Please join me if you have a project to update or would like some light-hearted banter to end your week.
-
Enshittification
🔍 Google Search speculation 🔥
Eric Holscher posted this post today, and I wanted to share my speculation.
Calling it now:
- Google stops paying Apple & Mozilla for search
- Apple ships search (probably buys DDG or similar)
- Apple pays Mozilla to be default search engine
Google stops paying Apple & Mozilla for search
This judgment means that Google has to give up overpaying to be the default search engine for Apple and Mozilla. It’s the primary basis of the lawsuit, and the judge wrote a 300-page judgment. So, it’s safe to say it will happen even if Alphabet isn’t formally broken up.
Apple ships search (probably buys DDG or similar)
Short term: Because Apple already has an AI deal with Google, I expect Apple’s default search to stay the same despite Google not being able to pay them for that default. Apple will change the options menu, but Google will remain the default.
Long shot/Longer term: Apple buys a few search companies and creates its own search products, as it did with Apple Maps. Search isn’t going to look like Google search does today, or, better yet, it looked like a decade ago before it because of an ad-first search secondary service.
Apple pays Mozilla to be default search engine
I do not see this happening even if Mozilla spends most of its cash buying a search company. Mozilla won’t be able to pay Apple to use it, and they need an incentive to switch. Logistically, Mozilla would cease to exist before this could happen.
Apple doesn’t want to be a search company or incorporate ads like Google and Meta do with their products. Even Apple TV’s ads are mostly for other Apple TV content.
What about Mozilla?
Mozilla will either pivot to try to buy or partner with Kagi, DDG, or Brave (gross, but the most likely). The Mozilla Foundation is facing a potentially extinction-level event, but it has a billion-dollar nest egg to fall back on.
Mozilla has cash, but its options may not resemble the Mozilla Foundation we know today.
-
Enshittification
🧐 Of course, Google is a monopoly
“After having carefully considered and weighed the witness testimony and evidence, the court reaches the following conclusion: Google is a monopolist, and it has acted as one to maintain its monopoly,” the ruling states.
Of course, Google is a monopoly. They have been for over a decade and closer to two decades.
If this quote from The Verge is true, Google’s CEO was a pretty damning witness and admitted that Google intentionally froze the ecosystem in place.
The judge found former Google executive Sridhar Ramaswamy “a particularly compelling witness,” pointing to his answer about why Google would pay billions of dollars in revenue share to maintain default status if it already had the best search engine. Ramaswamy told the court that the payments “basically freeze the ecosystem in place.” www.theverge.com/2024/8/5/…
Thanks to The Verge’s “brilliant” reporting, I can’t source this quote again, but I pulled it before they removed it and shared it across several Slacks and Discord groups.
As far as Alphabet/Google goes, the US Government should break them up and disassemble the company. That outcome may depend on the result of the 2024 election, but both the Department of Justice and the Federal Trade Commission are signaling that they intend to follow through.
I suspect Mozilla has the most to lose over this ruling. Google accounts for a significant portion of Mozilla’s revenue and has historically kept them afloat. However, I suspect the days of Google paying any company to be its default search are numbered.
-
Movies
📺 Kingdom of the Planet of the Apes - It’s a good night to just veg out.
-
📌 Pinboard... what a waste
Earlier this year, I wrote about why I dumped Pinboard after a decade of usage.
Why I gave up on Pinboard
I could write thousands of words about how frustrating being a paid user was, but I’ll sum it up as running Pinboard wasn’t a priority for Pinboard’s founder, and it painfully showed. 👎
This aged well.
I suspect that someday, I will roll out my own commercial Delicious clone for people who just want a reliable bookmark-archiving web service.
A few years ago, I might have said this would be a Pinboard clone, but at least Yahoo knew when to pack it up and shut it down vs. whatever the Pinboard founder has been doing. 🤷
-
Ollama
🦙 Ollama Tool Calling Loose Notes
I spent a few hours this week working with the Ollama project and trying to get tool calling to work with the LangChain library.
Tool calling is a way to expose Python functions to a language model that allows them to be called. This will enable models to perform more complex actions and even call the outside world for more information.
I haven’t used LangChain before, and I found the whole process frustrating. The docs were full of errors. I eventually figured it out, but I was limited to one tool call per prompt, which felt broken.
Earlier today, I was telling a colleague about it, and when we got back from grabbing coffee, I thought I would check the Ollama Discord channel to see if anyone else had figured it out. To my surprise, they added and released Tool support last night, which allowed me to ditch LangChain altogether.
The Ollama project’s tool calling example was just enough to help get me started.
I struggled with the function calling syntax, but after digging a bit deeper, I found this example from OpenAI’s Function calling docs, which matches the format the Ollama project is following. I still don’t fully understand it, but I got more functions working and verified that I can make multiple tool calls within the same prompt.
Meta’s Llama 3.1 model supports tool calling, and the two work quite well together. I am also impressed with Llama 3.1 and the large context window support. I’m running the 8B and 70B models on a Mac Studio, and they feel very close to the commercial APIs I have worked with, but I can run them locally.
Embedding models
Tonight, I tried out Ollama’s Embedding models example, and while I got it working, I still need to put practical data into it to give it a better test
One more tip
If you did not know Ollama can parse and return valid JSON, check out How to get JSON response from Ollama. It made my JSON parsing and responses much more reliable.
-
Office Hours
📅 Office Hours this Friday, July 26th
I am hosting Office Hours this Friday, July 26th, 2024, from 2:30 pm to 4:30 pm Central Time.
I’ll probably be on a bit early depending on much of my client projects I get wrapped up this week.
ℹ️ Anyone can join office hours.
ℹ️ Our office hours are a collaborative space where we can discuss our ongoing projects, catch up, and work together to wrap up our week on a productive note.
💼 I will be working on Django Packages and possibly a new project.
🙏 As always, everyone is welcome to join, whether you’re a regular attendee or joining for the first time.
✅ If you need any additional details, feel free to send me a message or check out the gist from our previous sessions, where you’ll find the Zoom link ⚠️
I look forward to seeing everyone.
-
Ollama
,LLM
🦙 Ollama Llama 3.1 Red Pajama
For a few weeks, I told friends I was excited to see if the new Llama 3.1 release was as good as it was being hyped.
Yesterday, Llama 3.1 was released, and I was impressed that the Ollama project published a release to Homebrew and had the models ready to use.
➜ brew install ollama ➜ ollama serve # (optionally) I run Ollama as a background service ➜ brew services start ollama # This takes a while (defaults to the llama3.1:8b model) ➜ ollama pull llama3.1:latest # (optional) This takes a longer time ➜ ollama pull llama3.1:70b # (optional) This takes so long that I skipped it and ordered a CAT6 cable... # ollama pull llama3.1:405b
To use chat with the model, you use the same
ollama
console command:➜ ollama run llama3.1:latest >>> how much is 2+2? The answer to 2 + 2 is: 4!``` ## Accessing Ollama Llama 3.1 with Python The Ollama project has an [`ollama-python`](https://github.com/ollama/ollama-python) library, which I use to build applications. My demo has a bit of flare because there are a few options, like `--stream,` that improve the quality of life while waiting for Ollama to return results. ```python # hello-llama.py import typer from enum import Enum from ollama import Client from rich import print class Host(str, Enum): local = "http://127.0.0.1:11434" the_office = "http://the-office:11434" class ModelChoices(str, Enum): llama31 = "llama3.1:latest" llama31_70b = "llama3.1:70b" def main( host: Host = Host.local, local: bool = False, model: ModelChoices = ModelChoices.llama31, stream: bool = False, ): if local: host = Host.local client = Client(host=host.value) response = client.chat( model=model.value, messages=[ { "role": "user", "content": \ "Please riff on the 'Llama Llama Red Pajama' book but using AI terms like the 'Ollama' server and the 'Llama 3.1' model." "Instead of using 'Llama Llama', please use 'Ollama Llama 3.1'.", } ], stream=stream, ) if stream: for chunk in response: print(chunk["message"]["content"], end="", flush=True) print() else: print(f"[yellow]{response['message']['content']}[/yellow]") if __name__ == "__main__": typer.run(main)
Some of my family’s favorite books are the late Anna Dewdney’s Llama Llama books. Please buy and support their work. I can’t read Llama 3.1 and Ollama without considering the “Llama Llama Red Pajama” book.
To set up and run this:
# Install a few "nice to have" libraries ➜ pip install ollama rich typer # Run our demo ➜ python hello-llama.py --stream Here's a riff on "Llama Llama Red Pajama" but with an AI twist: **Ollama Llama 3.1, Ollama Llama 3.1** Mama said to Ollama Llama 3.1, "Dinner's done, time for some learning fun!" But Ollama Llama 3.1 didn't wanna play With the data sets and algorithms all day. He wanted to go out and get some rest, And dream of neural nets that were truly blessed. But Mama said, "No way, young Ollama Llama 3.1, You need to train on some more NLP." Ollama Llama 3.1 got so mad and blue He shouted at the cloud, "I don't wanna do this too!" But then he remembered all the things he could see, On the Ollama server, where his models would be. So he plugged in his GPU and gave a happy sigh And trained on some texts, till the morning light shone high. He learned about embeddings and wordplay too, And how to chat with humans, that's what he wanted to do. **The end**
Connecting to Ollama
I have two Macs running Ollama and I use Tailscale to bounce between them from anywhere. When I’m at home upstairs it’s quicker to run a local instance. When I’m on my 2019 MacBook Pro it’s faster to connect to the office.
The only stumbling block I ran into was needing to set a few ENV variables setup so that Ollama is listening on a port that I can proxy to. This was frustrating to figure out, but I hope it saves you some time.
➜ launchctl setenv OLLAMA_HOST 0.0.0.0:11434 ➜ launchctl setenv OLLAMA_ORIGINS http://* # Restart the Ollama server to pick up on the ENV vars ➜ brew services restart ollama
Simon Willison’s LLM tool
I also like using Simon Willison’s LLM tool, which supports a ton of different AI services via third-party plugins. I like the llm-ollama library, which allows us to connect to our local Ollama instance.
When working with Ollama, I start with the Ollama run command, but I have a few bash scripts that might talk to OpenAI or Claude 3.5, and it’s nice to keep my brain in the same tooling space. LLM is useful for mixing and matching remote and local models.
To install and use LLM + llm-ollama + Llama 3.1.
Please note that the Ollama server should already be running as previously outlined.
# Install llm ➜ brew install llm # Install llm-ollama ➜ llm install llm-ollama # List all of models from Ollama ➜ llm ollama list-models # ➜ llm -m llama3.1:latest "how much is 2+2?" The answer to 2 + 2 is: 4
Bonus: Mistral Large 2
While I was working on this post, Mistral AI launched their Large Enough: Mistral Large 2 model today. The Ollama project released support for the model within minutes of its announcement.
The Mistral Large 2 release is noteworthy because it outperforms Lllama 3.1’s 405B parameter model and is under 1/3 of the size. It is also the second GPT-4 class model release in the last two days.
Check out Simon’s post for more details and another LLM plugin for another way to access it.
-
🔄 What to do when your iPad won't turn off or is frozen
As a parent, the few times an iPad freezes are rare but always seem to happen at the worst possible time and place.
Thankfully, Apple has a hard-to-find page called If your iPad won’t turn on or is frozen that is surprisingly hard to find in an emergency. This page also breaks down how to restart each model of iPad, which is great for us because we have multiple generations of tablets.