- Видео 10
- Просмотров 55 630
Hynek Schlawack
Германия
Добавлен 18 сен 2013
I’m an experienced software engineer, prolific conference speaker, and I'm reporting from the frontlines of software development and deployment. That means that my videos take a bit longer, but it also means that you'll get nuanced views from the engineering room instead of regurgitations of news stories or someone else's content.
Come and join me on my journey if you’re interested in Python, DevOps, and software engineering in general!
Come and join me on my journey if you’re interested in Python, DevOps, and software engineering in general!
Master Flaky Systems With Retries in Python 🐍 (avoid self-DDoS)
Every system fails eventually and your Python app is no different. And while failure is inevitable, downtime isn't. One of the key reliability tools in distributed systems are retries - so let's look how they can do more harm than good, and how to retry safely and easily in Python by using the stamina and httpx packages as examples. Both using a decorator and a smart loop-context manager combo!
🔗 Links
► stamina.hynek.me/
► tenacity.readthedocs.io/
► www.structlog.org/
► en.wikipedia.org/wiki/Thundering_herd_problem
► en.wikipedia.org/wiki/Denial-of-service_attack#Distributed_DoS
► www.bbc.com/news/business-64652835
► www.w3.org/Provider/Style/URI
► sre.google/books/
► how.complexsystems.fail
► en.w...
🔗 Links
► stamina.hynek.me/
► tenacity.readthedocs.io/
► www.structlog.org/
► en.wikipedia.org/wiki/Thundering_herd_problem
► en.wikipedia.org/wiki/Denial-of-service_attack#Distributed_DoS
► www.bbc.com/news/business-64652835
► www.w3.org/Provider/Style/URI
► sre.google/books/
► how.complexsystems.fail
► en.w...
Просмотров: 1 188
Видео
uv IS the Future of Python Packaging! 🐍📦
Просмотров 32 тыс.2 месяца назад
It's been six months since I asked whether #uv is the future of #Python packaging: ruclips.net/video/_FdjW47Au30/видео.html With uv 0.3.0, the answer is IN and I'll tell you WHY, and WHAT’s missing to be the PRESENT of Python packaging. 🔗 Links ► Astral’s 0.3.0 announcement: astral.sh/blog/uv-unified-python-packaging ► Documentation for the new projects feature: docs.astral.sh/uv/concepts/proje...
NOX vs TOX - What are they for & how do you choose? 🐍📦
Просмотров 2,8 тыс.7 месяцев назад
If you need to test Python packages or applications across multiple test environments you need tox or Nox. In this video I explain the problems they solve, the differences between them, and how I choose for my projects with over 300 millions of monthly downloads. 🔗 Links ► tox.wiki/ ► nox.thea.codes/ ► ruclips.net/video/_FdjW47Au30/видео.html ► Two Ways to Turbo-Charge tox: hynek.me/articles/tu...
Is UV the FUTURE of Python PACKAGING? 🐍📦
Просмотров 10 тыс.9 месяцев назад
Six months later, the answer is in: ruclips.net/video/8UuW8o4bHbw/видео.html Astral’s uv burst without a warning into the Python scene and made a huge impression! How does it fare in the context of Python's packaging problems… and what ARE those problems in the first place?! 🔗 Links ► Cross-Platform Lockfiles are coming (hopefully): discuss.python.org/t/lock-files-again-but-this-time-w-sdists/4...
Loose Coupling & Dependency Injection the EASY Way! 🐍
Просмотров 3,8 тыс.10 месяцев назад
This is a pragmatic approach to loose coupling and dependency injection with a focus how at they core they’re SIMPLE concepts that improve YOUR life! And: have you heard of dependency LOCATION at all?! We‘ll use simple #Python to demonstrate all that! ► Learn more about my service location package: svcs.hynek.me/ ◀ 🤓 ME ELSEWHERE 🏡: hynek.me/ 🐘: mastodon.social/@hynek/ 🦋: bsky.app/profile/hynek...
svcs: Robust & TESTABLE #Python Web Applications with ANY Framework!
Просмотров 3 тыс.Год назад
This is a quick intro to the svcs package - a flexible service locator for Python! Watch it if you want to improve the handling of your web application's services/dependencies/resources or if you want to learn what any of that means - and whether it's dependency injection! ► Learn more here: svcs.hynek.me/ ◀ ► Want svcs for DJANGO? Check out: github.com/django-svcs/django-svcs ► Love LITESTAR!?...
Hynek this looka awesome i'll definitely use stamina in some projects i was already using Tenacity but just setting retries to 3 but your video convinced me i need a little better tuning! appreciate it and love your videos!
The first time I didn't understand this short, so I retried watching it three times.
Thank you for your dedication! 💛 Maybe try the real video it’s from for extra context. 😇
@@The_Hynek I watched the original movie 9 times, and now everything is clear 🔎😎 (Should have added a :-) in the first message :D)
Oh god I’m an idiot NOW I got it 😅
And I retried 3 times
I hope you guys are being responsible and add appropriate backoffs and jitters!
very good. i have a doubt, can UV work well with django ??pls let me know
There’s no reason for it to not work with Django. Checkout blog.pecar.me/uv-with-django
@@The_Hynek thanks for your reply. i will try it out
Stamina is great! I love that now I'm getting paged 3 times with jittered, exponential backoff. ;D
Just like with food, there's *good* and *bad* paging!!1!
I discovered your channel thanks to the "algorithm" and it’s a bliss. I really liked the video on Nox and tox and I’m looking forward to checking out stamina and structlog.
Welcome aboard! 💛 100k more of you and this channel becomes viable! :D
@@The_Hynek I wish it does!
They have always been responsive in my interactions on GitHub. Charlie seems like a very smart guy. I became an instant user of uv when it took one of my projects' build times from minutes to seconds!
cool library. will probably use
If you're concerned about engagement with the youtube algorithm just do an aesthetic desk setup video where you talk about all the python packages you have installed in ~/.local while slow-panning over the logitech MX master, the CalDigit TS4, an ultrawide monitor and a macbook in clamshell mode in a vertical stand. Bonus points if it's *your* desk, but honestly that's probably not necessary
Or do that distributed retry budgets video. 3 hour runtime easy, super high retention because every way to get it wrong is a cliffhanger
I mean I own some of those things, but I'll need a lot more views to upgrade my TS3 to a TS4 and get a new monitor - like and subscribe everybody!
@@glyph_official i think i'll need to figure out how to switch my LEDs to purple first
This is amazing. I like that Stamina has nicer defaults than Tenacity. The type hints are an added bonus. One question: when you say loops can’t handle exceptions, I was wondering what that means. We can use a try...except in loops, can’t we? Could you please point to a resource that explains why the context manager within the iterator helps here?
YOU can use a try-except but the whole point of stamina (and Tenacity) is that we handle the errors automatically for you. I guess we could do something like `try: whatever() except Exception as e: attempt.handle()` but that's no way better than wrapping it into a context manager.
"I care a lot about automated testing, because I don't trust myself to write correct code, and if I did by accident, I don't trust myself to not break it in the future." - Hynek 2024 Pure poetry, I love it. ^^
the secret is to know one's limits 🧘♂️
thank you, Jason Segel of Python
oof man i wish i had his hair ;)
Good stuff. Usually I write a simple basic retry decorator with all the things you've mentioned instead pip installing another library. Not sure if I'll end up using it, but I'll check it out :)
Heh I’ve done it manually before too; the only thing that can get tricky is proper backoff computation. Fortunately there’s boltons with its drop-in-friendly design: boltons.readthedocs.io/en/latest/iterutils.html#boltons.iterutils.backoff_iter (I.e: no installation needed)
New Hynek video dropped! Love the library, will be trying it out soon!
Great video, thanks !
I still have difficulties understanding if i have to create a venv or not in uv.
uv will do that automatically for you
@ awesome!
Great work Hynek, well presented. Thank you
Thanks. A very helpful video that gave answers to all my questions. I'm going to replace pyenv and pip-tools with uv.
Cool channel. Happy to find it. Looking forward for nw vids
Thank you; you and I both! 😅
Love your style! Instant subscribe. And a great video. uv it is from now on.
can you please comment on uv in systems like nixow
sadly I can't, because I've bounced of NixOS many times. However, I've already heard from Nix friends that they plan on creating something like poetry2nix for uv's - and hopefully eventually Python's official - lock file format.
Coming from conda…wtf is this video about? I have never been more confused than right now
Conda has a very different scope than Python's packaging - it's closer to a Linux distribution than to an ecosystem packaging solution.
I have been a python fan since the python 1.5 days (and my previous language experience was pre-standard javascript and pre-standard C++, so I always found it quite impressive), but as great as I have always found it, it has often been hard to be a python fan. The build tooling and package management in a lot of other languages is so much better.
Which is why it's now time to celebrate! 🥳
Imho writing tooling for language A in language B is a very bad smell. I get that Rust is a shiny object but now whoever is using the tool is unlikely to understand how to debug and fix the tool. Conversely those writing the tool don't need to understand the target language.
does this work with Mojo?
Sorry, I don’t know anything about Mojo beyond that it exists and that it‘s from Chris Lattner.
Fantastic video! I really think you nailed both the technical and human aspects of this sea change in Python packaging. I especially appreciate how you called out all those giant shoulders the Astral folks are standing on. Ruff and uv are amazing tools and they are great partners in helping guide standards to keep interop, multi-culture, and innovation alive.
"It automatically installs..." Uh? How? Where? How do I remove crap that some random uv thing automatically installed? How can I see what has been automatically installed? How does the automatically installed things integrate with proper system packages (say, on a debian-based distro)?
Where: `uv python dir` How to prevent: `UV_PYTHON_DOWNLOADS=never ` How does it integrate: it doesn't, that's the whole point. People have been begging for a decoupling forever. If you don't want that, the the env variable or pass `--no-python-downloads`. I set the variable in all my Docker base images.
There's also configuration files at a project, user and (soon!) system level where you can configure this too.
good stuff ❤
wish there was a comparison done with poetry here
I'm trying my best to follow the rough rule that I don't speak ill of other people's projects which has the unfortunate but inevitable consequence that I'll never speak about Poetry.
Pip is not replacaeable by uv pip. Order matters with uv pip. Pip probably does but I never managed to recreate it. With uv pip order matters albeit with a clear way how.
so is uv is fully same as python pip, i have a problem to manage uv in offline machine pls help me anyone
If you need concrete help, I recommend dropping by Astral's Discord; people there tend to be very helpful discord.com/invite/c9MhzV8aU5
So happy I found this channel (first video) I’d say I’m intermediate level so I definitely want to dig through your videos. Thank you!
thank you, thank you, thank you! 😊
The only real issue I've had with uv is that "uv tool"/uvx has a slightly awkward interface compared to pipx. Otherwise, it's been a fantastic improvement over everything that's come before, and I'll be very happy when rye's functionality is fully integrated into it.
I still occasionally do `uvx run CMD` 😬 Supplanting Rye is a major goal, so only a matter of time.
Boy, I sure hope IndyGreg's github account is never compromised, or he get libxz'd into accepting a PR he shouldn't... I'm amazed you didn't also show the infamous "there are now N+1 standards" XKCD as well. Because, yeah, I've never needed more than pip+virtualenv, sometimes a python manager like tox when needing a lot of python versions. I swear devs don't do an hour of research before diving into solving a problem that's already been solved, repeatedly.
Love this content Hynek, funny and informative, and your email newsletter is awesome too :)
So happy not to use attrs, you can't imagine! Just kidding =) The video has a great pitch, always like the videos despite me not having any idea of how packaging works. I simply use it and it rarely shoots me in the foot. Liked the experience of rye, if uv creates even better tool - I would happily use it in new projects
1:54 I gotta say, as a Java developer who only dabbles in python every once in a while, the whole deal with packaging, virtual environments, wheels and so on, has deeply confused me to no end, but after checking out your previous video all the unanswered questions I had in the back of my head have been resolved. Honestly surprised such a well-informed person with entertaining videos like yours has fallen under my radar till now! Instant new sub, hope you keep making videos explaining all these historical aspects about the Python ecosystem in such a concise manner
I'm very glad to hear it did its purpose! The first video should probably have been two, but I suspect the uv angle lured more people in than if it were just about the packaging part. :)
name of the vid, i hav exact same need
Just stumbled over your channel. Keep up the original style. There is charisma. The charisma of a software craftsman that knows his shit and has passion for it. That's the kind of person I love working with. Liked and subscribed :)
Thank you for finding and appreciating my backcatalog! That video specifically is very dear to my heart. :)
Great video as always! really happy about uv progress recent time, hope we will finally have at least somewhat standard for basic package management needs 😅 Also I really would like to see a video or a blogpost why to write python applications as a packages!
now remove that old video
So would astral's uv be an alternative to pip... or more like an alternative to nuitka?
Nuitka is a Python to C++ compiler, that's something different entirely. uv is only about packaging Python code and an alternative to Pip (since last video) and/or PDM/Poetry/Rye (since this video).
I love it - keep being awesome Hynek.
thank you Michael - always great to hear from you! 💜
Man you have such a good banter, it's fun watching your content and hope to see more of you on here :)
Thank you! And you and I both hope the same thing ;)
13:14 have you checked pixi yet?
Love this video i subbed and enjoy your technical videos! i would love a workflow video about how you build an application with UV and how you use UVX with it. Or this could be a blog post whatever you prefer! keep it up!!
Thank you! 💛 `uv tools` and `uvx` are tools that you don't use with your own project (that would be `uv run`). They are the replacement for `pipx`: so if you have Python tools that you want to use outside of projects, it manages virtualenvs (and Python versions) for you. For example `uvx --from httpie http httpbin.org/json` or `uv tool install --with tox-uv tox` (and then you can run `tox` in your shell whereever you are).
@@The_Hynek would love migration video .. i think this fit with most people as a challenging usage while uv init to start a new project is the easiest to do
The problem with migration videos is "migrate from WHAT?" - one of the problems uv is solving is that currently there's virtually an infinite amount of workflows.
Hi Hynek, good video. Can you make a detailed video of what it does that env+pip+weel+bash doesn't? Because other than the performance improvement, I don't see any other improvement over the default tools. Even the lacking stuff on uv can be done with what we already have. For example, to install development dependencies you just create a dev_requirement.txt and run pip install -r dev_requirements. What am I missing?
Until 0.3.0, it was all speed (see my older video - there's a lot more context). Now, most of what uv adds is comfort and misuse safety. As I say in the video: you can give a project to a total newb and they can run `uv run pytest` and uv takes care of EVERYTHING. They can git pull some updates that update dependencies and `uv run` again, and uv will make sure all updates are applied. This eliminates a lot of problems that plagued teams before. Finally, to borrow my own words: the cross platform lock file is the crown jewel of post-0.3.0 uv. It's a HUGE deal if you need to develop across architectures like I do (ARM vs Intel) or across operating systems (macOS vs Linux vs Windows). This works for .txt lock files only when the dependencies are exactly the same, which they often aren't. For this you used to have to use PDM and Poetry that come with their own sets of problems.
@@The_Hynek thanks!!!
@@The_Hynek so does uv run do uv sync first then actually run?
For all intents and purposes, yes. If you always use `uv run`, any changes to uv.lock (e.g., a git pull) are applied automatically
@@The_Hynek that's nice. I didn't realize that it joins a lot of tools together into a single one, included automatic git pulls and so on. It greatly simplifies the workflow.
A binary blob that never breaks? Uhm, yeah that just doesn't exist. Never has, never will.
We have to see things in relation to the reality that we live in. Yes, there’s the heat end of universe. And yes, Go programs compiled on Jammy don’t work on Focal. But relative to the CURRENT jankiness of existing tools, it‘s IMHO fair to use the mild hyperbole of "never".
uv being written in Rust isn't even a problem (as long as it works). Is nodejs written in javascript? No, it isn't. Bam, it's called precedence.
There is a bit of history to this angst in the Python community: large parts used to be written in C and we worked for many years to port them to Python, if possible. Making it more approachable and maintainable. That’s how the Mastodon thread starts, in fact. Starting to add Rust is a step back in that sense, but IMO that isn’t really comparable. But it certainly does feel so for some.