Latest / Talk Python To Me / #540: Modern Python monorepo with uv and prek
Transcript
- 0:00Monorepos. You've heard the talks, you've read the blog posts, maybe you've seen a few glimpses into how Google or Meta organized their massive code bases, but it's often in the abstract and behind closed doors.
- 0:11What if you could crack open a real production monorepo, one with over a million lines of Python code and over a hundred sub-packages, and actually see what's being built step-by-step using modern tools and standards?
- 0:24Well, that's exactly what Apache Airflow gives us. On this episode, I sit down with Jarek Potiuk and Amogh Desai, two of Airflow's top contributors, to go inside one of the largest open-source Python monorepos in the world and learn how they manage it with uv, pyproject.toml, and the latest packaging standards, so you can apply the same patterns to your own projects.
- 0:47This is Talk Python To Me, episode 540, recorded February 10th, 2026.
- 0:52Welcome to Talk Python To Me, the number one Python podcast for developers and data scientists.
- 1:14This is your host, Michael Kennedy. I'm a PSF fellow who's been coding for over 25 years. Let's connect on social media.
- 1:21You'll find me and Talk Python on Mastodon, Bluesky, and X. The social links are all in your show notes.
- 1:28You can find over 10 years of past episodes at talkpython.fm, and if you want to be part of the show, you can join our recording live streams.
- 1:35That's right, we live stream the raw, uncut version of each episode on YouTube.
- 1:40Just visit talkpython.fm/youtube to see the schedule of upcoming events.
- 1:44Be sure to subscribe there and press the bell so you'll get notified anytime we're recording.
- 1:48This episode is brought to you by our Agentic AI Programming for Python course.
- 1:53Learn to work with AI that actually understands your code base and build real features.
- 1:58Visit talkpython.fm/Agentic-AI.
- 2:02Hello, hello, Jarek, Amogh. Welcome to Talk Python To Me.
- 2:06Awesome to have Amogh, you here, and Jarek, you back.
- 2:09Very nice to be again at Talk Python To Me. It's one of my favorite podcasts I listen to all the time.
- 2:15Thank you, thank you.
- 2:15It's my first, but yeah, thanks for having me, Mike.
- 2:18Happy to have you here.
- 2:19You and a team of people, given the scale of this project, have built an amazing, amazing product with Apache Airflow.
- 2:26It's going to be really fun to dive into it, and specifically, we're going to focus on not building workflows exactly,
- 2:33although I'm sure we'll talk about that somewhat.
- 2:35The real goal, the thing that we're going to focus on, is how do you manage such a big project
- 2:40with so many different internal packages that all depend upon each other and so on,
- 2:45and monorepos, and that.
- 2:47I've touched on monorepos before, but two things.
- 2:50I think this makes a really interesting discussion for listeners out there.
- 2:53One, this is going to be very concrete with exact steps, and it's even open source.
- 2:58You can go check it out and play with it.
- 3:00And two, the tooling and the standards have changed significantly since I talked about this three or four years ago,
- 3:06making much of what we're going to talk about possible, right?
- 3:09Absolutely.
- 3:09Yeah.
- 3:10Now, before we dive into that, of course, let's do quick introductions.
- 3:15Jarek, it's been a while since you've been on the show.
- 3:16Who are you?
- 3:17Tell people who you are.
- 3:18I'm an Apache Airflow maintainer, one of the PMC members as well,
- 3:22and also one of the Apache Software Foundation members.
- 3:26I've got this nice, thin new logo of Apache Software Foundation that we got at FOSDEM.
- 3:30I'm also an Apache Airflow security committee member,
- 3:35which is an important aspect for what we are discussing today
- 3:38because of supply chain and dependencies and lots of security,
- 3:44potential security issues these dependencies bring.
- 3:48One of the few lucky people to contribute to open source full-time and get paid for it,
- 3:53which is amazing.
- 3:54Maybe another podcast one day about that, because I think that's also an interesting one.
- 3:59Yeah, I have something like that, a topic somewhat like that brewing.
- 4:02So, yeah, potentially to have you back for that.
- 4:04Hey, I'm Amogh Desai.
- 4:05Again, similar to Jarek, I'm a PMC member and a computer at Apache Airflow.
- 4:10And I'm also part of, I'm one of the top 10 contributors to the project,
- 4:15top 10 all-time contributors to the project, Jarek being number one.
- 4:18So I work at Astronomer as a senior software engineer,
- 4:21where I get to live in both worlds.
- 4:24One is contributing to Airflow's code development
- 4:27and also supporting the companies that are trying to run Airflow at scale.
- 4:31Awesome. What is Astronomer? Tell people about that.
- 4:33It's a company where most of our, we're a company which is almost one of the leading contributors
- 4:39to Apache Airflow and also the leading consumer of it.
- 4:42We supply and we provide a managed distribution of,
- 4:45corporate managed distribution of Apache Airflow inside Astro.
- 4:49And yeah, I think we have a data platform as well to try and make your lives easier to use Airflow at scale.
- 4:56And let me ask to it, two comments.
- 4:59So Airflow has a number of stakeholders and commercial stakeholders
- 5:03who are hosting Airflow as a service as well.
- 5:06And, you know, like using Airflow, we have contributions from all over the place.
- 5:10Astronomer by far, like the biggest number of contributions
- 5:13and fantastic open source stakeholder.
- 5:15We like very much focused on making Apache Airflow,
- 5:18like truly vendor neutral Apache project.
- 5:21Like I'm always amazed how well this works.
- 5:25And the second thing, the number one, I'm cheating a bit.
- 5:27Like, you know, I do a lot of small PRs.
- 5:29This is how you get the number one.
- 5:30I guess it depends how you measure it, huh?
- 5:32You know, you could always just do one ginormous AI PR
- 5:36that's like a hundred thousand lines of code in your PR
- 5:39and people would love you for it.
- 5:40And you'd be a mega contributor.
- 5:42Oh, yeah.
- 5:43Well, not.
- 5:44He does both.
- 5:45The funny part is Jarek does both.
- 5:47His velocity amazes me or, I don't know, shocks me sometimes.
- 5:50He does massive PRs and also like a lot of tiny ones.
- 5:54And by the time I'm looking, there are like three more out of it.
- 5:56I don't know how he does it.
- 5:57We're going to get to a bit of how much traffic there is on Airflow
- 6:01in terms of like open source activity.
- 6:04It's some, it's a little bit.
- 6:05Before we move on though, Jarek, what is the Apache Software Foundation?
- 6:09What is this Apache thing that you're talking about?
- 6:12And why is Airflow part of it?
- 6:13Very quickly.
- 6:14It's a foundation.
- 6:15One of the oldest foundations, open source foundation in the world.
- 6:1825, 26, seven years now.
- 6:20I think the main thing about Apache Software Foundation is that it's individual driven.
- 6:24So every member is an individual, not a corporate, as opposed to like Linux Software Foundation,
- 6:29where members are corporates.
- 6:30And people make decisions in both foundation and projects or PMCs, so-called project management committees.
- 6:39And Airflow is one of the PMCs.
- 6:41So one of the project management committees, which has PMC members.
- 6:45We are both PMC members and we have like 50 other individuals or 60.
- 6:50I can't remember like the number of changes.
- 6:52Like we are inviting new ones all the time.
- 6:54We make decisions as humans, as individuals, not the corporates who are employing us, for example,
- 6:59because it's a meritocracy-based system where people have merit and the merit doesn't expire
- 7:07and the merit doesn't belong to individuals, not to the corporates.
- 7:11That's one of the big, like pretty much all the open source software out there, like has some Apache Foundation
- 7:18or Apache Complement in it.
- 7:20It started with Apache Server 20, 30 years ago almost.
- 7:24But now we have more than 200 PMCs.
- 7:27We just passed 10,000 committers mark two months ago, I think.
- 7:32So like lots of individuals, lots of people contributing to the foundation.
- 7:36And the main thing about foundation is community over code.
- 7:39So we value building communities more than actually producing code.
- 7:42We believe producing code is just byproduct of great communities working together.
- 7:48And ASF is a charity, is a public good charity in the US registered in Delaware.
- 7:53So we actually cannot be sold.
- 7:55We cannot change our license.
- 7:56Nothing like that can happen because of the status of foundation.
- 7:59And a really positive force for open source, right?
- 8:01Oh, absolutely.
- 8:02Absolutely.
- 8:02When I first got into like learning how ASF works, I said like that it has no chance to work.
- 8:08Like there is no way it works.
- 8:10It's too idealistic.
- 8:11There's no way.
- 8:12Absolutely.
- 8:12And nobody in the foundation who makes decisions gets any money.
- 8:16So like everyone is a volunteer.
- 8:18All the PMC members, all the committers, all the board members, all president, all the VVPs,
- 8:23those are all volunteer driven roles.
- 8:26And those are the people who make decisions.
- 8:28We just pay a few people in infrastructure and security.
- 8:31That's basically it.
- 8:31Let's start by just talking about high level abstract.
- 8:35What is a monorepo?
- 8:36I think it's so easy to make that sound like the same thing as a monolith.
- 8:42You're like, oh yeah, monorepo, monolith, same thing, right?
- 8:44And yet you're shaking your head.
- 8:46The first time I met personally a monorepo, maybe I can continue with that, but that was
- 8:50like at Google.
- 8:51I worked at Google years ago and I was surprised coming to Google that all the code there is
- 8:57in a single monorepo.
- 8:59Even though like we have like hundreds of products and all the stuff you see.
- 9:03It's got to be a lot of code, right?
- 9:05Like a giant, giant repo.
- 9:07Like now they have like maybe four.
- 9:09I don't know.
- 9:10Like I've heard some stories.
- 9:11I don't work there for a long time now.
- 9:13But that for me, that was a sign that like you don't really have to split and dice and
- 9:17slice your repositories into many, many small ones.
- 9:21Even if you have like non-monolithical product, it all can be kept in a single source, single
- 9:27repository, separate source trees maybe, separate like we'll talk about how we do it in
- 9:32Airflow.
- 9:33But it's a way how you can bind it together and have it tested together and have it developed
- 9:38together.
- 9:39Even though each piece is pretty much separate and you can work on them separately.
- 9:44That's the monorepo.
- 9:45As opposed to multirepo, which is like when you have multiple repositories consisting of
- 9:49whatever comes up as a product.
- 9:51Yeah.
- 9:52Everything that Jarek said plus just a small addition, which is each of the component or
- 9:57the tiny bit of a monorepo can have its own build artifacts, its dependencies.
- 10:03It can also have its own release cycle or a release vehicle.
- 10:06That's the only addition, but everything is put together as a big puzzle just to keep the
- 10:10puzzle together.
- 10:11You know, not every monorepo is Python, but in Python terms, it could have its own pyproject.toml,
- 10:16potentially its own virtual environment.
- 10:18The nomenclature ironies of this is often the monorepo, I think, makes more sense when
- 10:24you are working with lots of small parts, right?
- 10:27Where the monolith, maybe it has a couple of things, but it doesn't depend real deeply.
- 10:31The more interconnections you have and the harder it is to manage those versions, the more something
- 10:36like this makes sense, right?
- 10:38People really make a connection between isolated work on part of the system into having to have
- 10:45separate repository for that, which is completely not the case.
- 10:48Like you can actually have an isolated sub part of the repository, even if it's Git.
- 10:53Git doesn't have like, you have some modules and sub repos and all that stuff.
- 10:56But even like in a single Git repository, you can easily have like start working and focusing
- 11:01on a small part of the whole monorepo and only care about that.
- 11:06That's what the monorepo is.
- 11:09I'm going to go ahead and put it out there.
- 11:10I'm not a big fan of microservice architectures.
- 11:13I kind of find it's trading code complexity for DevOps and deployment complexity.
- 11:20And I think we have better tools to manage code complexity than DevOps complexity.
- 11:24But something like this does help you manage those kinds of deployments as well better, right?
- 11:30I use the term mini-series, not microservices.
- 11:33Microservices is just too much.
- 11:35But then you can have a lot of mini-series, a number of mini-services, but not micro.
- 11:39Like micro was just too much of a mainstream.
- 11:42I can get on board with that.
- 11:43Amak, what do you think?
- 11:44I like that as well, mini-services.
- 11:46Maybe you should coin that too.
- 11:47It's the microservices that are too small.
- 11:49It feels to me like the equivalent of when you're trying to write unit tests and you're
- 11:53like, oh, what if I get a customer and I set their first name?
- 11:57And then I check that their first name is set.
- 11:58Like, what are you doing?
- 11:59You don't need to check that assignment works.
- 12:00This is too, you're just too much in the weeds.
- 12:03You know what I mean?
- 12:03This is what AI agents do now all the time.
- 12:06Like, no.
- 12:08Yeah, think of the code coverage.
- 12:09Just think of the code coverage.
- 12:10Come on.
- 12:10You've got some goals to hit.
- 12:12You said 80% code coverage.
- 12:13It's on top of it.
- 12:14Yeah.
- 12:15That sets the stage.
- 12:16Let's talk a little bit about specifically how Apache Airflow has come to need this, basically.
- 12:23Right?
- 12:23Like, you shared with me the pulse, the GitHub pulse for Apache Airflow.
- 12:27And it's kind of worth looking at just how much open source interest and traffic there
- 12:33is.
- 12:33Who wants to kind of summarize this weekly pulse here?
- 12:37This is not the best week in terms of the number of comments.
- 12:40We have had even more red, but in the week of...
- 12:43Wow.
- 12:43Just one of those weeks.
- 12:45Yeah.
- 12:46One of the usual weeks.
- 12:47Between Feb 3 and Feb 10, we have had about 310 active pull requests.
- 12:53So, you can imagine that's about 40 plus pull requests a day.
- 12:57A lot of them are being assisted by the AI revolution going on, but that's a lot of pull requests.
- 13:04And we have merged about 200 of them.
- 13:06About 100 are open.
- 13:08And similarly with issues, right?
- 13:1035 new issues.
- 13:11Five issues per day.
- 13:12That's a lot of traffic.
- 13:13So, you can imagine the amount of review pressure each of the maintainers has here.
- 13:19There's 300 pull requests spread across, I don't know, 120, 130, maybe 140 distributions.
- 13:26And each of the distributions having like a swim lane owner who is actively trying to take a look at these pull requests.
- 13:33So, it's just another week to be very honest.
- 13:36It's more than 25 PRs a day, including weekends.
- 13:39How many of these people are high value?
- 13:40How many of these PRs are high value?
- 13:43I guess I'm trying to get the sense of like, how much does this get accepted?
- 13:46Are these just people throwing stuff out there that doesn't make sense for the direction of airflow?
- 13:50Well, those merged all make sense because they are reviewed and merged by airflow maintainers.
- 13:55And we are very serious about that.
- 13:56So, like we don't merge anything that doesn't pass our bar, which is like very high and extremely high.
- 14:01Like we have 170 track hooks which are checking if the PR is doing what we, if the code is doing what it was supposed to be doing and if it's architected properly.
- 14:11And on top of that, we have individuals, people like, like among myself and maybe 50 other PMC members and committees who are reviewing it and making their comments and know the system enough to direct people.
- 14:25So, they may make sense.
- 14:26We do have recently, and that was a recurring them at the FOSDEM conference last week when I was there about like AI generated contributions.
- 14:34And many of the AI generated contributions are not the best quality.
- 14:38It's not like AI is bad quality.
- 14:41Many of those are easier to produce and they might have bad quality.
- 14:45So, we are now learning how to filter them out and how to make the, to handle them quickly.
- 14:50But those are the actual high value PRs that we merged.
- 14:53In terms of numbers, if you, if I may, the, it would be maybe a third of the open pull requests that are nice general trend.
- 15:01That's pretty good, honestly.
- 15:02Yep.
- 15:03We have some guidelines published very recently.
- 15:05And due to that, we have seen a dip in such, such quality of PRs.
- 15:09We published some guidelines in our contribution guides about what will be the action taken if, you know, bad quality PRs are raised or non or PRs are raised where the author does not know the context, but the AI does.
- 15:22I don't want to go down this rat hole.
- 15:24People hear this enough lately, but I just, it's been in the news lately.
- 15:27Open source projects have been kind of getting a barrage of AI submissions.
- 15:32And I think that comes in a couple of flavors.
- 15:35One, people who just want to get their name listed as a contributor, maybe it helps them with their job or whatever.
- 15:40So there's like a small incentive there, but it's been really bad for bug bounties.
- 15:45Like curl closed its bug bounty program because people were trying to make the 50 or $250 by finding some issue with AI.
- 15:52Is that a problem for you all just taking the pulse of a big project like that?
- 15:56It is.
- 15:57I actually had a talk about that at the Global Vulnerability Intelligence Platform Summit just before Fosden.
- 16:03So that was exactly like, I even quoted Daniel Stenberg and I met him there at FOSDEM, which like, that was really cool.
- 16:09There are some different motivations of people who are submitting those those AI issues and we should fight with the in different ways with different approaches or like, you know, the respond to those motivations.
- 16:21Somehow we have some ideas.
- 16:22We have an open discussion in GitHub maintainers list right now.
- 16:27And GitHub is trying to address it by like just discussing what they can do right now.
- 16:32And that's the highest priority for them.
- 16:34We have a discussion with OSSF for security kind of guidelines or policies for open source maintainers, how to deal with those issues.
- 16:42And I'm sure we will work out some ways and toolings and most of all processes and like being assertive is one thing, like just saying no when the report doesn't meet all the bars immediately.
- 16:53And, you know, directing people to the description is good enough of a, you know, barrier for, you know, getting kind of completely broken PRs because we have to just make it more expensive for the reporters than for the maintainers to diagnose the issues or decide if the issues are bad or good.
- 17:11And I'm not necessarily saying that there's something inherently bad because AI wrote some of the code than a person.
- 17:17AI can write really good code better than a lot of people I've seen.
- 17:20But it has this sort of shotgun effect often of just like, I'm going to change all these files and it's not as focused and clear.
- 17:28A lot of times it just it doesn't it doesn't get the Zen of it.
- 17:31You know, Amogh, what do you think?
- 17:33It'll generate code, which it thinks is good, but we don't really know the ripple effect and we want to avoid such things.
- 17:40Such a long living app with lots of complexity. Right.
- 17:44And we all are using the AI for generating the code, to be honest, like so like most of my code.
- 17:50You should. Yeah, it's incredible. It's it's I pulled up this graphic here and I'll link to it in the show notes.
- 17:56I just given people a sense, I got this little utility that I released this week called Tallymon, which like analyzes code and gives you sort of a more of a breakdown than just like this many lines or whatever.
- 18:07So I want to just highlight maybe you all like can riff on this a little bit to give a sense.
- 18:12So 100 or 1.2 million lines of Python, 918,000 excluding comments, maybe a little over counting the way this thing works, but still 200,000 restructured texts.
- 18:23The one that really stood out to me, 81,000 lines of YAML and 16,000 lines of TOML.
- 18:28You guys, that's impressive. And you know what?
- 18:32Hat tip to just a just a sprinkle, just a hint of Java at 42 lines of Java.
- 18:38But, you know, almost a million, just over a million lines of code without comments.
- 18:43That's a big project. What do you think?
- 18:45What happened when you joined?
- 18:47I don't know. I think it was much less.
- 18:50You did contribute a lot.
- 18:51You can imagine so because of the number of packages we haven't read the monorepo discussion from earlier.
- 18:56We have a lot of packages and the YAML might surprise you at first.
- 19:00But if you actually go and see why the YAML, it's mostly for our providers.
- 19:05So integration with other systems is something we call as providers.
- 19:08And the spec of the providers is written in YAML.
- 19:11And TOML, sure, will come to it very, very, very soon.
- 19:14That's kind of why I pulled this up, actually, is the TOML aspect is quite interesting, which leave us with that number as we move on.
- 19:2316,000 lines of TOML. That's a lot of pyproject.TOML going on right there, folks.
- 19:28Oh, yes. And lots of it is generated, actually.
- 19:31So like, because we actually generate quite a lot of the YAML and TOML that we have and keep it in the repo.
- 19:37So we don't want to regenerate every time.
- 19:39So like, we don't write YAML by hand.
- 19:43Maybe we can start by introducing this by just giving a shout out to this series that you wrote over here on Medium.
- 19:50Jarek, modern Python repo for Apache Airflow, parts one through four.
- 19:55Yes, I initially started discussing this blog post idea with a few people.
- 20:00Like, you know, like people are busy and I couldn't get people like to write it.
- 20:04So I decided to write it myself.
- 20:06Well, with a lot of AI help, of course.
- 20:09It's not that everything is written by hand.
- 20:11And when I wrote it, I realized it's like too big and I had to split it into four.
- 20:17But the idea was like to document what we've done because because I think that a lot of people are struggling with like monorepo versus multirepo or like how they should do their repository in when they are the project grows.
- 20:29And there were lots of discussions in the past, including here, one of the, you know, one of the podcasts of yours were monorepo versus multirepo.
- 20:37And I can't remember who that was, but there was discussion about like going back and forth and like finding that people sometimes go back and then then go forth and like in different directions because there are different problems or approaches.
- 20:50So I just wanted to document the reasoning why we are doing it, like why it's possible now because of the packaging ecosystem maturing for Python and uv and other tools coming into the space.
- 21:03And then the last part was like really the kind of a little bit innovative approach that we do where the tooling is still not catching up with what we need and what we, what we, what we did.
- 21:12So those are the kind of history why we are doing it.
- 21:16The, you know, the packaging, the automated verification with prek.
- 21:22So that was the third part.
- 21:23And the fourth part was about like the, this chart, libraries, innovation, innovative concept, but we added for, for, for.
- 21:29I'll link to the series as well as to a talk that you gave at FOSDEM that just got published, right?
- 21:34Yes.
- 21:35Yes.
- 21:36And, they are, they have amazing system of recording and publishing stuff.
- 21:40Like, like for the volunteer driven conference, thousand speakers.
- 21:44Oh, that was, that's amazing.
- 21:45That works.
- 21:46Like probably some automation going on there.
- 21:48Let's talk a little bit about, I guess the problems that you ran into because initially there were some challenges with the standards and tooling not be there.
- 21:56And you actually, one of the takeaways, if people read the series or watch the talk is you actually had to work with some of the tool providers to make this possible.
- 22:05So not only is it like, well, the tools have changed what we could do this.
- 22:09It's you all have changed the tools a little bit through, you know, working closely, like, Hey, we've got this 1 million line project with a hundred dollars.
- 22:17So not only is it a hundred sub modules or more help.
- 22:20Like it's just your tools to support this.
- 22:22Help me make this work.
- 22:23Right.
- 22:24What were some of the problems?
- 22:25Let me start with this cooperation and maybe, you know, Amogh can also explain like what was before and after, because like he experienced that firsthand as a, as a user kind of this kind of repository structure.
- 22:34But for me, the idea was like, I was working on it for years.
- 22:39Like when we went to airflow to five years ago, we, or four years ago, I can't remember.
- 22:44That's a long time.
- 22:45And we didn't have all the tooling and we had to do pretty much everything that we do now with the, with monorepine uv by hand, by bash scripts by that time.
- 22:55By that time, by that time, crazy.
- 22:57So like, if you run it three years ago, the, the, your code, you would see more than 10,000 lines of bash code, which I wrote.
- 23:04But we, we since removed.
- 23:05We since removed.
- 23:06That is not joyful.
- 23:07That doesn't spark joy.
- 23:08That's why we removed it with some outreach internship actually.
- 23:11And shout out to edit and, and Borna who were our outreach mentors who helped us to convert it to, to Python, which was really helpful.
- 23:19That's how it started.
- 23:20No tooling need because we grew, we wanted to have more providers, more integrations, and it already was quite difficult to manage if they are well part of single distribution.
- 23:30So we have to split into many distributions, 60, I think at the beginning.
- 23:34Now we have more than hundreds.
- 23:36Now, when we did that, I, we had to do all manually and like working with that was like really cumbersome.
- 23:43Maybe, you know, like I can switch to, to Amogh.
- 23:45So he can say like the past experience and new experience because like he experienced the change himself.
- 23:50Yeah.
- 23:51The, the past experience was scary to be, to speak the least.
- 23:55Whenever I, switch branches or have to rebase for whatever reason, I had a nightmare, a very bad time trying to, you know, package things together and try to run something.
- 24:05And I think Jarek found me often, you know, ranting on the Slack channels that, Hey, this doesn't work.
- 24:09Hey, that doesn't work.
- 24:10What do we do?
- 24:11Now it's, it's very easy.
- 24:13It's, it's effortless, almost effortless compared to what we had years, maybe like five years ago, four years ago.
- 24:19Yeah. Amazing.
- 24:20How does GitHub deal?
- 24:21I was the only one who actually managed the whole thing for years.
- 24:24And I was like overwhelmed as well when people have problems, of course.
- 24:27So then the change that we've done was not only with the tooling.
- 24:31And as you mentioned, we were actually cooperating with Charlie from Astral, Charlie Marsh and with Joe from FEC because we had this need.
- 24:39We had it implemented ourselves and then they could look at how we've done that and they could implement it properly in their tooling.
- 24:46And we've been like exchanging the, you know, like Charlie was even interviewing me at some point of time, how we, how, what, what are our needs?
- 24:53So I have for a long time, I have this, this motto that the best way to foresee future is to shape it.
- 25:00And like, so we did shape the future by, you know, talking to those tool providers so that they can, or builders so that they could build it for us and work with us.
- 25:08And we helped them to test them and everything like that.
- 25:10But also it was like listening to Amog and other contributors, like all the problems they had or like, and then when I solved it, I wouldn't, I wouldn't also own solve it with the new tooling, but we also engaged all the more people from the, from the team, like Amog and few other active contributors.
- 25:27And they were actually part of the whole process of conversion.
- 25:29And they are now part of the team.
- 25:31And now we can have this podcast while things are being broken in airflow right now.
- 25:36And somebody is probably fixing it right as we speak.
- 25:38So like, not me anymore.
- 25:40So that's, those old, old things are really great.
- 25:42This portion of Talk Python To Me is brought to you by us.
- 25:46I want to tell you about a course I put together that I'm really proud of.
- 25:50Agentic AI programming for Python developers.
- 25:53I know a lot of you have tried AI coding tools and come away thinking, well, this is more hassle than it's worth.
- 26:00And honestly, all the vibe coding hype isn't helping.
- 26:03It's a smoke screen that hides what these tools can actually do.
- 26:07This course is about agentic engineering.
- 26:09Applying real software engineering practices with AI that understands your entire code base, runs your tests, and builds complete features under your direction.
- 26:19I've used these techniques to ship real production code across Talk Python, Python bytes, and completely new projects.
- 26:27I migrated an entire CSS framework on a production site with thousands of lines of HTML in a few hours.
- 26:33I shipped a new search feature with caching and async in under an hour.
- 26:38I built a complete CLI tool for Talk Python from scratch, tested, documented, and published to PyPI in an afternoon.
- 26:47Real projects, real production code, both Greenfield and legacy.
- 26:51No toy demos, no fluff.
- 26:53I'll show you the guardrails, the planning techniques, and the workflows that turn AI into a genuine engineering partner.
- 27:00Check it out at talkpython.fm/agentic dash engineering.
- 27:04That's talkpython.fm/agentic dash engineering.
- 27:07The link is in your podcast player's show notes.
- 27:10How does GitHub deal with so many files and such a big project? Is it fine or is it a challenge?
- 27:18Except yesterday, where half of the time GitHub was not at the end.
- 27:21Except yesterday.
- 27:22Yeah, for people who don't know, yesterday morning, at least morning US time, GitHub was having a moment.
- 27:27Like, it was, I couldn't clone stuff.
- 27:29I pulled up the random page on GitHub and got the 503 Unicorn.
- 27:35It was not good, right?
- 27:36Besides that, not excluding that time.
- 27:38The Unicorn is actually a little bit like looking kind of angry at you.
- 27:41That's one of the observations I had from yesterday.
- 27:44I saw it so many times that it's like, it doesn't look nice.
- 27:47But maybe GitHub.
- 27:48I agree.
- 27:49That's not a great error page.
- 27:50Like, some error pages are amazing where it's like, you know, the coyote fell off of a cliff.
- 27:55Woo!
- 27:56You know, like, that one just looks like it's angry back at you.
- 27:58Besides that, it's perfect.
- 28:00Like, it works like seamlessly, no problems whatsoever with the size, with the numbers.
- 28:04Like, we are very, very happy in general.
- 28:06And of course, like, things like that happen.
- 28:08There is nothing wrong.
- 28:09Like, there is something wrong, but like, it's not like that, that it happens all the time.
- 28:12Not really like GitHub.
- 28:13It's super rare.
- 28:14GitHub is an incredible service.
- 28:15I mean, I know there's been some grief about the GitHub actions, but I put, that's a different, different conversation.
- 28:22Right?
- 28:23So let's talk about, next, about how the package standards have changed and how basically some of those things have made it possible.
- 28:31And so in your talk, you pulled up a bunch of different peps, nine of them or something like that, that were about packaging, recently packaging standards and different things like that, that have made basically the structure that you're working with and the tools that do it possible.
- 28:45Do you want to maybe highlight either of you, some of these things that stand out as, this one is really important.
- 28:50The one which is maybe not super related to Monorepo, but it actually helped us a lot, like the pep723, the last, all the, one but last inline script metadata, which is like one of the biggest successes and the biggest kind of usages I see from PEP implemented.
- 29:07It caught up very, very quickly. It allows us to, you know, embed inline script metadata into, into the Python scripts, which is like something that we've been dreaming of for years, especially for this kind of tooling, the FCI environment, et cetera, et cetera.
- 29:21This is really, really helpful.
- 29:22So that, that's the one that I would like to highlight.
- 29:24But I, you know, I read all of them like many times, all the peps and they are difficult things to read, to read and understand, but they were like, we actually did all that we could to, you know, be like fully compliant with the, not only with the specification of those peps, but also with the kind of spirit of the specification, because sometimes things are not very precisely described and there are some interpretations and stuff.
- 29:46So we just, we just made sure, and this is our, our goal as well.
- 29:50Like we just make sure that all the PEP standards that are being published are actually very meticulously followed.
- 29:56And we just try to adapt to any changes that are coming in the environment.
- 30:00So we know how difficult it is if people are sticking to the old ways and like that's, that makes difficult for Python maintainers.
- 30:06Mark, any other thoughts?
- 30:07This one is a particularly very important one for us also because it simplifies our pre-commit configurations where earlier we had to,
- 30:15you know, specify the dependencies as required.
- 30:19So like whatever the particular version was, but now it's all in the script.
- 30:23It's not, and the pre-commit remains as clean as it could just with the hook name and,
- 30:28you know, the regex for the file filter and minimal configurations for it to work well.
- 30:34And I think your dependency group is also the other PEP.
- 30:37I don't recall the name, but I recall the number.
- 30:40I think it's six.
- 30:41Oh, I can't remember all the numbers, but one of those.
- 30:43That would be 735 folks, 735.
- 30:46That's also particularly nice for us.
- 30:48We can define the dependency groups in our by-projects and it's, it's nice to, it's really nice how it works with uv.
- 30:55We're very happy with this particular dependency group as well as the inline scripts.
- 30:59Right.
- 31:00The inline scripts are cool.
- 31:01I, you know, especially with uv these days, it really makes running some kind of Python code so much easier.
- 31:08It's, it's almost as if everything is standard library.
- 31:12I can give somebody a file.
- 31:13I can say the way you run it.
- 31:14No, no, no, no, no.
- 31:15Don't.
- 31:16I know it looks like you say Python, but don't say that.
- 31:18You say uv run this and then, and that's it.
- 31:21Like they didn't even have to have Python.
- 31:22They might need 10 dependencies and so on it, but it doesn't matter.
- 31:26Right.
- 31:27Yeah.
- 31:28And big standard.
- 31:29It makes it also, you know, like other tools are doing the same or hatch run.
- 31:31That's the same.
- 31:32That's like, yeah, there is even like support for inline script metadata just released in latest
- 31:37tip 26.
- 31:38So like, it's all good because of the standards and not because a single particular tool does it in an opinionated way.
- 31:44So this, this is really, really, really cool.
- 31:46And there is one big benefit of those kinds of apps and this part, particularly inline script metadata.
- 31:52It's like, we have less YAML.
- 31:54Yeah.
- 31:55You already have a lot of YAML, but less is better.
- 31:58We have a lot still.
- 31:59We can't come from that.
- 32:00It's better than it was.
- 32:03Yeah.
- 32:04And so the dependency groups are like, you know, for dev or for tests or something like that.
- 32:09Right.
- 32:10So you can say like uv sync or uv pip install, and you can say like thing bracket dev or something like that.
- 32:19Right.
- 32:20The nice thing is about you think is that it sends the dev dependencies automatically without you even specifying that, which is like the best thing for development because you actually always want to have developer developing development tools with you.
- 32:31That's a good point.
- 32:32Yeah.
- 32:33That's really cool.
- 32:34That was the changes to Python itself through the peps.
- 32:37But there's also tools and you've already mentioned some of them, both of them, but tools that make this possible, which I mean, I think uv has to be number one that goes on this list, right?
- 32:47Like uv has really done some powerful stuff here.
- 32:50Right.
- 32:51Again, Amogh can say like, I introduced it, but Amogh was the one to switch to use uv at some point of time.
- 32:56Yep.
- 32:57UV has been a game changer.
- 32:58I think we were using poetry before this or Hatch.
- 33:01I don't know.
- 33:02No, not even that.
- 33:03Just pitch.
- 33:04Just pitch.
- 33:05Just pitch.
- 33:06Just pitch.
- 33:07Just the image.
- 33:08It's so good.
- 33:09I don't even remember the last, you know, game changing aspect that uv brought in was this notion of workspaces.
- 33:13It's something very simple.
- 33:14You can compare it very similar to, you know, a co-working space or something similar where it's a unified environment where multiple interconnected pieces coexist and they're very easy to manage.
- 33:26And that's something that eventually led us to splitting the whole repository across our distributions.
- 33:32And that's the reason you see so many toml files.
- 33:35So everything has a by project toml.
- 33:37Everything defines the dependency groups it needs and development of a particular package is restricted only to its dependencies.
- 33:46So you develop it, you run uv sync, you can run your by test using uv and everything that is supposed to run with it is running with it.
- 33:55And any bad or, you know, cross imports are caught really easily.
- 33:59So I think the workspace feature at least was the most important one for me.
- 34:05And obviously the speed that it brings with it.
- 34:07And that's impressive.
- 34:08It is.
- 34:09And I think this workspace concept, it's new to me.
- 34:13I'll say it's new to me.
- 34:14I don't know how new it is to other other folks.
- 34:16So you've got this giant monorepo and how many different conceptually different packages or projects are in there right now?
- 34:26120 plus.
- 34:27It changes by day because Amogh is doing a lot to increase the number very, very quickly because we are just now in the middle of finishing some isolation kind of restructuring.
- 34:38And Amogh is the one that that's why he's here also to lead the introduction of new packages that we or new distributions that we that we have like a shared libraries that we will talk about later.
- 34:48So we have a lot of those.
- 34:49Yes.
- 34:50I think this is super important to dive into and how uv makes this possible.
- 34:54And I think you said also Hatch, you talked with Ofek, who runs Hatch as well about this, right?
- 35:00Yes.
- 35:01Yes.
- 35:02Hatch is also supporting workspaces, which are modeled mainly about what like after what uv has done.
- 35:07We haven't tried it yet, but I've heard it's very, very similar or even like you can use it as a one to one replacement in some cases or maybe even in all.
- 35:16But generally, I would love this eventually to become some kind of standard so that multiple tools are supporting this.
- 35:21But but yes, there are a few other tools that we were considering before, but uv is by far the kind of like, yeah, well, we work together.
- 35:28We shaped it together with the uv team.
- 35:30So it definitely works well for us.
- 35:33Yeah.
- 35:34Amazing.
- 35:35So let me describe this a little bit and then you all can can actually introduce it.
- 35:39So the idea is we've got this mono repo with a bunch of different folders for the sections, right?
- 35:45Like airflow dash CLI or CTL and airflow dash core and so on.
- 35:49And you'd like to be able to kind of just jump into one section and treat it as a top level project, right?
- 35:56It's got a pyproject.toml.
- 35:57It's got a source file, tests and so on.
- 35:59But the challenge is you can't just have a bunch of disconnected pieces like maybe airflow core depends on five other parts of it that are also themselves have their own pyproject.toml and different things.
- 36:12And you've got to set up, you know, set up.
- 36:14If you jump into the airflow core, you've got to set up the environment just right to be working on those other parts, right?
- 36:19It sounds pretty tricky.
- 36:20So how does how does that work?
- 36:22Who wants to make sense of this for us?
- 36:24It works perfectly.
- 36:25Like it's super, super simple, actually.
- 36:27You know, like the whole thing about the uv is like its simplicity of the of not of the concept.
- 36:33The implementation is actually quite tricky.
- 36:35But the way how you use it is very simple.
- 36:37Just go to the directory and run uv sync.
- 36:39That's basically it.
- 36:40This is the directory you want to work on.
- 36:43And it does exactly what you would expect it to do, which means that it syncs.
- 36:47It actually updates the or recreates basically the virtual environment that you're using with all the dependencies that this particular distribution needs and anything that it needs.
- 36:56As a transitive dependency as well.
- 36:58So if it refers to another project project inside the workspace, it will also use it from there, not from like installed by by PyPI.
- 37:05So you can immediately start working on this because everything after uv sync, everything is exactly as you expect for this particular subset of the repository that you were on.
- 37:14And that's basically it.
- 37:16This is all.
- 37:17Like there is nothing more, basically.
- 37:18That's it.
- 37:19It works.
- 37:20And you can, when you run uv sync pytest run, it will do exactly what you want.
- 37:25So in this folder, because it will also uv, uv run py test, it will do exactly what you want because even uv run will automatically sync the virtual and very, very quickly to the one that your project needs.
- 37:38And then it will just run pytest in this virtual environment and it will run all the tests in your project.
- 37:43And that's basically it.
- 37:44So it's like conceptually for the users is like, you don't have to do much, just uv sync.
- 37:49And that's it.
- 37:50I think one of the big challenges here is how do different parts of the project know about each other, right?
- 37:57Yeah.
- 37:58You said that it, it, it's similar links the different elements in.
- 38:01The basic kind of workspace and implementation is just a workspace definition.
- 38:05So you have to have the definition of workspace in the top level by project.
- 38:09So there you have all of them listed.
- 38:11You have links to it.
- 38:12They have described where they are and uv will read the by project from the top level and will, will know what they are.
- 38:18We'll, will know where to look for particular distributions.
- 38:21So that's the, that's the simple discovery and the way how we know that we are using it from the sources and not from the, from the PyPI.
- 38:29But then like the shared libraries as, as it's like something that we added on top of it and the sim links are on the top of it.
- 38:36And this is kind of extra innovative thing that we are doing for something else that we need, but you know, we can, we can talk about that now or like I'm not can talk about.
- 38:44This is really cool.
- 38:45So one of the things that happens here is these different slices or subsections of the monorepo pyproject.toml that pyproject.toml depend, defines its true dependencies and its dev dependencies and so on.
- 38:59So when you go and jump into a section, it will, uv will basically realign the virtual environment with whatever dependencies are supposed to be there from those things.
- 39:10Right. So that means installing stuff, obviously, but actually what surprised me a little bit, not a lot, but like, Oh yeah, I guess it does do that.
- 39:17That's cool. Is it actually uninstalled stuff. That's not explicitly put there, which I can imagine before that you could be like, well, this one part way down here depends on this weird library.
- 39:29And somehow I used to be over there. Then I went back to the, this other piece and then I came back and I forgot where that even came from.
- 39:36Like, why is that in my virtual environment? And like, how do I specify that? Probably juggling that was a big problem, right?
- 39:41This, this like loading and unloading dependencies based on what part of the monorepo you're in.
- 39:47And I think that actually makes it really much easier to deal with like this, this type of code structure.
- 39:52Let me add to that one more thing, because it's also not only the dependencies that you might have from somewhere else, but also it's a cross dependencies between different distributions inside.
- 40:02So for example, if our flow CTL does not use our flow core, if you go there and you think you will not be able to report and use any of the source code, which is in airflow core, because it's not a dependency of our flow CTL.
- 40:14So uv sync will not only uninstall the dependencies that you have, but also uninstall the source code that you have from other parts of the repo, which is a fantastic thing for us.
- 40:23And that was exactly what was missing before kind of isolation between those.
- 40:27You only actually can from your source, you only can refer to the source code of those distribution that you depend on and nothing else from the monorepo.
- 40:36So this means that it's like you can slice and dice your repository as you want.
- 40:41So depending on in which the directory you are and when you run uv sync, you will have like subset, like the actual useful and the used subset from your repository.
- 40:51And it can be completely different if you go to another directory, some of that can be overlapping, some of that can be completely different.
- 40:58Depends like which dependencies are defined.
- 41:00And this is like, this all magically happens, like by just defining the dependency in pyproject.
- 41:06And uv sync will handle it for you in the workspace.
- 41:09It's like exactly the reason why it's so useful for developers.
- 41:13It helped us in our vision to actually, you know, decompose the project into multiple parts and avoid the classic problem of coupling, which every monorepo faces at some point in their lifecycle, because everything is out there.
- 41:27Why don't we just, you know, have code leaks all over the place.
- 41:31So this helps us prevent that.
- 41:33And I cannot imagine a time how we did it earlier before uv.
- 41:36I don't know if we did it, but if we did it, it would have been a really tough thing.
- 41:41Yeah, there's a bunch of tools that you can, linters and code analysis things you can run on your code that breaks down for these different modules and these layers.
- 41:50Here's like a directed graph of how this thing, and you can set up rules to say this should never cross that boundary, but these are just very, very vague things.
- 42:00And this setup actually makes it so it's not accessible to your code.
- 42:04If you didn't say it should be.
- 42:05It's just built in exactly the definition of your distribution, which you anyhow have to do because like you have to define what the, what the dependencies are.
- 42:13And yes, we did something like that before.
- 42:15So we get a number of like rough rules or whatever.
- 42:18Don't import here, import here.
- 42:21We still have them for shared libraries, which we can talk about now, because I think this is an important modification of the concept.
- 42:28So we do have some automated check for quality and for imports with prek, our Prec commit hook implementation.
- 42:36But before that, it was just completely, completely like handwritten and unmaintainable.
- 42:42People will not, we're not actually updating it with all the distributions you couldn't really, you know, follow when things change.
- 42:48With PyProject Tom being the, for each distribution being the single source of truth, you don't have to do anything because the dependency is declared there.
- 42:56And this is like the best part of, of uv understanding that and, and doing everything that is like reasonable in this case.
- 43:03The other major tool involved here was prek, which it's a pre commit framework for running hooks, many languages, but especially Python relevant here written in Rust.
- 43:15So it pairs well with uv, I suppose.
- 43:17Oh yeah.
- 43:18It was inspired by uv as well.
- 43:20And, and Joe was mentioning, mentioned that, that he was actually contributing to uv before.
- 43:25Great.
- 43:26How's prek show up here?
- 43:27I feel like this is leading towards what you were hinting at earlier.
- 43:30It's a new name, prek.
- 43:31So, yep.
- 43:32This allows us to do a few things which pre commit did not do, or, you know, did not accept as suggestions.
- 43:39So, one certain thing that prek offers is obviously it's written in Rust.
- 43:45So speed is the obvious one is that we get.
- 43:48But apart from that, we also get this notion of it pairing well with uv in terms of modularized hooks.
- 43:53Earlier, we had all the hooks in one place in that, in the top level pre commit YAML, right?
- 44:00And it was a big fight.
- 44:01It was really big.
- 44:03You can imagine.
- 44:04So, yeah.
- 44:05So this prek allowed us to, prek again, you know, it, it consumed the concept of workspaces here, I would say.
- 44:11So it allowed you to define pre commit hooks or prek hooks within a module itself.
- 44:18And this paired well with uv in the sense that when you have to run hooks that are bound to a certain distribution,
- 44:26all you have to do is check in into the, you know, the sub module and just do a prek run.
- 44:31It will run the relevant hooks for that particular module.
- 44:34And the other, other thing that I really love about prek is auto completion, which is not something pre commit had.
- 44:41So you can imagine that something fails in the CI, you have to copy that and copy the ID and try to kind of backtrack it in your repo as to which one is failing.
- 44:50So it's, it used to be a nightmare, but now with the, you know, the tab completion, it's, it's amazing.
- 44:56Nice. Are you talking about like shell autocomplete integration?
- 45:00Yeah. Yeah. So, okay. I've seen.
- 45:02I have some story about that very, very short.
- 45:04So like we actually tried to get out the completion for hook names with, with Prec commit, which was the predecessor of prek.
- 45:11Like prek was largely based on Prec commit, but somehow the author of it didn't accept even idea of us contributing it or actually had some very, very excessive expectations for that.
- 45:22And we, you know, discussed and like, there were like, other people were also trying to convince the author to do that, but they refused.
- 45:29He refused basically and refused to accept contributions.
- 45:32Even when we spoke to Joe, that was like completely different stories.
- 45:36Like we need that.
- 45:37And next day it was there.
- 45:38Like it's like completely different approach.
- 45:41So, so this is, and then we said like, we need workspaces and like a few weeks later, because it took a little bit of time, it was there and we work together and we tested that.
- 45:49And like, I raised, I don't know how many issues in the initial kind of pre-release version when, when we wanted to use it.
- 45:55So I think the collaboration and being, you know, working together, listening to your users and be responding and actually working as an open source maintainers together.
- 46:04This actually worked perfectly well here, both, both in uv and prek.
- 46:08And this is why we love prek actually because, because we know we can rely, if something is not working, that it's going to be like, we can discuss and either submit a fix or, or, you know, Joe will do this or even like lots of other people can do it.
- 46:22Because there was a few features that we wanted and somebody else implemented it.
- 46:26And that wasn't Joe, they contributed prek because of this openness and, you know, being able to accept the needs of the users.
- 46:35That was very, very important part, like why we moved to prek.
- 46:38Yeah. I think Airflow was also one of the initial case studies for prek.
- 46:41It's a project of that scale. And if you kind of satisfy that project's needs, you are, you're pretty good with most use cases.
- 46:48I think that's quite both Prec and UVS.
- 46:51Yeah. Right there at the top of the prek repo, it says, although Prec is pretty new, it's already powering real projects, you know, little things like CPython, Apache Airflow and FastAPI.
- 47:01I know Hugo van Kemenade from the release manager of Python. So we met at Fosdem as well. And like, he was actually listening to our prek discussion and he converted, you know, CPython to use prek because of the, of the needs they had.
- 47:13So like, it was all about, you know, people talking to each other, word of mouth and things like that.
- 47:19You know, there's a feature listed here that just makes me jealous. One of the features of prek is a single binary with no dependencies that doesn't require Python or any other runtime to be installed.
- 47:29Like how incredible would it be with Python if we had a, a Python --build app or something, you know what I mean?
- 47:36You can put it at your thing and you get something you could distribute. I know uv solves a lot, but you still got to have uv installed.
- 47:43And then, you know, like this, that is a huge advantage of things like Rust and go and some other languages.
- 47:49It's both good and bad in some cases. So it's like, there are always trade-offs, different choice made by Python here.
- 47:55I don't think it's like the best choice for, for Python. I think Python being script language, it's okay to have, you know, like dependencies and especially like inline script, script metadata almost did it because you just, you know, can install stuff.
- 48:09And uv also, and the kind of tooling is also doing all the stuff like uv install or uv tool install, whatever.
- 48:16And it would not only install the project, its dependencies, but also install Python that is needed to run it.
- 48:22So like all this is really a matter of two weeks and it has improved dramatically over the last few years.
- 48:27Yeah. I was pining for an option, not a only binary thing.
- 48:32All right. So one thing I actually want to talk about going back to this workspaces thing real quick is what does it look like from a IDE or editor experience to work on this?
- 48:43All right. Like you've got Python projects, you've got maybe VS Code workspaces where you can pull in different pieces. How do you all manage that?
- 48:52I cannot talk for VS Code. I'm a Python user here, but we had to do a little bit of hacking, I would say, or more like a helper script for the IDs, right?
- 49:02Because so we have a IDE helper script right in the repo and we recommend the users to run it so that the IDE knows what is where in terms of maintaining things, right?
- 49:12Because in normal projects, there's usually just one source, one desk at the top level, but it has 120 plus.
- 49:19And the helper script is, it does a pretty simple thing. It just auto discovers all the packages in the monorepo and adds this.
- 49:27So IntelliJ and PyCharm both have a .IDR within each, a hidden folder within each of the projects that it opens.
- 49:35And it has a, and it supports XML like format for IML where you can define certain things.
- 49:42So this essentially does a very simple thing.
- 49:44It just, for each package, it adds the module slash source as the source root and the module slash tests of the test.
- 49:52It's as if you went through all 120 things and right clicked and said mark as sources root or something like that.
- 49:56Yeah, we had this PyCharm script and then we have the same approach for VS Code.
- 50:00So we have another script for VS Code as well, which was contributed by someone who uses VS Code because neither me or Amog are VS Code users.
- 50:08PyCharm uses both of us.
- 50:09But, you know, communities also and like somebody said, OK, I'll do it.
- 50:13And there it was.
- 50:14And they tested it.
- 50:15And, you know, like that's, that was super cool actually.
- 50:17So, yeah, it works well.
- 50:19Also, the, you know, a little bit of words, probably we don't talk, we won't talk too much about like the, we don't have too much time, but the shared libraries concept a little bit might maybe it's the right time to introduce the concept.
- 50:32Because, because we like one thing that Amog mentioned is like the, we have, we solve this coupling problem, but also we wanted to solve the dry problem.
- 50:41And those two are always kind of mixture, like you get dry and then you get more dry and less coupling and like, like more dry and more coupling and like all these things are complex when you have lots of code interacting with each other.
- 50:54Dry being the architectural philosophy of do not repeat yourself.
- 50:57But if you're not repeating yourself, everything where if it exists somewhere, everything's got to depend on that somewhere and it starts to become more linked together.
- 51:04Right.
- 51:05So it's a little bit of like a, eat cake and have it too.
- 51:08Like we want to have dry code and not to repeat it for like common utilities, like logging, configuration, whatever, all the things that are kind of common between all the different distributions.
- 51:18But also we didn't want to depend on a single version of those, because if we do, then it means that we have to make sure that the backwards compatibility is maintained.
- 51:26Because like when we install different version of different distributions coming from different time of repository, they might use different version of those shared libraries.
- 51:35And like how to make sure that they don't have breaking changes and stuff like so this is all the whole level of complexity between like how to manage the dependencies there and manage versions, especially manage the backwards compatibility.
- 51:48So we figured out that with some very simple approach, we tried a few different approaches, but like, like one of the approaches was using the vendor link library from pip and from Byton, no, from pip, from pip.
- 52:01And the second one, and that's the one we came up, we finally implemented, was like using Simlinks to share the code between different distributions.
- 52:09And that's a very innovative approach that I hope will make it into some kind of standard eventually.
- 52:14So like we came up with this approach where we actually have cake and eat it too, like, which is like pretty amazing if you fought with like for years with this kind of common dependency issues that and backwards compatibility.
- 52:27So in our case, like the Simlink approach we have, it needs some pre-processing of by project DOM.
- 52:33Some parts of the PyProject DOM are generated to make it actually work.
- 52:37But this is all automated with prek, which is like, we don't have to think about that even.
- 52:41And once we do that, and once we create some Simlinks between different parts of code, like one library, one distribution is Simlinks in code from the shared distribution.
- 52:50The end result is that this code gets automatically vendored in during the building of the package, which means that we actually have the same library in different package, in different version, in different distributions.
- 53:02So distribution released a week ago will have a shared configuration from a week ago.
- 53:08But another distribution will have the same shared configuration code from today if it's released today.
- 53:14And we can install them together.
- 53:16And all of them have effectively, like if they had a different version of the same library installed.
- 53:22It's as if the Airflow-CTL said it had a dependency on core and it pinned that version to something, but a different part of the repo pinned it to a different.
- 53:31And they can both kind of coexist.
- 53:34But it's actually all within the same code file.
- 53:36That's insane.
- 53:37OK.
- 53:38And this is like largely, like it's nothing new.
- 53:40It's largely inspired by how the libraries work in C and like traditional kind of building code.
- 53:46Like you have dynamic libraries and static libraries.
- 53:49So this is like essentially equivalent of static libraries where you take the code of the version that you compile the stuff in and put it inside the final binary.
- 53:59And then it results like in Rust, the kind of single binary thing.
- 54:02So it's a little bit like, so we have a little bit of this single binary by doing that in the sense that we automatically vendor in all the, you know, shared dependencies that we have in the same distribution.
- 54:15So it's kind of hybrid, but it's always like, so Rust is a little bit too far because everything is single binary.
- 54:21In our case, we have a bit of both.
- 54:23Like we can use libraries dynamically, but we can also embed libraries as shared inside the single distribution.
- 54:29That's very cool.
- 54:30That's wild.
- 54:31Amogh?
- 54:32Sounds like you were instrumental in this, Pari.
- 54:34That's the nice thing about the approach that was chosen, right?
- 54:37We all came together as a community on this one.
- 54:40And we had one email, DevList discussion one fine day that, hey, we want to achieve something like this, which more or less was something everyone agreed upon.
- 54:50So people started chiming in and we started trying different things out.
- 54:53The first one, obviously using the rendering tool from Pip.
- 54:57Somebody did a POC on that, but it felt like it's going to be difficult to achieve that long term.
- 55:02And also it could be brittle.
- 55:04So Jarek came up with this particular option with Simlinks, which again was discussed within the community.
- 55:10A few of us picked this PR up, passed it locally, played around and gave the feedback.
- 55:16So I don't think this would be possible with AI in the sense that this has never been done before.
- 55:23Or something like this, where a community comes together and solves a rather difficult problem, is something that makes me really happy.
- 55:31And also something that all of us are working towards a common goal while also bound by our corporate hats, right?
- 55:38Is something that is again, really nice to see.
- 55:41We have about how 11, I think at this point, we have about 11 to 12 shared libraries where the main notion here is to reimagine Airflow as a independent server and more like a control plane and execution plane.
- 55:54What we did with Airflow three and this shared libraries is helping us achieve that model.
- 56:01And we have about 11 to 12 of them.
- 56:03And I think a few more coming very soon.
- 56:05But yeah, that's yeah, it's been nice working on the shared libraries.
- 56:10It's yeah.
- 56:11Is this something that people can take and adopt into their monorepo if they want to live that life?
- 56:16Absolutely.
- 56:17Yeah.
- 56:18It's just that it's really like one or two kind of prek hooks which are maintaining the consistency.
- 56:23And like, so that you don't forget to add this symlink here and that kind of I project com definition here and or that hatch definition for the hatch link to actually embed your symlink code into the final distribution.
- 56:38So like there are like a few pieces that have to be put together from existing libraries.
- 56:43So that's basically it.
- 56:44And once you do it, it's just that those are the funny thing is like those shared libraries are just standalone distributions.
- 56:51You can actually build them separately as a library as well.
- 56:54We could potentially even, you know, like just use them as library as well.
- 56:58No problem whatsoever because they are just standard plane distributions or any other.
- 57:02We just happen to take the source code of it and then embed it in into the target distribution that wants to use it rather than, you know, link to it by dependency.
- 57:11So that's basically other than that.
- 57:13It's it's it's a kind of completely standard library and or standard distribution.
- 57:18And one one more thing that is really important to add here is like this also has a side effect, but I think a very nice one.
- 57:24And Amo can confirm that because he has been doing a lot of that is like we actually come up with like way better internal architecture.
- 57:31Or because of that, because a lot of those shared libraries, they depended on each other, sometimes in a circular fashion.
- 57:38Sometimes it really dependent, like which import you did first, like what happened, like what was initialized.
- 57:43And I was like complete spaghetti of dependencies between generally independent pieces of functionality.
- 57:49Right now, by having shared libraries, we are actually forcing ourselves to make it make them isolated.
- 57:56We are changing the way how we initialize them.
- 57:59For example, we are injecting all the configuration rather than using them from inside the library, because like configuration libraries and other libraries.
- 58:06So you don't want to depend on the other libraries.
- 58:08So it's and it's really nice.
- 58:09I think it comes.
- 58:11The result is that really the architecture of Airflow internally is so much better because of that.
- 58:17So less surprises and explicit initialization is like something that we'll have to do rather than implicit initialization, initialization during imports, which which has always been plaguing as a big issue.
- 58:28Certainly, it also allows you to imagine each component having an entry point, per se, where you have an initial starting point and it initializes everything it needs by injecting and calling certain factories, which makes a very clean for anyone visiting the project.
- 58:45Also, they look at something and they know the entry point very clearly that, hey, this is how it starts.
- 58:49This is what it initializes.
- 58:50You know, it reminds me of like Golang or Java projects where they have a nice, nice main where in Python, Python, it's not really the same way.
- 58:59All right. Well, I think that's about it for all the time we have.
- 59:02I guess let's close it out with one final thought.
- 59:05Here's just people who are maybe inspired by your design, by the way you put together Airflow and this monorepo concept, especially Python people.
- 59:15What do you what do you say to them?
- 59:17Final thoughts here.
- 59:18I mean, like there was always discussion.
- 59:20Like we had lots of discussions internally, even some of the teams members in Airflow.
- 59:24They let's split the repository into smaller one.
- 59:27Like let's make more of them because it's going to make things easier.
- 59:30I was always the monorepo fan and and I made a lot of work to make it possible.
- 59:35But that was a very, very difficult thing.
- 59:37It's changed.
- 59:38So like the reasons why you would like to have multiple repos are gone now if you're using the right tooling.
- 59:44And only the benefits or mostly the benefits from having it in one place where you can test everything together and work on it together, remain.
- 59:51All the rest is basically gone.
- 59:53So for me, the discussion monorepo versus multirepo is already solved.
- 59:57Yeah, just do it.
- 59:58We it's not even.
- 1:00:00So personally, I've been using the read me that we have present in the shared libraries as a context for my ID.
- 1:00:07So it's turning out to be very nice for the shared library split, for example.
- 1:00:12All I have to do is just provide it the context and tell it, hey, just just construct the structure for me and I can do everything else.
- 1:00:20So it's that easy.
- 1:00:21We have all the things in place.
- 1:00:23We are in the right area to do it.
- 1:00:24So just do it.
- 1:00:25Very inspiring.
- 1:00:26Thank you for being here.
- 1:00:28Awesome for this look inside.
- 1:00:31And it's Apache Airflow.
- 1:00:32It's on GitHub.
- 1:00:33People can go look and see.
- 1:00:34It's not just a talking vaguely about some internal project.
- 1:00:38Right.
- 1:00:39So people can go check it out.
- 1:00:40All right.
- 1:00:41See you later.
- 1:00:42Thanks.
- 1:00:43Thanks.
- 1:00:45This has been another episode of Talk Python To Me.
- 1:00:48Thank you to our sponsors.
- 1:00:49Be sure to check out what they're offering.
- 1:00:50It really helps support the show.
- 1:00:52This episode is brought to you by our Agentic AI Programming for Python course.
- 1:00:57Learn to work with AI that actually understands your code base and build real features.
- 1:01:02Visit talkpython.fm/agentic-ai.
- 1:01:06If you or your team needs to learn Python, we have over 270 hours of beginner and advanced
- 1:01:11courses on topics ranging from complete beginners to async code, Flask, Django, HTMX, and even
- 1:01:18LLMs.
- 1:01:18Best of all, there's no subscription in sight.
- 1:01:21Browse the catalog at talkpython.fm.
- 1:01:24And if you're not already subscribed to the show on your favorite podcast player, what
- 1:01:28are you waiting for?
- 1:01:29Just search for Python in your podcast player.
- 1:01:31We should be right at the top.
- 1:01:32If you enjoy that geeky rap song, you can download the full track.
- 1:01:35The link is actually in your podcast blur show notes.
- 1:01:38This is your host, Michael Kennedy.
- 1:01:39Thank you so much for listening.
- 1:01:41I really appreciate it.
- 1:01:42I'll see you next time.
- 1:02:11Bye.
- 1:02:11Thank you.