Python Bytes - #289 Textinator is coming for your text, wherever it is

Episode Date: June 21, 2022

Topics covered in this episode: beanita The Good Research Code Handbook Textinator Handling Concurrency Without Locks Extras Joke See the full show notes for this episode on the website at pytho...nbytes.fm/289

Transcript
Discussion (0)
Starting point is 00:00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 289, recorded June 21st, 2022. I'm Brian Ocken. Hey, I'm Michael Kennedy. And I'm Gina Heuske. Welcome, Gina. I'm so glad that you could join us for the show. Well, I'm still very, very honored that I'm allowed to be on here because I've been a long-time listener. And yeah, so being on here is absolutely amazing for me. That's very cool.
Starting point is 00:00:27 So tell us a little bit about yourself before we jump in. Yeah, well, so I think my claim to fame most likely is that I'm the creator and maintainer of Octoprint, which is basically a web front end slash print server for 3D printers that I've been now maintaining for almost a decade, actually. So this December, it will be a decade. And it's written in Python, which is why I have gotten more and more interested into the language over the course of the past decade.
Starting point is 00:00:55 And also now hang out on conferences when I get the chance. And there is no pandemic going on right now. And in general, just kind of fell in love with the language, I got to admit. I used to be a Java developer. I'm very glad that I no longer am. And now I'm a full-time open source maintainer, actually, because I'm in the very lucky position
Starting point is 00:01:17 that people apparently love Octoprint enough that donations and such and sponsorships and such generate enough revenue that it can work for me. Oh, that's awesome. Very cool. Pretty awesome. That is so fantastic.
Starting point is 00:01:31 Yeah. I still don't know why it works, but hey, I'm taking it. Well, Michael, you got our first topic today. I do. I want to combine some things that we've covered before as a way to introduce something new. So way back when we talked about something called MongoDB. If I mentioned that I like MongoDB, I think this might be something I've been talking about. I love MongoDB. I think it's great. Love working with it from Python. It works super duper well for me. Now, one of the things I'm
Starting point is 00:02:01 envious of on the relational side is SQLite, which ships with Python and you don't have to start up a server or anything. You just say, here's a file. That's my database. Let me point database tools like SQL alchemy and stuff at it, right? With MongoDB, we haven't really had anything like that. But then we did talk about this thing called Mongita, which is Mongita is to MongoDB as SQL is to sql so that's pretty awesome you pip install mongito which is a beautiful little little character uh for its icon and you pip install this thing and then you can just create a like a disk connection or a memory connection or stuff like that it's not incredibly fast but you know what fast enough right fast enough for simple apps for demo apps or
Starting point is 00:02:44 if you're teaching a class or something like that, it's sort of my primary, basically demos, YouTube video demos and class examples and stuff. I don't want to have to people set up a whole database server. They maybe have never set up just to play with an example, right? So here's a cool way, except for it only does like the low level MongoDB API. So I'm a big fan of Beanie. I reached out to Roman Wright and said, hey, do you know of anything that will allow Beanie to work with something like Mongita? And he said, not really. So I'll make one.
Starting point is 00:03:16 Where did I put it? Oh, no, if I copy. No, I, yeah. So had the wrong one selected. He did Beanie the ORM. And I said, I want to use this ORM against the disk database, much like you would SQL Alchemy against SQLite. He said, no, I don't know of one of those, but what if I made Beanie for Mongita? And so I love the naming here. I wanted to put them all together. So Beanie is a local DB-like database ready to work with Beanie, right? So basically all you have to do to work with this
Starting point is 00:03:47 is import client from there, create a client, paste that, give it a directory just like you would SQLite, pull a database off of it, and then just call initialize Beanie like you normally would, but pass it this Beanie-ta database. So it just works off the file system.
Starting point is 00:04:03 So now you've got a local, mostly compatible MongoDB disk-based in-process thing that you can use for simple MongoDB examples. It has some things it doesn't support. Links, which are like following references across documents. Aggregations, which is a whole crazy data analytics aspect of MongoDB. And unions and other things that MongoDB doesn't support. So I'm pretty sure let's just double check here. Yeah. So it's basically just builds that wrapper on top of MongoDB. And the real challenge that was tricky here was Beanie is only async and
Starting point is 00:04:37 MongoDB is only sync. So you've got to somehow put those together. Anyway, thank you, Roman Wright for doing this. It looks really cool. And we could, we could come up with a joke for this, but I think that's Benitez. Oh, Brian, that was solid. That hurts. Yeah. Sorry. Not sorry. Okay. So I think that I'd like to talk to people about using good coding practices, especially in research and science. So ran across Patrick Minolt. It's an online book, really. It's called the Good Research Code Handbook. And he says it's for grad students, postdocs and PIs, which I had to look up was
Starting point is 00:05:26 principal investigator who didn't do a lot of programming as part of their research. And I think it's also just kind of a good thing for really anybody that's coming into to coding from a different field and wants to jumpstart some good practices. It's actually really kind of great. He's got a little roadmap, which is neat. I'll click on that roadmap. A little small here, but it goes through. It's got a journey mapped out there. I love it. Yeah, it's nice.
Starting point is 00:05:52 But kind of a visual of where you're going to go with this, but he talks about setting yourself up for success using Git and virtual environments and projects and even packaging and cookie cutter, which is cool. Talks about style guides and keeping things clean and removing dead code. Some coding practices like separating concerns and separating your pure functions from side effect functions, which I thought that some people don't really touch on right off the bat, but it's a good practice. Even talks about testing, although the focus is really around unit testing
Starting point is 00:06:28 and sort of some hand waves around end-to-end testing, but still, it's nice. And then even gets into documentation and social aspects like doing pairing and peer reviews and getting involved in open source and community. It's actually just really kind of a pretty solid book for people. Sounds great. Yeah, that's really great.
Starting point is 00:06:50 I think it's, yeah. Go ahead, Gina. No, I just wanted to say it sounds great. Because I sometimes have people joining Octoprint who are pretty much newcomers to the whole coding aspect, but are interested in writing a plugin or something like that. So that might be a good resource for them to just direct them to i had um you know i'm go brian i had somebody contacted me once and try to i wish i knew about this before because somebody contacted me and said
Starting point is 00:07:16 um we don't really need coding training but we kind of aren't used to working together well we're all individual people and now we're working as a group and we don't know how to do that. And I don't know if that's here, but a lot of this around this is sort of good practices working well with others. Michael? Yeah. What I was going to say is a lot of people, especially in this research field, learn to code in a jit fashion, like just enough learning of coding to get the problem solved. And then they just, they have to keep moving on. And it's easy to find yourself just stumbling into wrong patterns of, well, everything's into one huge file and it doesn't take like
Starting point is 00:07:58 command line argument inputs. It just hard codes the values in. So you can't reuse it. It's not a module you can import or a function you can call and you know just no error checking these are yes exactly no no testing all of that kind of stuff would be really valuable for people who are coming from that angle so definitely a good thing to check out and i love it good research.dev what a sweet domain name there's also one of the neat things about the the writing style is he's talking about trying to just free yourself from time. So not free yourself from time, but as a researcher, you're in a hurry. There's a lot of stuff to do.
Starting point is 00:08:36 And a lot of the stuff he's trying to get people to do is about offloading information so that you don't have to keep it in mind. So it talks about short term memory and long term memory and how, you know, like unit tests and inline code comments are good to, you know, short term reminders in the moment. And then project documentation and test suites are about keeping that knowledge long term. And that's kind of I never really thought about that before of short term versus long term information And I never really thought about that before, of short term versus long term information. But it's kind of a neat angle as well. So anyway.
Starting point is 00:09:11 Yeah, that is clever. So where are we at next? We have a- Something that I brought along. And given that I come from a 3D printing background now, I thought I would start with something that can be applied to 3D printing. And that is a Python library for building parametric 3D cut models. It is based on,
Starting point is 00:09:33 for those of you who have heard of the open source cut solution called FreeCAD, it's based on the same cut kernel, on the same modeling kernel and allows you to, um, yeah, programmatically design stuff. And that is pretty amazing if you want to do it parametric. So for example, imagine that you have some kind of case for, for an electronics project or something, and you need screws from, uh, screws, screw, um, holes at, at certain distances, but maybe you want to be able to scale that up or down or whatnot, or things like this. And for stuff like this, something like this is absolutely amazing. From the ground up, CatQuery is only a library, but it also comes with, as it says here,
Starting point is 00:10:17 it also comes with a Qt-based GUI called CQ Editor, which I tried out and worked great. The only problem was it came with an older version of CatQuery that did not yet support some stuff that I wanted to play around with. So what I did instead was I tried the Jupyter extension and just threw that up on my NAS in a Docker container, and that works absolutely wonderfully. In the browser, it gives you a 3D model view of the stuff that you're currently modeling,
Starting point is 00:10:45 automatically refreshes whenever you change something. And the way things look is, this is the GUI, by the way, you simply create, you define a work plane, then you create a box on this, for example. Then you say to the face,
Starting point is 00:11:02 to the top face in Z direction, define that as a work plane, put a hole through that with a diameter. So the whole API is pretty intuitive as well. Also well documented on here. And if you scroll a bit through the examples, you can see that there is way more possible than just planes with holes. But things like, where was it? Somewhere there was a little dum. Right. A flask or the aforementioned parametric enclosure, a Lego brick.
Starting point is 00:11:37 So for all of that, there is example code there. And yeah, it really surprised me how quick i got this up and running because i had a very specific use case that i wanted to try to run through that and uh that was inserts for one of these part case thingies where you can put inserts into sword screws and stuff and that worked flawlessly with that i had this finished in maybe half an hour or something like that so really great package works nice has everything that you expect from a basic cut solution and also works in a browser so if you want to go fully parametric and already know python then give this a look as well as free cut very cool yeah this. Yeah, I have a friend who is doing a lot of Python and CNC machines. He has a guitar company and it gets these wood blocks and shaves out guitars and necks and things that I'm not familiar with.
Starting point is 00:12:36 Would this be applicable to something like that as well? Not just 3D printing, but if you got to define the polygons of it, basically? The objects that it can output are STL files, object files. I think step export is also available. So all the stuff that you find commonly in the CNC and 3D printing world. So I could just design something with this, export the STL, throw it in a slicer for my 3D printer,
Starting point is 00:13:00 or alternatively throw a resulting step file or something into whatever workflow preparation I do for my CNC router, I guess. So I'm not that familiar with CNC. Yeah, yeah. I think this huge CNC machine, I think it takes STL files. Pretty sure. Well, then? I'll have to check.
Starting point is 00:13:20 But that sounds like it could be really relevant. A couple of pieces of feedback. Daniel Krass says says it's nice because he hates the GUI workflow of FreeCAD. Yeah, the funny thing is CAD query originally started out as a FreeCAD plug-in, actually, as far
Starting point is 00:13:35 as I see. So the CAD query 1 was FreeCAD, still built into FreeCAD. CAD query 2 is now standalone and just uses the kernel and all that. Really nice. For people who used to use OpenSCAD, that one is the next level and really nice. And then Brandon says, can you import this into a slicer for 3D printing? Yeah, that was what I meant with you can export the STL and then throw that into the slicer. Yeah, that's what I thought.
Starting point is 00:14:01 Perfect. Awesome. This is a great find. I love it. And I also love that you come with your experience and your view of Python and what's super interesting, because I would have never picked this, but it's very, it's very cool. And a lot of people are into it, right? It's just like, I'm like, oh, FastAPI.
Starting point is 00:14:15 Yeah, it's stuff like that. Yeah. Different point of view, I guess. I want to do some 3D printing. It'll be fun. It is, but be careful that you don't start a hobby project that then takes over your life that sometimes happens, I've heard. Well, so that's why I put that off,
Starting point is 00:14:30 because I know that I don't need another one. Brian, I heard you have some awesome 3D Star Wars stuff and maybe you could build in, like you could print some additional stuff to go with it. I could, yeah. Or just buy it. Yeah, there you go. Or you could like build in, like you could print some additional stuff to go with it. I could. Yeah. Or just buy it. Yeah, there you go.
Starting point is 00:14:48 Or you could just buy it. I just actually bought a part. So I needed a camera mount. So I had a camera that the one I'm using now, there's other applications where I want to use that I don't, I didn't have a mount for a tripod mount. And there was somebody, somebody on Etsy that, that it's obviously a 3D printed thing that you can buy.
Starting point is 00:15:08 So Etsy is full of people making useful things with 3D printers. I think that's neat. And $10 to somebody else to do it for me, what a deal. I'm happy to report that I'm currently looking into a camera that is sitting on a mount that I designed and printed myself. Wow, that's neat. Wow, that's awesome. Yeah, so that mounts to a VESA monitor arm and then has a little slide
Starting point is 00:15:33 that I can actually slide up and down to adjust the height. And I also have some of these angle brackets that are with tripod mounts on the up and down side that I can use to adjust the tilt and stuff. And yeah, so after I did this, that thing finally set where it is supposed to sit.
Starting point is 00:15:51 So win-win. JASON MAYES. That's awesome. And just for people listening who are not watching, Gina has the best video setup of all three of us. She looks great. It's a really good studio setup. And then parting thought on this one, Henry Schreiner.
Starting point is 00:16:07 Hey, Henry says 3D work from Python has always been tricky. So this looks great. Right? You ready for a fun one? Yeah. Let's switch to you. All right. I got something cool.
Starting point is 00:16:18 So previously I spoke about TextSniper. This is a Mac app and it lives in the menu bar, like up by the clock. And you just run it and you can, on Mac, you can hit Command Shift 4 and select a region and screenshot it. This one adds Command Shift 2, and if you select a region, it will capture the text out of whatever is behind it. So for example, I was on a meeting on Zoom
Starting point is 00:16:37 and somebody put something up and like, oh, I wanna have notes on that. And I thought, oh, I could type it. Wait a minute, Command Shift 2, swipe on Zoom. Boom, I have notes of the whole page instantly, right? This is a cool app. It's like 11 bucks for the Mac. This I sort of randomly mentioned that was thought it was cool. This is not what I'm talking about. What I want to talk about is Brett, Brett Turnbull said, Hey, I heard Michael talk about this tech sniper thing I just described on Python bytes. That's neat. I bet I could build this in Python. So he did. Nice. Isn't that dope?
Starting point is 00:17:06 So if we jump over here to the, I love the name. I got so many good names today. I mean, I didn't get them. I just gathered them up. So we have text sniper for that thing that grabs the text. He created the textinator and it's a simple Mac OS status bar, mini bar app that automatically detects text within screenshots. So instead of adding a new hotkey that does its own thing, you just do command shift four, copy it, and then it hooks into macOS through PyOBJC, figures out a screenshot was taken, grabs it, real quickly uses the neural engines in macOS and the Apple Silicon and stuff to
Starting point is 00:17:43 do the text processing, and then drops out the answer. And if you look at the whole app, the entire app end to end is 450 lines of code. That's brilliant. Yeah. Very cool. If you look at there's like, let's see, well, there's a lot in it. So you can see it's, you know, from foundation, from Coco, you know, import, NS Notification Center, and all these different things is what it's basically using to listen for events of screenshots being taken and then feed those off into the various places that it needs to go.
Starting point is 00:18:15 So what do you think? I think it's awesome. And Rhett's in the audience. And he says, thanks for the shout out. And then, of course, somebody says, just for Mac? I'm with Weasel on that. I'm afraid. Gina, what do you run for your OS?
Starting point is 00:18:33 Actually, Windows. Yeah, to the big surprise of many. But I'm also a gamer. So I got tired of constantly dual booting. So, yeah. That's definitely a challenge. So there's actually a video showing you how it works. And it uses something I've built apps with as well called
Starting point is 00:18:51 Rumps, ridiculously uncomplicated Mac OS apps or something like that. And so it's really an interesting way where it's just kind of like clicking together a couple of cool things, like the NSQuery for Spotlight with PyOBGC, the Vision VN recognized text request, and like just building on top of macOS and RUMS, which is pretty cool.
Starting point is 00:19:15 You do have to give it special permissions because it has to be able to monitor your system globally. So there's a few steps you got to follow, but well done, Rhett. I love the ambition here and it looks good. But this is incredible. What I love the ambition here and it looks good. But this is incredible. What I love about this is it's just one, it's just one thing, but it's a small application.
Starting point is 00:19:35 So, I mean, potentially just, you could, you come up with, with all of these pieces, you could do other stuff too, is, and, and have just a small example to try to learn off of. That's pretty neat. Indeed. Let me, let me just make a real quick suggestion out there. Maybe, I'm not sure if this is, I don't see it over here, but if over on the releases side, on my Rumps app, I did this and I put over in the releases, you can come over here and you can just download a.app zipped, but it just unzips as a.app file. So hit that with some Pi install, no, Pi 2, use Pi 2 app on it and make it one cool further step there. And maybe automate that with GitHub Actions. Yes, that's a very good point. Absolutely. So you don't have to constantly keep doing it. Yes, very good point. Push to a branch, have it do some magic.
Starting point is 00:20:20 Or click on release and have it do some magic. That's always wonderful to watch in the log. Yeah. You know what I find is that people that set that stuff up, they release apps like this more frequently. They're like, oh, it's just one feature, but I don't mind pushing the button or I can just push to that branch. And the more that you have to do it manually,
Starting point is 00:20:39 make sure you don't mess up stuff and don't forget to bump the version and you just do it a lot less frequently. And so there's some really cool knock-on effects of that recommendation. I went through a lot of pain to automate testing and release tasks in OctoPrint, which also involved, by the way, flashing physical hardware. And so I built a lot of stuff so that all of that is more or less at least semi-automated because that takes so much work out of every single release.
Starting point is 00:21:07 That's absolutely insane. So yeah, automation, it's great. Yeah, I do have to add. So yeah, there's a couple. I don't maintain that much stuff, but I have to admit that I'm reluctant to bump versions because then I'm like, I got to push it out to PyPI then
Starting point is 00:21:24 and I haven't automated that through GitHub Actions yet. So yeah, I got to get on that stick. So, okay. I'd like to talk about locks, actually not using locks. So this is an article called Handling Concurrency Without Locks from Haki Benita. And it's just sort of a nice, actually, this is intimidated at first by read, like flipping and getting ready to read this article, but
Starting point is 00:21:53 it was really well written. So the idea is it starts with a Django application, and it's a URL shortener, actually, you were just talking about but um there's so there's like an idea that you just sort of walks through it of of the idea is you you have something that creates a unique url but um but that that uniqueness is checked because you keep a database of it and um so you check to make sure it's unique and then you you create it the check it make sure it's unique and then store it in the database but that check has to hit the database, and you've got a read-write thing, and there's a concurrency problem. I know there's lots of ways to get around it,
Starting point is 00:22:31 but it's a reasonable use case to just think about. But there's a lot of places within Django or within web, actually, and within actually all applications where if you're using a database, this concurrency thing might be a problem and you can get around it with locks or other things. But the discussion kind of goes through basically broadening it up a bit and just talks about collision problems
Starting point is 00:22:55 and locking problems in general. And with some nice diagrams, I can't remember where they are on the page, but nice horse. But it's a kind of a good slow walk. Here's some diagrams. And then, okay, going on, continuing on with the article. The idea is like once you know it's unique, you're storing it in the database.
Starting point is 00:23:19 The database is already going to, if you set it up right, it's already going to make sure that he is unique. So instead of making sure you can do it ahead of time and then doing it and making it, then checking for database errors, just assume that it's right and throw it into the database and then watch for any problems. So basically using the database as the uniqueness indicator. And then he talks about how to do that and then how to structure code a little bit to, to deal with those issues and then recover from it gracefully if that happens. And, and then the side effect is you, you're faster because you're not, you're not putting the, the concurrency locks within your, within your application, you're depending on that uniqueness and that
Starting point is 00:24:09 control of the database, which is already fine-tuned to allow multiple access and keep track of that. Just utilize that. So it's a neat reminder to everybody to utilize the tools under you, I guess. Yeah. Good reminder. Yeah. Do you do much database or Django stuff? Me? No. I think I've never so far even touched Django and I try to avoid databases like the plague. Yeah. I'm a huge enthusiast for flat files. Yeah, I don't know. I can do that stuff. They are quite valuable, right?
Starting point is 00:24:49 Yeah. It's just, it takes so much complexity out of the system if you can somehow avoid having to run a database server or an SQLite file somewhere or a Benita file. Yeah, yeah. I've been working on a project, which I'm not ready to talk about yet, but I've been thinking, well, could this just be a bunch of local JSON files? I'll talk about that later.
Starting point is 00:25:11 But yeah, could it just be? Maybe. If it's 20 records or something, maybe just a JSON file is all I need. I mean, sometimes there's no way around it. I've got a project with a very small database, and it's a very tiny text file as we, as, as we started out. But, but the problem always is as long as, as soon as you get more than one user, you have concurrency problems.
Starting point is 00:25:35 Even if the application isn't multi-threaded or multi-process you've, and, and we're running into that so uh switching to it does feel weird to have to switch to a database just for that and you i mean you can get around it also you can put the you can just say hey if i don't already have a database i can put the currency in uh in the server so that um so that that is handled there you can do that but could be sure yeah for sure um my example is a client side like desktop type story so there's only gonna be one user there might be two people hitting the keyboard but it'll be one in one app cool but i also uh just really like thinking about well if you have a
Starting point is 00:26:15 database and you have an orm in what ways could you just leverage that and then instead of like you said well let's you know from threading import import re-entry locks, the R lock, and then take those. And then you do pay the price for every successful time. And if it's one in a thousand or more that you're going to hit that problem, you know, pay that price and that little bit of complexity of catching like the integrity error and then reporting the error instead of reverse. That's great. Yeah. All right. What do we have next? Yeah. Next, we have something that I have not yet had a chance to test out myself, sadly, but which I could have used roughly five or six years ago.
Starting point is 00:26:54 Really hard, but did not have access to then, so I thought maybe I should make a mental note now and share it here so I will remember the next time. That's something like Tatsu exists. And Tatsu is a library with which, sometimes English is hard, you can generate parsers for Python, so Python-based parsers, based on EBNFs. So I think the E was for extended, and BNF is Bakusnava form. So a very structured way to define a grammar of a language of a file format of whatnot. And text, a textual I should add, though, maybe also binary, but that sounds like a lot of pain. And that looks like something like I'm looking for a good example.
Starting point is 00:27:45 Let me quickly. Yeah. So for example, this is a grammar. And then you turn that into a slightly annotated grammar. And in the end, you run this through Tatsu. And then Tatsu spits out something which builds an AST out of your thing that you put into it that is supposed to be parsed. And apparently Tatsu cannot only do that. So it can do on the one hand in this kind of way that we know from the RE module,
Starting point is 00:28:20 from the regular expression module in Python, where you can compile a pattern and then reuse it during the duration of your code. But you can also generate Python code itself out of it so that you can then import it as a module and reuse it and reuse it. Maybe also adjust it, but I don't know how well that works. And apparently it is also compatible to Antler grammars, which is a name I haven't heard since university. So that is nice, I guess, for people who have grammars lying around that are written in Antler, I think version four or something like that. And yeah, so this is really one of these things that I wish I had found sooner when I had a desperate need to generate a parser from an EBNF because writing an EBNF is sometimes
Starting point is 00:28:59 way easier than writing a parser. And yeah, now I have it, but now it's too late. For people who are listening, the EBNF, the grammar file, it looks a little bit like a YAML definition, a tiny bit, a little bit like a little bit of regex, but you basically specify the rules of the language and then you can take that and run with it, right? Yeah. In a way, you basically say you have an expression and that expression consists of this other components and then these components
Starting point is 00:29:30 are defined further down. And so you dig deeper and deeper into the syntax and build up the definition from that basically. Like if you've ever seen one of these JSON grammar railroad diagrams,
Starting point is 00:29:41 it also goes a bit like this, just in textual form yeah once i was teaching a class and so go brain no i just uh i was getting ptsd from uh my language classes in college yeah that's admittedly also where i learned about this stuff but for some reason i yeah back then it was horrible now i kind of like it it's weird. It just makes it so easy to define something. Yeah. And no pressure. And now I see the advantages because it makes it so much easier to define a structured text and stuff that you need to use in machine communication. So if I had had an EBNF or if I had, if I had had that like 10 years ago, I started on OctoPrint, I would have written an EBNF for the, yeah, basically for the G-code stuff that runs between a printer and OctoPrint to communicate over the serial interface.
Starting point is 00:30:33 And then it would have been way easier to pass that the way it is now. I had to do all of this by hand. Yeah. But maybe I can rewrite it with this. We'll see. Yeah. It seems useful if you wanted to create a simple, higher level scripting language that controls your app, right? If, say, you were writing code for scientists in a lab and those scientists were not developers,
Starting point is 00:30:57 but you could say like, okay, you can enter a couple of simple expressions and it'll like move the robot around or it'll like upload the results, or something like that. You could probably build that with this, and that seems neat. And then the other thing that's noteworthy here is this is 3.10 or above. And I'm sure that's because it's the peg parsers match, effectively, the switch statement that's in Python 3.10 that it's using.
Starting point is 00:31:22 ALINA IVANCHENKOVSKAIHARAVANIHALAVANIHALAVANIHALAVANIHALA Also, with regards to data science, I could also imagine this helps maybe with parsing weird data formats that you have in Textual that fall out of some legacy software that is running on some ancient Sun cluster or something that is connected to your measuring devices.
Starting point is 00:31:39 So I could imagine that could also help there. Good idea. Brian, is that it for our items? I think it is. Do you have anything extra also help there. Good idea. Brian, is that it for our items? I think it is. Do you have anything extra? All right. Of course. Of course, I've got some extras.
Starting point is 00:31:51 Let's see. Me too. Let me pull up some real quick. All right. Fantastic. All right. I'll throw mine out. So not here.
Starting point is 00:31:58 In a recent episode, we covered, where was it? It was the- 285? PEP 690. Oh, okay. 285. Thank you. Yes, that's it. So we talked about PEP 690 and lazy imports, and this was recommended by Itmar. This comes out of the Cinder project and other things. Since then, I've had Barry Warsaw, Armand Bravo, and Carl Meyer on TalkPython to discuss this, which was fun. And they've also written this up as a formal blog post.
Starting point is 00:32:26 So people were interested in that and they wanted to just go dive in. I just want to point out that that's a pretty intense dependency graph right there. It's this black cloud of dots all connected and stuff. So there's some really interesting things from Instagram's use of this and whatnot. Very neat.
Starting point is 00:32:41 People can check that out. There was an expedited release of Python 3.11 beta 3 because of an incompatibility with PyTest, Brian. Can you imagine? Yeah. Do you know about this? Yeah, so I do.
Starting point is 00:32:56 I found it amusing. In one of the announcements, it said, apparently PyTest is well used. No, can't be. No way. I think it was a joke, but it made me laugh. Yeah, yeah.
Starting point is 00:33:12 But the fix was no joke. So there's a quick fix that rolled out for people if they want to check that out. And then last thing, I kind of threw out a teaser for this episode saying I just did something completely silly and weird. And I think I might like it. I'm not sure. So for a long, long time, I've used DuckDuckGo, right? And I really think that DuckDuckGo is fantastic
Starting point is 00:33:31 and I may just keep using that. But let me give a little credit here. Daniel Herthome sent us a message and said, you know, this isn't really Python related, but if I know Michael, I bet he will love this ad-free privacy respecting search engine called kagi.com. Have either of you heard of Kagi? I had not. Never. No. And so it's pretty interesting. I went and I listened to, or listen, read, I listened with my eyes. I listened to this
Starting point is 00:34:00 interview, watched this interview. There's an audio version, so I keep stumbling on that. But Vladimir Perlovak is the founder of Kaggy. It was founded in just March, so it's really brand new. It talks a lot about the motivation for creating the search engine. Basically, he says, I think the ad tech, which I think maybe should be called more like surveillance capitalism or something a little more serious. But ad tech, putting all these ads and tracking in front of my kids. I don't want my kids to grow up thinking that just like being completely tracked and having zero privacy is like the way of the world. So there's a pretty interesting conversation here on what they built. But the idea is it's a search engine that is a premium search engine.
Starting point is 00:34:40 So instead of having ads, users have to pay for it. So I'm going to do an experiment for us, Brian. I'm going to live with this for a month and then I'll give you a report on what I think. I think that'd be great. Yeah. Yeah, so check this out. For example, PEP 690 lazy imports.
Starting point is 00:34:54 What happens if we put that up there? So comes up with the PEPs page and check that out, number three. And then probably somewhere a little farther down since it's not in the title is Python Bytes, I would suspect. But like these results are pretty interesting, but check that out. Number three. And then probably somewhere a little farther down, so this is not in the title, is Python Bytes, I would suspect. But these results are pretty interesting. But check this out. So I can come over here, and I can hover over next to one of these.
Starting point is 00:35:12 And it says, oh, this is on this page. This one doesn't have that much information about it. Some of them, let's see. Maybe this one should have it. So before you even visit it, it'll say there's four trackers. It's this rank by traffic. It'll use HTTPS. It's fast or not.
Starting point is 00:35:26 It lands in this category. And you can upvote and downvote things. You can push things up and down. That is a power feature. For example, isn't that cool? You can say W3 schools. I never, ever want you to show up ever again. Exactly.
Starting point is 00:35:37 That was my thought. It's so horrible. They're so good at SEO and they're so bad at writing meaningful, helpful stuff. So you could just, when I got my first W3C school's result, I just did block that. And so you can, for example, go to like the docs on python.org
Starting point is 00:35:55 and say, you know what? That one's higher for me because if I search for Python stuff, I'd kind of want to get the official discussion. The other thing you can do is cool is you can have these lenses. So you're saying, I'm only interested in programming stuff right now. So it takes you to like GitHub and
Starting point is 00:36:09 stuff like that. And then you say, you know what, I'm just actually what I want is just more results. Just basically search GitHub for all of this. And the final thought here that's cool is it de-ranks. So, you know, I showed you like different sites. So here, let's put, let's put something embarrassing for a company that needs to be embarrassed. CNN. So, you know, I showed you like different sites. So here, let's put something embarrassing for a company that needs to be embarrassed. CNN. So if you hover over this, how many block? There's 43 ad detectors on this thing.
Starting point is 00:36:31 43, 43. Here's what they do. They are down-ranking, down-voting, like lowering the SEO rank of things that have tons of ad trackers and things like that. So if you're overwhelmed like this, where it's orange or red, that lowers your rank. So it's like an anti-ad tracker
Starting point is 00:36:51 result surfacer. Anyway, what do you all think? I'm tempted, but I'll let you test it first. Yeah. Give me a month. I didn't think I was going to like it that much. It's pretty nice. So I paid $10 a month, which seems a little high. I think they're getting their results by buying API access to Google and Bing and then resurfacing those results to you in this privacy respecting way. Yeah. Actually, I kind of think it's brilliant and I want to try it too because at first I was like, I don't want to pay for a search, but I know I try to tell my kids
Starting point is 00:37:32 if you're not, if you're not the if you're not paying for it, then you're not the customer, you're the product. So yes,
Starting point is 00:37:39 absolutely. Absolutely. And even if it wasn't for that, that the customization options are just like amazing. Like, I don't know. Yeah, the fact that you can say,
Starting point is 00:37:48 I prefer more of this site, less of that site. Yeah, it is pretty neat. So I really appreciate that Daniel sent this in and I'm going to live with it for a month and I will let you know, but the maps doesn't work very well. They don't work very well, but you can always just go to somewhere else.
Starting point is 00:38:04 A final thought, the whole reason I switched to Vivaldi over Firefox Maps doesn't work very well. They don't work very well. But, you know, you can always just go to somewhere else. A final thought. The whole reason I switched to Vivaldi over Firefox is I didn't want to bring other things like ad block. And you have ad blocking, tracker blocking and stuff there. But then you have to get extensions. And then those extensions send their data back. And then sometimes they'll like, well, these ads pay to be let through our ad blocker. And there's just like still kind of a tracking level. So with Vivaldi, you know, you get like total blocking without third party things. So with this, you kind of get a search engine that is like a good match to that.
Starting point is 00:38:35 So anyway, I think it's cool. And anyway, I just wanted to give it a quick shout out here because it seems fun. Funny thing. I think that's it for everything. Okay. it seems fun um uh funny and i think that's it for everything okay funny thing i in this the chat um uh ecov or eki eki vu uh says i use a use a custom firefox extension to block w3 schools that's interesting i didn't know that existed but yes i installed that as well and i eki vu that is an absolutely worthwhile thing to do i totally agree so i'm with you i used to use that as well and i ekivu that is an absolutely worthwhile thing to do i totally agree
Starting point is 00:39:05 so i'm with you i used to use that as well i also use something that like i'm it was it was called i'm okay with cookies and it would automatically accept all cookie disclaimers you know the cookie warnings it would just say okay and there's almost none of them and then i just block them on my network so it doesn't matter if i accept them um well let's jump to gina's extra stuff it's only some small stuff okay so one thing uh can you share my thank you uh so one thing is something that i mentioned before that i went through a lot of pain to automate a bunch of stuff about the testing and octoprint which involves some raspberry pi cluster here that I can flash via a Python tool and stuff like this. And I also needed voltage monitoring for this Raspberry Pi cluster, because I don't know
Starting point is 00:39:52 how familiar you are with Raspberry Pis, but they can be a bit, let's say, selective about what power supplies they like, and they start browning out easily and stuff. So power monitoring is very helpful. And there are these cheap-ish 30, 40 bucks USB power and voltage monitoring dongles that you can just plug between two USB cables and then it will measure everything. And they also come with Bluetooth. And I found a tool that can log the data from this Bluetooth interface via PyBlueZ. It's written in Python from these UM24C, UM25C, or UM34C dongles in order to allow you to track the voltage and power over a course of, yeah, whatever.
Starting point is 00:40:41 So I have to set up, log this out, throw that into an influx db throw it up on a grapana dashboard and get warnings when something underpowers and that is great for sleeping in peace at night about the test cluster situation and the other thing is something that reached me actually just last night in the shape of a tweet and that is that there is now another Node.js PyPI distribution that you have a way to ensure that everything that you need in order to build that web UI is also there and can also maybe make this part of a build process that you build into your setup pie or something like this as well. So that was a really nice thing to discover. Still considered alpha, but I tried it briefly this morning and really great that's cool that's really cool that is fantastic yeah that's super interesting um you could pair that with py script
Starting point is 00:41:52 and have it do a little electron thing and then just run that run python write python for your little web app that runs on the front end yeah or if Or if you do something like, so for example, I still use Cypress.js for end-to-end testing in OctoPrint, which means that I now need a Node.js environment and a Python environment in order to have all developer dependencies together. This would solve this problem, because then I could just make this part. Maybe I could even fire it up as part of the PyTest suite.
Starting point is 00:42:22 I don't know. But it would be interesting, certainly, to test that out. Definitely. Very cool. Brian, it sounds like a PyTest fixture needs to be put in place. If you want to do that, that would be great. I'll put it on my to-do list right after 3D printing.
Starting point is 00:42:40 Yeah, I know the problem. Since we're running a little long, I'm going to skip my extras till next week. So let's maybe jump to something funny. Nathan Ashbagger, it's a tweet. And it's like, pretend you're getting a call and the phone says, hey, I'm from somewhere. We built the first AI-driven sales platform
Starting point is 00:43:04 and I wanted to talk to you about your sales needs. He says, wait, are you an AI? No. Well, we can both appreciate the irony here, right? So I don't know if this was real or not, but it just made me laugh. That was funny. I love it. Yeah.
Starting point is 00:43:22 Shouldn't they be having their AI call you with their AI platform? It's subtle. Yeah. Okay. So let's go. Maybe love it. Yeah. Shouldn't they be having their AI call you with their AI platform? It's subtle. Yeah. Okay. So let's go. Maybe yours is funnier. Let's go to yours, Rykel. Well, mine is a collection of jokes.
Starting point is 00:43:35 So maybe one of them will be. This comes to us from Brian Skin, who, as I said, has been on the show before. Thank you, Brian. And these are, you know how like you've got the Mars Rover badge and you've got the Arctic Volt badges on GitHub. These are ones that were considered and potentially rejected. Okay. Okay. So let's see what's over here. These are, they were considered. I feel like David Letterman with his, his like ad stuff. Okay. So one of them is the vital contributor over 100 issue comments consisting of just plus ones or thumbs up emoji.
Starting point is 00:44:06 There's the Sith Lord who wiped out someone else's commit by force pushing to the main branch. You could have that badge. I have that. You have the procrastinator badge. Do you? You could be the procrastinator. Create a repository with a single init commit with just the readme.md and never touch it for five years. My personal favorite is the secret Santa. Accidentally commit a secret API key to a
Starting point is 00:44:31 public repository. That's good. We have the monkey rich. Yeah. The monkey rich is, makes a commit directly to the main branch that breaks the build. This is fine. It has a dog in a room that's full of fire. We've all seen this meme in some form or other, I'm sure. This is fine. Over 1,000 open issues on a public repository that you own. Ouch. Fine, let's wrap
Starting point is 00:44:58 it up with the last one. Works on my machine. The works on my machine certification suggests user error in at least 10 issue threads without attempting to reproduce in user runtime environments. All right. These are pretty good. That would be hard
Starting point is 00:45:09 to automatically detect though, right? It would. Yeah. The last one. Some of these you gotta self-assign, I think. Yeah, yeah, yeah. Yeah.
Starting point is 00:45:17 But yeah, I don't know if you saw that GitHub recently actually rolled out more achievements that you can now try to hunt. So it's not anymore just the Arctic stuff, but there's now stuff like Merch Shark and PR Shark, I think they called it.
Starting point is 00:45:31 And so there are several. They are hidden. You have to figure out. Yeah, I think last Thursday or so they rolled it out, which was also when this repo, I think, popped up or at least popped up I also it also went past me on my Twitter feed and I immediately
Starting point is 00:45:48 shared it around with people because yeah it's yeah it was good it's cute it's kind of sad that some of them
Starting point is 00:45:54 didn't make the cut didn't make the cut I think so for sure yeah this is fine people definitely definitely need that
Starting point is 00:46:00 this is fine absolutely yeah hi Brian is that it for us I think it is. It was a fun episode. Thank you, Michael.
Starting point is 00:46:07 Thank you, Gina. Absolutely. Thank you. Yep. Bye, everyone. Thanks for being here, Gina. Thank you for having me. Bye.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.