« Return to show page
Transcript for Episode #181:
It's time to interrogate your Python code
10:00 code with a simple test name. But the thing he's asserting on doesn't really make sense. And the reason if you don't know what's going on under the hood. And the reason is, because tests often are testing for a side effect of an action. If you're testing the output of a function, that's obvious you, it's kind of obvious over the five pass in functional tests of view, passing of certain parameters, and you get a certain expected output you can assert against that. But what about actions that have side effects and you need to test for those that might need some more explanation, and rewrites This is quite common in testing very often, you can't ask questions directly. Instead, you verify certain properties that prove that your code is achieving its goals, by checking side effects and stuff like that. It's a short little article, and I was just happy to have some that expressed of why you should document and it might be you that it's confused in the future. And then it ties back into the interrogate, because so I was just thinking when I was reading about interrogate, and like, Oh, awesome, I really want to put something in place to just make sure all my tests have docstrings. And he lists in Oracle, the exact command line that you need to make sure that all that just text, make sure that your tests have doc strings, and nothing else. So is it cool? Yeah, it looks really nice. And I can see how this would lead you down to finding a library that searches for or evaluates these. Yeah, so the test example he has here is testing that the hash, like creating the same object instance of a class twice, and taking the hash and making sure that those are not the same, because he's trying to test that attars is not implementing false on the class or something to that effect, right. So like, what the heck is going on with this? Like, why would you check the hash of a thing is not equal to the hash of a thing. But it's looking like you said, for this sort of, like, hidden layer that's operating below it. Right. Yeah. And then also, my reasoning, and I think he brings it up is that that, often, when you're looking at a test, it's because you really got to get a release out and one of the tests is failing. So you got to go look at the test and figure out what it's testing for and why it's failing. And if you're don't have it clear why the test is important, you run the risk of the person at the time going well, I don't even understand what this test does. Maybe some important is commented out, commented out, passes, don't want to see eyes, good will go home.
12:34 I don't do that. But I've heard it done before. Of course, I would never do anything like that. But I could imagine that it has been done. Now I actually have I have some experiences in the past where like, there was some project and had like a beautiful set of tests, and then and ci and stuff. And it wasn't working on anymore. And whoever took it over. It's like, Oh, those tests were really annoying. So I turned them off. Like, Oh, my gosh, those were there for a reason. What just happened? So at least like if, if this gives you some description about what's up, that would be good. Is there anything where like pi test will show the doc string as part of the error report? I think there was a somebody that wrote a tool that would do, I don't remember the name of it. I remember running across a plugin that would pop out the doc string for failed tests, which would be pretty cool. Yeah, that would be pretty cool. Hopefully, the person evaluating the test failures has access to the code, they can go. Yeah, I'm thinking more of like a CI CD. Like you're not really you don't have it, like loaded up. Right there. Right? You're just like, Oh, I'm cruising on GitHub, checking a PR, what the heck is this? Yeah, I actually wrote a was an internal thing. But a quick plug in for pi test that would just before every test function, print out the test name and print out the the doc string. If we can look at the logs. It's there. Yeah, that's cool. Very nice. Also, cool data dog. So this episode is brought to you by data dog. And let me ask you a question. Do you have an app in production that's slower than you like its performance all over the place? Maybe sometimes fast, sometimes slow? Here's the important question. Do you know why it does that with data dog, you will, you could troubleshoot your app performance. With their end to end tracing, check out their detailed flame graphs to find bottlenecks and latency and that finicky app of yours. be the hero that got your app back on track at your company. Get started with a free trial at Python, bicep, FM slash data dog and get a cool little t shirt as well. Alright, so your theme is so far, it's been pretty clear. Next one of mine, we're going to talk about a project called hollow ww is be heard of hollow is not I'm sure you've heard of Sai pi, and those types of things. So there's kind of a grouping of other projects right under that general banner with like NumPy, matplotlib and whatnot. But hollow is is kind of like that, for data processing and visualization. In one of its features acts very much like streamlet but in a more general, probably a little more work to set up and
15:00 Right got to work more in its framework, but in a very similar way to what streema is doing as well. So it's a coordinated Hello visits a coordinated effort to make browser based data visualization and Python easier to use, easier to learn and more powerful. So, yeah, so what does it do? So it has a bunch of tools that make it easier to apply Python plotting libraries to your data, bunch of tutorials, conda, like metapackage, that when you you know, and conda install all of his, it actually installs a whole bunch of things I'll tell you about a second even has some sample data set. So you can like go through the tutorials and actually get the outcome, right. So it's made up of a bunch of different things, one called panel, and that one makes creating apps and dashboards for your plots, using any of the supported plotting libraries, which is pretty awesome. It has hv plot to quickly generate interactive plots as hollow views to make your data, instantly visualizable, geo views for visualizing geographic data, data shader for rendering huge data sets puram for creating user configurable objects, config stuff, and then color set, or like color maps. So yeah, you want to have like nice colors that flow together for your plot. And panel is the main thing that I was thinking of that lets you create these single page apps around interactive sliders and drop downs, render graphs and other other kind of stuff. And yeah, very cool project as well. Yeah, I'm just looking at the data shader. And then like some really pretty pictures, because the quick examples of overlaying Oh, yeah, data plots over the map of the US things like that. Cool. Yeah. Or, you know, you can plot attractors with 10 million points each. Oh, is that all?
16:50 And these graphs, I mean, these the resulting pictures are I don't know what they're like 400 by 400 pixels, or smaller as i get i came from 10 million points, or here's the United States, plotting each person in the United States where they're physically located from the 2010. Census. So 300 million points of data overlaid on to the United States map. Yeah, it's like, like a son really is pretty interesting. Actually. I think I can see you over there, Brian, here on the left.
17:21 You are too. That's right. Awesome. Anyway, yeah. So this is a cool project. There's a whole bunch, a bunch of different little libraries that are pretty neat. So if you want to try to visualize your data, and we'll come back and talk some more about both these projects towards the end of the show, as well, but bunch of cool libraries, like all brought together under this hollow this project to make them work together.
17:41 I want you guys next, I have another command line tool. So this was by Oh, gosh, Rosario, and he wrote a little blog post about it. But it's a there's a project called a live progress. And it's a progress bar for Python. And it's really cool. So it is pretty cool command line interface, a progress bar. So often, I mean, like, even, like pi test has added progress bars for, you know, watching your test finish and things like that. And it's nice to have progress bars, it gives you good feedback, and whatnot. But there, there's limits to what you can do, except for this seems unlimited. It's got a whole bunch of different animations, and spinners and things you can combine to make a more entertaining progress bar. So it's fun. Yeah, these are really nice. And you know, these little touches, they probably don't seem like much, but they can definitely make your app feel more professional and more polished, rather than just, you know, the answer seven, or like, whatever we're done. Yeah, some of the like, what was it, Pip and I don't use it, but I appreciated some of the fun, Command Line Interface stuff that they've added to it. And I think adding some fun to a tool is nice. One of the things I wanted to comment on also was just the about the the repo itself. So the code is up on GitHub. And the readme has some nice thing features I wanted to call out. So the the animated pictures of what it does is a nice touch. We've said this before, we love things like this, I liked that there was a to do list. So it encourages having a short to do list encourages contributions. And I think even listing things I've gotten that I've gotten done recently, so that people that might not know about those features, don't try to go work on them. And then just a short list of things you'd like to have done. And then has an interesting facts section, which is kind of cool. The code is in a functional style uses closures in generators. So I mean, actually, a lot of times I'll look at code not as an example of how to do something. So if somebody's proud of like their use of generators, maybe it's worth checking out if you try known generators. And then another feature that I'm definitely going to pick up for things that I work on is changelog highlights. So not the entire change log in the readme but just one or two lines of semi colon separated features per version.
22:46 in order to talk about graphical stuff. Yeah. So Brian, really quick on this next one, click on the app for it, because it's take just a second to load up. So that's information items, I want to tell you about a couple of things, then we'll get here as well. First, one of the features that I really like about Visual Studio code, I haven't really used because I don't use Visual Studio code like a meaningful way. I use it all the time for like little bits of editing, but not if I'm like doing real projects, I probably use PI charm. But it has, it has live share, which is a pretty killer feature. So you can say I would like to share my coding environment with someone else who's going to like look over my shoulder, do pair programming, just code review, whatever. And they can actually debug and step through and like see your code in their editor. And it could even be like a different editor. I think there's other stuff support like proper Visual Studio vs. vs. code and whatnot. So that's really cool. I've always thought like, well, that would be awesome for pi charm. But no. So someone on Twitter, sorry, I don't remember who sent this to me. But thank you, I sent up this link to this project called code together. So code together is a freemium product. So this is a modern open source thing. It's like a paid project, you can go sign up pay dollars a month for certain features, or you can just use the free version, but it has that type of experience that I just talked about, but for many different editors, right? So it comes for all the IntelliJ stuff. So like WebStorm, pi charm, and so on. also works with VS code. It works with other things. I don't know exactly all the things that it covers, but certainly Eclipse IntelliJ and VS code, which covers quite a bit. So if you're looking for that, and you weren't using live share, because it didn't exist for what you're doing. You could check this out. I've not used it. I'm not endorsing it. I'm just saying it looks interesting, and it might help people. Cool. Now. Cool. And then the other one that I want to just quickly mention is related to the first thing these are totally different things. But Kevin Vander Veen sent over a message a week ago and said, Hey, I built a cool Data Explorer to help you understand the whole COVID pandemic stuff in a
22:46 Local way. And he built it using streamlet. So I thought, hey, here's an app that someone just sent over. That's like a cool running on Heroku streamlet app. That would be a nice example of what I talked about at the beginning. And he also has the GitHub repo there as well. So if you go and check out that app, like, for example, Brian, you scroll down to the second to the third graph below the third graph, there's like a drop down that lets you pick Oregon, and you can go pick that. And Wow, it looks like we're flattening the curve really well, that's pretty awesome. Although the last two days have been rough, I guess. Or you can go down a little farther and compare it against different states, you could go in there and type like Colorado, you could type Oregon, or New York, or whatever you want. And then it'll like autocomplete that out of the list and then regenerate. And this is exactly like what I say like, there's some line in the stream like code, that's just saying, Get the tags from the tag selector. And then if you type in there, it just reruns the whole thing. But most of the stuffs cached and then it'll redirect, read, rather grab. It's super cool. So this is both useful, I think for if you want to try to like understand that. It's a cool data science project. The source is on GitHub. But also, it's just a cool example of Streamlight if people want to see that going, and the graphs are fun, too, because you can do like buck select and zooming and stuff like that. Yeah, these are just plotly. So they do all the standard plotly stuff, which is pretty cool. That's kind of what I like about the streamlet thing, not forcing you to use their random graphing thing, but just other graphs that you might like it. Yeah. All right. Well, that's it for my extra What else do you got? Well, I wanted to remind people that pike on 2020 Online is available. And new content is still being posted through the first few weeks of May. I think that's when they're wrapping things up as well. I just saw some new videos go up there. Yeah, yeah, one of the new videos that just came up was my talk. So multiply your testing effectiveness with parameterised. Testing. Oh, yeah. There it is right at the bottom with a couple of new tags on it. Yep. So I'm excited to have people get feedback from people to see what they thought. So that's good. I like it. Yeah. Well done. While I was there, I was looking around. There's tons of great talks. There's a bunch of tutorials there. There's charlas. Is that new this year, and they did it last year, maybe over the last few years. But it's the Spanish language track. Yeah, it's nice. I'm glad they're doing it. Sponsor workshops. That's kind of nice to have. And then even an online poster Hall. So that's there. So it's cool. The other thing I wanted to bring up quick extra. If anybody's following the drama and pi test, the drama is over. And I'm happy with the resolution. So hopefully there will be peace in the family. I hope so a link to the Twitter announcement from pi test. Yeah, they got the whole public statement there. So the folks who had dropped out, are they dropping back in or what's ours, they're just permitted a follow up for that. I don't know that. Any more details. I know at least one person is back in. Okay. All the people are was worried about are signers of this message. So yeah, so probably kind of seems like maybe they're back in? Yeah. Well, that's awesome. I'm really glad to hear that go solved. And it sounds like exactly the outcome that I would have voted for as well. Okay, so, you ready for some jokes? And out of these jokes? How about you? Are you ready for humor? Yes. humors good. Humor is definitely good enough. So I found a couple of funny pictures. And I'm gonna put the pictures in the show notes. I don't know if they'll come up in your podcast players. Some of them do. Some of them don't. Some of you guys, they allow pictures in this podcast feed, just like in the player as you're looking in the show notes. But certainly on the website, there'll be there. And these are a really book covers. I love these. They're like O'Reilly and just if you've forgotten the O'Reilly books always have the title. And then they have an animal that goes with it. Right. So if you wrote a book for O'Reilly, the thing is like, what's your animal on your book and whatnot? Yeah, so these are like, take those ideas, put an analog animal on it, but make it silly.
22:46 There's also usually like some sort of saying at the top of the book. So for these, you definitely have to read the top also. Yeah, it's right, like sort of the subtitle. Okay, so how about this all read the first one, you do the second one, and so on. So this one has like a badger or something on it on the front of it. And it's kind of like sneaky head down. And the title is pointless meetings, the survival guide how to survive all pointless meetings.
22:46 I feel like many, many things that used to be meetings these days are now in email. And people are like, Oh my gosh, they really can't just be emails like why we've been going to all these meetings, right? Yeah. All right, you want to get the next one. The next one is overriding your teammates code. My code is better than yours. Anyway.
22:46 It's got a horse on the front.
22:46 there either. I really love this one. This one is the essential semicolon parenthese sorry, quote, semi colon, parentheses, DROP TABLE animals, semi colon dash dash and there's no
22:46 No animal, because while this is a SQL injection, deleted it, and it says now with user generated content.
22:46 That ones that may be the fastest now with the security hole. Exactly. related. What's next? Okay, this one is a fish on the cover expert hoping nobody hacks you. Security by optimism in prayer. What the fish has to do with it, I must be missing but that's good. This was people's security solution. Right? That's true. So the next one is an octopus. Obviously many legs, I can type many things in the title, the entire book is exiting them eventually. just memorize the 14 contextual dependent instructions.
22:46 Excellent. Give him eventually. Yeah, I love it. I love it. Yeah. So you have to visit that website and check out these because they're pretty sweet. Yeah. Awesome. Speaking of sweet, it's been great to be here with you, Brian. Thanks. It's been great. Thanks. Yep. Bye bye.