Python Bytes - #169 Jupyter Notebooks natively on your iPad

Episode Date: February 19, 2020

Topics covered in this episode: D-Tale Carnets BeeWare Podium pytest-mock-resources How James Bennet is testing in 2020 Python and PyQt: Building a GUI Desktop Calculator Extras Joke See the ful...l show notes for this episode on the website at pythonbytes.fm/169

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 169, recorded February 12th, 2020. I'm Michael Kennedy. And I am Brian Ocken. And this episode is brought to you by Datadog. Check them out over at pythonbytes.fm slash datadog. Get a cool t-shirt for just giving a little trial, installing them and checking it out. Brian, I love a good story.
Starting point is 00:00:24 You got a tale to tell us? Well, yeah, I've got a detail. So this was a suggestion on Twitter by, oh gosh, David Douglas something? Maybe David Douglas Smith? How do you think you pronounce that? David Douglas Smith. Yeah. That's what I'm going with.
Starting point is 00:00:40 If you can trust the Twitter name to be the real name. Yeah, right. This is a little tool, which is pretty darn cool. Detail. This is a quote from their site. A combination of a Flask backend and a React frontend to bring you an easy way to view and analyze
Starting point is 00:00:55 Pandas data structures. It integrates seamlessly with IPython notebooks and Python IPython terminals. Currently, this tool supports such Pandas objects as DataFrame, Series, MultiIndex, DateTimeIndex, and RangeIndex. Okay, so there's a live demo linked from the README, and you can go to that, and there's a little arrow on the top left,
Starting point is 00:01:17 so you end up with something that looks like a spreadsheet, whole thing. But in the demo, if you click on the little play button, there's a whole bunch of different tools that pop up one of them like even just the describe button if you click that you can select different columns and it gives you statistics and in a little graph of what what data is in there and top 100 values that are in there that That's even cool enough, but that's just a start. This tool also gives you, you can filter your data, do correlations, charts, heat maps, just all looking at a data frame through this user interface.
Starting point is 00:01:54 It's pretty cool. Yeah, that's super cool. When I first saw this, I wasn't sure what to make of it, and playing with the live demo really is the way to check it out, isn't it? Yeah, I mean, after playing at the demo a little bit and then going back to the readme with all of the information, there's just so much that you can do with this thing. And it's all open source so you can
Starting point is 00:02:12 run it on your own servers or whatever. But it's cool. I like the idea of having a live demo linkable. Yeah, I do too. It makes it real and it's a really cool, smooth interactive framework for visualizing data. I like it a lot. I really, I think it's like if I did more with Panda DataFrames, I'd be all over this.
Starting point is 00:02:29 Yeah. Cool, cool. Speaking of the data science side of things, there's a pretty cool project that just came out called Carnets. Have you heard this? Not until you listed it, but I'm pretty excited. Oh, man, it's pretty awesome. I actually learned about this at PyCascades. We were hanging out there with some folks, and somebody sent this in to me over email and said,
Starting point is 00:02:53 hey, check this out or over Twitter or something like that. And yeah, everyone was uniformly impressed and thought this was quite cool. So you probably heard of Pythonista. And Pythonista is not a description of a person who likes Python, but Pythonta being the app in the app store that is kind lets you do like automation and stuff with python on your ios device okay okay so what was cool about that is like you can write and run python on your iphone or on your ipad natively which is pretty awesome this is kind of like that but in that it runs python natively. But this is Jupyter Notebooks on your phone, or maybe more importantly, on your tablet, like on your iPad. Yeah, this is pretty slick.
Starting point is 00:03:32 I can't wait to try this out. Yeah, and it's super, super smooth. So what's, you know, obviously these days there's options for running and writing Python through your iPad, if like that, if that differentiation makes sense. We can use Visual Studio Code online, which will just basically put the front end into a web browser and then it runs somewhere on Linux and Azure,
Starting point is 00:03:57 or there's some other ones like Coder.com and whatnot. But this is no internet required running Jupyter notebooks locally. And it has built-in IPI packages, numpy, matplotlib, scipy, and pandas, pandas, pandas, already installed. So you don't have to install them or anything. So it's not just, oh, here's a thing you can run Python. Like there's even some of these C-based packages that you might need already installed, which is great.
Starting point is 00:04:24 Yeah, it really looks really clean too. Yeah, for sure. And it also has file sharing ability. So you could like share your stuff through iCloud, right? So you save your notebooks there, edit them somewhere else, pick them back up again over there. You can import IPY&B files or whatever the Jupyter extension is. Yeah, so it's really quite neat and it
Starting point is 00:04:46 looks like a proper jupyter app running over there i think it's great i'm impressed it also extends the keyboard on ipad to give you a couple of actions some hotkeys or like sort of i guess like the mac touch bar sort of that's pretty. One different thing from Pythonista is Pythonista, I believe you have to pay for on the app store. This one is open source and free. So just go click install and you have it. And you can pip install stuff. I don't even know how that works.
Starting point is 00:05:15 Yeah. It's amazing. It's awesome. There's a restriction on the pip install stuff. So with Jupyter, you can say percent pip install a thing or whatever, issue that to the shell. But this one, you can do that as long as the thing you're pip installing is pure Python.
Starting point is 00:05:30 It doesn't have like a C compiler or something like that in your phone. Well, that makes sense. Yeah, yeah. Isn't this cool though? Yeah, it's very neat. I got to try this out. Yeah, I definitely want to put it on my iPad and check it out. And it has a separate dedicated iPad app that's slightly different,
Starting point is 00:05:43 which is nice. Honestly, like a lot of times you can kind of get away with the both the same app or it's not really that big of a difference but this is the kind of thing where it's most relevant on ipad or like a larger device and then it just happens to also work on the phone as the way i would see it i wouldn't really want to develop on my phone i don't know doesn't seem great right harder to hook an external keyboard to your phone and whatnot as opposed to an ipad but yeah this is really cool people should check this out and it's open source people can go download it and play with it and whatnot speaking of really cool datadog's pretty cool they are doing really good stuff supporting the show as
Starting point is 00:06:17 they have been for a long time so they're a cloud scale monitoring platform that unifies metrics logs and traces if you've ever wondered what's going on in your app, you know, you can watch one log or another or look at the performance of one part or another, but it's hard to put that all together in an overall request. Well, Datadog's what you want to put all those pieces together. You can trace requests across service boundaries and that sort of stuff. And they're tracing client auto instruments, popular frameworks like Django, AsyncIO, and Flask. So you can quickly see the health and performance of your python app get started today with a 14-day free trial and a complimentary free t-shirt with a cute little dog on it over at pythonbytes.fm slash datadog wonderful thanks datadog yeah thank you datadog brian you spent
Starting point is 00:07:00 some time on a podium not long long ago didn't you? Yeah, just this last Sunday. Or I mean like, you know, a Sunday ago, depending on time travel. So, yes. And this actually came from PyCascades. I got this suggestion from Katie McLaughlin. I did my talk using, there's a lot of people that use HTML5 based presentation frameworks.
Starting point is 00:07:20 And that's what I was using. I was using remark.js. I chose it because I like Markdown, and so I can write my slides in Markdown and then present it. But there was difficulty. So in order to get this all to work, maybe some people know some other secrets to it, but I had to go in a little early
Starting point is 00:07:38 and then go into the extended display mode so that I can drag the the version of the presentation that's going to be on the display drag that web browser window into the other window that's on the display and then maximize it but I'm not in front of it so I gotta like use the mouse to try to go to the maximize button and then on the other my laptop display I have my presenter notes and timer and stuff. And it actually worked really good, but that setup was a little bit of a pain. And so Katie McLaughlin told me about Podium, which is a Beware application. And I got to tell
Starting point is 00:08:16 you, I love the Beware stuff, but they know it also is that the documentation, they need more help with documentation because there's not much there. But this is cool. It's a native application. It currently supports, there's builds for Linux and for Mac OS, which, bummer for Windows people, but it works for me for Mac OS. And since it's not a browser thing, it's a native app. It can have control over going to different screens and stuff. So when you hit, like, Command-P, it just goes into presentation mode. You've got your notes on your computer and the presentation on the extended one.
Starting point is 00:08:55 It's automatic. You don't have to fight it. They've also simplified the syntax of the markdown. So remark.js has a bunch of boilerplate HTML stuff on the top and bottom, but the podium, beware podium, has removed that. So your markdown file with all your slide content is just content. It's not a bunch of other stuff. So I'm really happy about this.
Starting point is 00:09:18 Yeah, this looks nice. It's cool to not see it all just a bunch of JavaScript, right? It's cool to have a little bit more of a native app that can do more than just something in your browser. Yeah. So this isn't specifically a Python related topic, but in watching other people's slides, I know a lot of people are using remark because I recognize it when people do it. So I'm hoping this might help other people too. Yeah, absolutely. If anyone wants to help out with the documentation, a little giphy or video or something of what this looks like and what it does would go a long way. Just like, you know,
Starting point is 00:09:49 the D type detail that you had before would be quite cool. So, or the car nets, right? Just the BeWare stuff is cool, but it's always, you know, it's just text usually talking about something visual. So that would be great. Now, this one, I feel like this topic is cheating on you, Brian. I'm going to cover a PyTest thing. I love it. So this is PyTest mock resources. So this comes from Daniel Carden and his company recently open sourced some of their internal PyTest tools to help them do more PyTest goodness. And I think it's cool that the team at the company put the effort into open source this project. So basically, this is something to help out with testing external resources. Now, testing external resources is one of the tricky, challenging bits
Starting point is 00:10:38 of testing code, right? I'm going to call the credit card API, but I don't really want to charge it. I just want to simulate calling it and get the response back. Or I'm going to call the credit card API, but I don't really want to charge it. I just want to simulate calling it and get the response back. Or I'm going to query the database and I don't really want to hit the database. I just want to simulate getting this data back. And that's already solved with mocks and patching and that kind of stuff, right? But this is a way that you can test if you do need to actually get some data back from the database or from some other service and just go like i really need it to give me this data back to see that the part that actually processes the query that is working correctly so basically its job is to set up docker containers
Starting point is 00:11:19 and manage the life cycle of those around your tests So it'll fire up a little Postgres server or it'll fire up a MongoDB server inside of a Docker instance, get it set up for your tests, let your tests query against it, and then throw it away. Sometimes it makes sense to have tests that are abstracting away or hiding
Starting point is 00:11:37 or patching or mocking the dependencies, like we described, that probably makes sense most of the time, but there's a little slice where it really needs to interact with those resources, and you might want to test that. Like, did my SQL alchemy class get out of shape with the way the database thinks it is?
Starting point is 00:11:55 Well, I can mock that out all day, but the only way I'm going to find out that doesn't work is try to do a query and have the relational database throw an exception and say, this column that you're querying for doesn't exist, and then I'll find out, right? So I think it's cool for testing that level. Oh, that's neat.
Starting point is 00:12:10 What's your take on this? It's not a domain that I'm having to utilize, but I love that people that solve a problem are willing, even in a company setting, are willing to open source it to let other people benefit as well. Yeah, pretty cool. I can definitely see using this around the websites and stuff like that. There's certain parts where it really would be easier if it just would generate the sitemap.xml
Starting point is 00:12:37 correctly so then I can use that to poke back at some of the elements and whatnot. It seems pretty interesting. I haven't used it for anything yet, but it looks cool. Yeah, nice. Let's keep rolling and testing, huh? Yeah, I guess we got two testing things in a row. This is an article. I wrote the title as How James Bennett is Testing in 2020.
Starting point is 00:12:55 The actual article title is How I'm Testing in 2020, but it isn't How I'm Testing, so it's James Bennett because it's his article. So anyway, he wrote an article called, I forget what it's called, but it's an article about testing Django applications in 2018, and so he's following it up again to see what changed. Sounds like he's testing more things than just Django, but still is. I'm going to go through a few of these.
Starting point is 00:13:23 Still using unit test over pytest, and I respect that. There's a lot of people that just think in the XUnit style and for some reason have trouble thinking in PyTest, and that's fine. We can both coexist. He's using Tox to be able to test over multiple Django and Python versions and using a Tox Travis plugin to aid the Travis side of that, which is cool. I like Tox a lot. I use it almost every day. We've talked
Starting point is 00:13:52 about PyENV before for local Python installation management, and so he's using that. And actually, I think we talked about this the other, not too long ago, that if you're using PyENV, there is a PyENV-virtualenv plugin to help you with virtual environments. I'm not using PyENV, but that's neat. Yeah, yeah, yeah, very cool. And since you can't use PyTest, well, he does use PyTest sometimes, but he also gave a list of his run tests script to just run everything. That's especially useful. You can have multiple. I like the idea of this anyway. You can have multiple of these for, let's say you've got a smoke test or suite or different suites that run on Jenkins
Starting point is 00:14:39 server or some other or Travis server. Being able to have one entry point is a good idea. Using coverage also, and he talks about some of his extra tools. It's not just functional tests, but things like including Black and IceWord and Flakate. And I just appreciate people being very open about their testing workflow. I think more people just
Starting point is 00:15:00 write, and really any workflow, I think it's interesting to find out what people are doing for different parts of their workflows yeah i find this interesting as well it's kind of not quite a confessional but like look you're gonna hear all these new awesome ways of doing things are you gonna hear that you should use this and not that or you have to do it this way here's what's working for me really in a nice practical way and i. Yeah, it's not like this is the best. It's just, it's working for me.
Starting point is 00:15:27 This is what I'm doing. Yeah, and there's some cool little extra commands like cleaning up a PyCache files and set up, install local files and pip upgrade. That stuff's nice. And building that as talks commands, that's something that I learned, I picked up from somebody, I can't remember who but i'm like oh yeah
Starting point is 00:15:45 you don't actually have to run do a complete thing you can just have some of your utility stuff within uh within talks that's nice absolutely have we talked about guis yet i don't know probably not yeah there's actually some uh interesting news about remy and some people jumping in and contributing to that that i've seen flying by on twitter so that's super cool but i want to talk about qt uh pronounced cute so interesting project here this is a i want to talk sort of riff on i guess is the right way to put a article by leo danis ramos over at real python.com and over there there's an article about python and pi cuteute building a GUI desktop calculator. So if you're interested in getting into Qt, this is a really nice summary,
Starting point is 00:16:31 not too long, you know, shorter than a quick little blog post, but longer than a little quick little blog post, but shorter than a whole book, right? But you know, like, I think it's a good level that they've got going on over there. So I'm just going to talk about a couple of interesting takeaways and basically the elements of a Qt application. So if you're going to build them up, so the Qt apps are made up of three or four different big ideas or whatever. One of them are widgets, right? So if you're going to work with Qt, it's basically a wrapper around the C++ API. And being that a lot of things are object oriented and whatnot. So if you work with a widget, you derive from QWidget or use something that's already written and driven from QWidget,
Starting point is 00:17:13 which are like buttons, text boxes, and so on. And a lot of examples you see will like take those widgets and put them on the screen and say, this button goes at this X, Y location, and this thing goes there. But the other thing that's really interesting there are layout managers. So there's all these different kinds of layout managers that you can use. So you could put in something, let me pull up a quick little example. So you could put in the elements and it has like a horizontal layout where stuff goes left to right to right based on the size of it. Or you can have a vertical one or you can have a grid one,
Starting point is 00:17:49 all these different layout managers you can employ to figure out how it will automatically adjust its size as the elements are rearranged or the size of the windows change and whatnot. So that's pretty cool. We got main windows, of course, which is like the essence of your app, right? You're gonna create a main window and put your layout manager in it and then load it with widgets and of course
Starting point is 00:18:10 you've got an app queue application for a cute app and that's kind of like the essence and then finally to bring it all together there's signals and slots which are kind of like events i guess or callbacks so all the all widgets, like buttons and whatnot, have these event catchers from the GUI system of your OS, and then they'll fire off events like, hey, somebody clicked me, hey, somebody typed in me, and things like that. So, yeah, it's just a quick way to get started with Qt
Starting point is 00:18:38 that people might want to check out. I think they've done a really good job. It's pretty cool. The Qt demos and tutorials, there are many around, but having it all just in one single page is pretty neat. Exactly. I feel like there's a lot of stuff out there, but it's all kind of hit and miss.
Starting point is 00:18:57 I don't feel like I quite have the whole story, and so that's why I wanted to bring this up because Dan and crew, Leo, Danis, they're doing a good job on this. Now, one caveat I do want to throw out there before you spend a week getting this all up and running and find out stuff about it. Either you need to have a lot of money to work on this or you need to have it be open source or internal, not distributed projects. They can be used at your company, company i believe but they have to be not distributed i think that's the important thing oh because of the cute licensing the cute licensing is it's like dual license either gpl or lgpl or it's commercial and i'm pretty sure these are
Starting point is 00:19:37 commercial projects you have to have a commercial license and the commercial license is five thousand five hundred dollars per year per developer. Okay. That's a lot. To me, that feels like a lot of money for a GUI framework. Yeah. Right? When I could go use Java, I could use C++, I could use Windows Forms from.NET. There's like a bunch of options that are solid. I don't know.
Starting point is 00:19:59 It just, it seems... All of those options sounded horrible to me, though. I know. Well... You just listed. I know. I'm with you but uh it's not like you pay five thousand dollars once or you pay five hundred dollars once it's as long as you care to own this application it's five thousand five hundred a year per developer and that's just that's a lot so anyway it's not to say don't do it right
Starting point is 00:20:22 if your company is like hey we really want to go with this technology, we want to go that way, that makes sense and we can totally justify it. But it's not something I, if I was like, hey, I'd like to create a little app, maybe I'll create like a desktop version of the TalkPython player app that does cool like offline support and stuff. Maybe I'll use Qt. Like, no, I wouldn't use Qt. Okay.
Starting point is 00:20:41 Right? I mean, because I'm not going to pay you know five ten thousand dollars a year before that because it's just i don't know that's just the way it is anyway i always want to throw that caveat out there because it's not just like oh you got to pay a little bit for it's like you got to consider that that's a non-trivial amount of money to use it that way so i just want to throw that out there well yeah and if we've gotten this story wrong please somebody tell us yep i did poke around their site a lot and i was looking for the exact quote but basically if you're going to release it commercially i believe that this is the case but yeah if we got it wrong someone tell us i believe you i just don't want to believe you
Starting point is 00:21:13 i know i know all right cool well yeah if somebody has more details than that on the license but that is i spent probably 30 minutes trying to figure this out to make sure i got it right and that's what i took away from the what's on their website. Okay. What about the extra stuff, the things that we're not quite covering but we're still covering? What do you got? Well, we did mention PyCascades a couple times. As of this recording, they don't have the individual talks chopped up into videos yet.
Starting point is 00:21:41 I don't know if they're going to, but the live stream video of day one and day two, so everybody's talk, if you can kind of fast forward through it, is available. That was available right away, actually. They were pretty fast about it, which is pretty cool. We're leaving a link to that. And I also just want to do a huge shout out and thank you to all of the volunteers for PyCascades. It was a really fun event and I appreciate everybody's time. Yeah, PyCascades was great and it was really fun to be there and meet all the folks that I did. I had a moment of panic and anxiety shortly before my talk. And back in the green room, Nita Zakarenko noticed and probably because I said, oh my God, I'm freaking out. And she helped me through to
Starting point is 00:22:26 calm down and before the talk. And I really appreciate that. So I wanted to thank Nina on the show. How about you? Any extras? Just a couple of quick things. I did a live webcast that I talked about like a month ago on the show for Python for.NET developers. A bunch of people signed up. That was awesome. That happened yesterday. And so now the recording is available. So I'll link to that in the show notes. People can go listen to that or share it with their friends and whatnot, colleagues. And also, I've talked about this before, I'm pretty sure, but I sent out a message and a whole bunch of people were like, oh, really?
Starting point is 00:23:00 So I just want to throw it out that if you go to the TalkPython training site and get one of our apps, those apps, you can download them for free. And when you open up and log in, it'll give you a list of our free courses and you just tap them. You can take a bunch free at the moment, probably more in the future of our free courses on your iPad or Android tablet or whatever it is you want to take them on. So check that out if that sounds cool to you. When you first released this, I didn't quite get the value, but I really appreciate the mobile app because for me, bookmarking stuff on a, I bookmark stuff on my desktop all the time, but bookmarking stuff on my, on my mobile phone, I don't really do that. So keeping track of which courses I've been partway through, it's really handy to just have this right in the app. I like it.
Starting point is 00:23:46 Awesome. Yeah, thanks. That's awesome. And also, there's a bunch of restrictions, especially around iOS. Like, it won't autoplay the next video, so you've constantly got to be going, like, play, play, play in the mobile app,
Starting point is 00:24:00 and you can't quite full screen it as much because there's, like, a little, you know, the address bar on some browsers. Anyway, yeah, thank you for that. That's awesome. So the mobile app can't autoplay? No, the mobile app and you can't quite full screen it as much because there's like a little you know the address bar on some browsers anyway yeah thank you for that it's awesome what so that the mobile app can't auto no the mobile app does but if if it was alternative were to be to watch it with safari or chrome or something on ios it's kind of restricted yeah right yeah okay cool how about uh how about a joke i would love a joke all right i'll take one you take one because i couldn't decide i had three and i chose two they're both short so so I figured that'll round it out. So here you go.
Starting point is 00:24:28 Did you know that programmers, they sometimes get confused about what holidays are? No. They do, because especially Halloween and Christmas. Okay. There was not a real good reason people couldn't figure it out until someone realized that Oct 31 is des 25 this is so wacky that that's true that's and plus it's funny yeah all right what's the other one okay let me read it first okay speed dating is useless five minutes is not enough to properly
Starting point is 00:24:59 explain the benefits of the unix philosophy it might not be enough to explain the Unix philosophy, but if that's the start to a date, it might still be effective in communicating what it's got to. Oh, yeah. Oh, boy. All right, well, that's pretty funny. So thanks again, as always.
Starting point is 00:25:17 Great to be here with you. Thank you. Bye, everyone. Bye. Thank you for listening to Python Bytes. Follow the show on Twitter via at Python Bytes. That's Python Bytes as in B-Y-T-E-S. And get the full show notes at PythonBytes.fm. If you have a news item you want featured, just visit PythonBytes.fm and send it our way. We're always on the lookout for sharing
Starting point is 00:25:36 something cool. On behalf of myself and Brian Ocken, this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

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