Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 181, recorded May 6, 2020. I'm Michael Kennedy. And I am Brian Okken. And this episode is brought to you by Datadog. Tell you more about them later. Brian, this first item that you picked here, I saw this going around the Twitterverse and I was like, oh, that looks really cool. Tell us about it.
Yes, Interrogate. So it's a new little tool. I think it's kind of new, new to me at least. It checks your code base for missing doc strings or the presence of doc strings. So it's written and maintained by Linroot. And we were notified by Herbert Beamster, suggested it to us. I like doc strings. I don't like them. I don't have a policy of having them
everywhere, but doc strings can help you understand the code quite a bit. I really love how like a function doc string is utilized by VS Code and PyCharm and other editors to do things like if you hover over a function, it just pops up a little window with like, you know, what parameters you can send
to it. But it also sends the doc string, shows the doc string if there is one. There's also other tools like Sphinx or PyDoc or DocUtils that can use that amongst other things to generate documentation. I don't really use those. I know a lot of people do though. So it's a problem if you've got some missing, if you really need to have doc strings someplace and they're missing.
So interrogate is a command line tool that you can use to check your code to make sure everything has a doc string that needs to. I think this is great. Yeah, it's super cool. And well done, Lin. Nice work on this one. I think this is really nice because if you have a public library, that should be documented, right? That should be covered with nice doc strings that give you all sorts of help in your editor, like you
mentioned. But also if you generate the documentation, you don't want to have just some random empty, either completely missing or just the, you know, like the function name and just an empty body or whatever it gets generated there. So this is really cool. And I could see if you were doing a package that was public, having this part of your CI CD process that if somebody introduces something into, like a PR that here's a new function we wrote, like, great. It failed the CI because it doesn't
have a doc string. That'd be awesome. Yeah. And then there's also some common, there's some common like caveats, like, yes, all public functions should have doc strings. But what about like private functions and stuff? There's options to be able to tell to turn off things where you, you know, might not need a doc string for just an internal helper function or something.
Yeah, I totally agree. Like if it's not really meant to be included, you know, in the public API, then it shouldn't have a doc, it shouldn't necessarily have a doc string. Yeah, it can if it helps to understand it, but you don't, maybe you don't need it. So this is nice. Yeah, yeah, this is super cool. Well done, Len. Yeah, I wanted to mention also there is information on the readme about how to use the tool within talks and within CI workflows. So that's helpful.
Yeah, this one seems like a super easy thing to adopt. If you already have a CI process in place, and you're working on something that's public, whether that's public to your people within your company, or you know, it's a package that is used by other projects, right? Or it's public as in on pypi.org. I still think it makes sense to just document it for whoever's consuming it, who's not writing it. Yep. Very cool. Now, this next one, I've been holding off on talking about for a long time,
because it's really interesting, but I didn't feel like I was able to do it justice. So the thing I want to talk about is Streamlit. With Streamlit, the idea is it allows you to build much simpler data science applications and web apps, I guess you would say. So many people come to Python from I've got a little bit of computation that I got to do. And so I'm going to write a script that does like 10 things, maybe it doesn't even have a function, it just does do x, you know, load data,
transform data, pivot data, show graph, or something like that, right? Really, really simple. They're not like, pro web developers that are like busting out view or react or something like that to build cool apps. But they've got this really cool outcome with Python, and they're happy. But at the same time, they would like to have this publicly shareable, they maybe want to put it on the internet,
they want to make a web app out of it. And the gap from I've got 10 lines of code that outputs a graph to I have a fully interactive, dynamic, server backed JavaScript front end type of visual website, that's a big gap, right? Yeah. So Streamlit... Even for me. Yeah, yeah, well, yeah, for me as well. Now for Streamlit, the idea is that you write the code in the simple, straightforward style that I talked about, but then it turns it into an interactive web application. That's neat.
That sounds neat, right? And it does a whole bunch of really interesting tricks to let you continue to write code in this simple, straightforward way, and yet interact with like callbacks and stuff. So you might have a function that comes along and says, okay, what I need to do is I want to show, I don't know, a drop down list in a web app, or a slider bar or something like that. And then you write your code
that says, get the value from the slider bar. And you might think, okay, well, normally that's wait for the user to click on the slider bar. And when there's a change or some kind of callback, and then you have some function that runs on the callback and it updates the DOM, right? But this is like straightforward procedural code or imperative code that doesn't have any of those ideas in it. So what it does is it uses interesting caching on your functions so that if it were to rerun it with
the same inputs, it gives you the same answer instantly, like LRU cache type of stuff. And then if any of those controls on the web page change, it just reruns the whole script. And when you say, get me the value from the slider, it says, well, currently the slider is set at this. And if it happens to change, it just reruns the entire thing from beginning to end. But because everything's cached, it only recomputes the parts that are needed. So you don't have to think about callbacks.
You don't have to think about user interaction. You just write top to bottom code. And here you've got multiple parts of your application that can be changed dynamically that just continue to refresh. And it refreshes it by using JavaScript. So it doesn't even reload the page. It just looks like parts of the page are dynamic and coming alive. Oh, wow. This is neat.
Yeah. So it's super cool. Basically, if you can write like straightforward, top to bottom code that works with like graphing or pandas or something like that, you now can create a single page, a spa app. And I don't remember what JavaScript framework it uses. It's like react or view or something like that. I think it might be react. Anyway, it's not super relevant, but it does all of that work with like hosting it and creating the server callbacks and setting up the JavaScript
and the UI widgets and all that kind of stuff. And all you do is write basically procedural code. One thing that I think is a danger of these types of applications is it's easy to say if you use our magic graphing library and our magic UI widgets and our magic, you know, data processing library, not a real database, but our magic server database that we create, then it works, right? Yeah. What I like about this is it doesn't do any of those things. It just says you want to use pandas
and numpy and plotly or something like that. Use those and then use them in your script. And then we just make it this single page app, which is pretty awesome. Yeah. That was my question. Is this a hosted thing or can I do it like behind a firewall or local thing or do you know? Yes. So with Streamlit, you have a couple of options. I haven't done anything myself,
but you can self host it or they'll host it for you, I believe. And if you, they have this thing called four teams, which is like they automatically deploy and manage the apps and you just create them and say, here's the code and run it. It's like kind of a platform as a service for Streamlit apps type of thing. That's a paid part of what they're doing. But the stuff I described up until then, that is free and open source. So it's still pretty, pretty usable. Yeah. So you have to
basically deploy them yourself, but they talk about how to do it. You know, it's not super hard. Okay. Nice. Yeah. So I had the, one of the guys Adrian on who is behind this and has also done some other interesting technical programming stuff and with self-driving cars and folding at home, those types of things on Talk Python just a couple of episodes ago. I don't remember exactly what number it was, but I guess 260 ish, something like that. So just check out that episode if people want
to go much deeper, but this is really cool. If you're writing these imperative, simple little scripting apps and you're like, I would really like to share this or make it better. Streamlit's cool. Yeah. Nice. Okay. I feel like we both have themes for ours. Your theme is continuing with documenting and whatnot. And you'll see my theme develop as well. This is interesting because I ran across this interrogate second, but after I ran across this,
an article by Hienic that says why you should document your tests. He makes a lot of good points. So I believe, and we have this policy where I work of tests should have doc strings on them to tell you kind of what the test is doing and why it's there. There's a lot of reasons that I have never really been able to describe clearly because you're, I mean, ideally your test name should be descriptive and
the code should be clear. So why do you need a doc string? It's not, that's not something that you're going to call from an API or anything. You probably won't type help function, you know, test function, right? Right. Probably not. And you also don't call it. I mean, like test methods that you run pytest with, pytest calls
it. You don't call those tests, but you can get confused in the future. And one of the explanations is Hienic has a good example where he shows some simple 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. It's kind of obvious of the, if I pass in functional tests, if you pass in a 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 he writes, 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 of that expressed of why you should document. And it might be you that'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, I'm like,
oh, awesome. I really want to put something in place to just make sure all my tests have doc strings. And he lists in the article, the exact command line that you need to make sure that all just text, make sure that your tests have doc strings and nothing else. So this is 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, the 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 adders is not implementing false on the class or something to that effect. Right. So you're 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 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 it's not important. Comment it out. Comment it out. Passes. You don't want that. CI is good. We're going home. I don't do that, but I've heard it done before. Of course. I would never do anything like that, but I can imagine that it has been done. Now I actually have, I have some experiences in the past where like there was some project and it had like a beautiful set of tests and then, and CI and stuff. And I wasn't working
on it anymore. And whoever took it over is like, Oh, those tests were really annoying. So I turned them off. You're 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 pie tests 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 the 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 look. 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, it was an internal thing, but a quick plugin for pytest 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
it's 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 can troubleshoot your app's performance with their end to end tracing. Check out their detailed flame graphs to find bottlenecks and latency in 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 pythonbytes.fm/data dog and get a cool little,
t-shirt as well. All right. So your theme is so far has been pretty clear. Next one of mine, I want to talk about a project called hollow viz. Have you heard of hollow viz? I have not. I'm sure you've heard of scipy and those types of things. There's kind of a grouping of other projects, right? Under that general banner with like numpy, matplotlib and whatnot. Well, hollow viz is kind of
like that for data processing and visualization. And one of its features acts very much like streamlet, but in a more general, probably a little more work to set up and like, right, you got to work more in its framework, but in a very similar way to what streamlet is doing as well. So it's a coordinated hollow viz is a coordinated effort to make browser based data visualization in Python easier to use, easier to learn and more powerful. So it's, 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, a bunch of tutorials, conda, like meta package that when you, you know, in conda install hollow viz, it actually installs a whole bunch of things. I'll tell you about a second, even has some sample data sets. 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, param for creating a user configurable objects, like config stuff, and then color set or like
color maps. So yeah, you want to have like nice colors that flow together for your plots. And panel is the main thing that I was thinking of that lets you create these single page apps around interactive sliders and dropdowns around your graphs and other, other kinds of stuff. And, yeah, very cool project as well. Yeah. I was looking at the data shader and they have like some really pretty pictures because of the, the examples of, overlaying data plots over the map of the U S things like that.
It's cool. Yeah. Or, you know, you can plot attractors with 10 million points each. Oh, is that all? And these graphs, I mean, these, the resulting pictures are, I don't know what they're like 400 by 400 pixels or smaller. It's like, yeah, that 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 onto the United States map. Yeah. It's like, like a sun,
uh, really is pretty interesting. Actually. I think I can see you over there, Brian, you're on the left. 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 of these projects towards the end of the show as well, but a bunch of cool libraries, like all brought together under this hollow of his
project to make them work together. Yeah. Nice. Nice. What'd you got 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 pytest has added,
progress bars for, you know, watching your test finish and things like that. And it's, it's nice to have progress bars and 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, 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 is seven or like whatever we're done. Yeah. Some of the, like, what was it? pipenv. 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 that 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 it has an interesting fact section, which is kind of cool. The code is in a functional style. It uses closures and generators. So, I mean, actually a lot of times I'll look at, code, not as an example of, of how to do
something. So if somebody is proud of like their use of generators, maybe it's worth code checking out if you're trying to learn generators. And then another feature that I'm definitely going to pick up for things that I work on is change log highlights. So not the entire change log in the read me, but just one or two lines of semicolon separated features per version of change. So this is kind of a nice thing to add. Oh yeah, that is really nice. Cool. I think it's a great project.
If I need a progress bar, I'm definitely going to consider this one. Like I said, like I do think they're neat and I do use them sometimes. So, yeah, that's cool. Very nice. All right. Last one's a quick one. So we talked about hollow viz, talked about streamlet and panel and how those are kind of similar. So there's this other project called awesome panel, which is kind of like an awesome list for panel that way to build interactive data science, single page apps, or not even single page
apps. This is run by Mark Skalv Madsen. I got that closely, right? Mark. And yeah, it's a cool project to just show a bunch of examples and a curated list of these. So yeah, if you just open that up, you can go see, there's an app that comes up. It takes just a second come to life. And then on
the left, there's like a gallery. There's all sorts of cool pictures. There's also a nice talk. I can't remember who gave the talk, but yeah, it's a, there's like a talk from one of the conferences, but if you go to the gallery, you'll see like, as you navigate around, it's kind of like this single page app. So if you click gallery, you'll see like the main part of the app sort of spin for a second and then come up and then you can go and say, Oh, there's like one of the things that's
really cool that I'll point you guys at is this thing called the image classifier in there. So I went in there and it's lets you, if you just scroll down, it says upload an image and you can grab some JPEG and upload it. I grabbed some like random microphone picture that I had laying around and threw it in there. And then it ran, you can pick different neural networks to run against it.
Do you want to run NAS net mobile, NAS net large, mobile net V2? Like, I don't know what these are, these glass fires, but you can pick from them and then it'll tell you in a cool little graph at the bottom, like what it thinks that is. And it thought the microphone was most likely a microphone, but it could have been a shield because it had like a big metal guard on the front of it. And it's just really
cool. And so this whole website is built, if I got it right, in panel to show you how you can build a cool panel app. But then as you dive into the gallery, each one of these pieces is like an interactive sub panel or something like that. So it's kind of, it's a little bit meta in that regard, but it's pretty cool actually. Yeah. It's really, it's really cool.
Yeah. And yeah, it's apparently super easy to work with. Again, I haven't built anything with it, but it seems like a much simpler way to get your interactive data science stuff on the internet than learning Vue.js, JavaScript, Flask, SQLAlchemy, et cetera, et cetera. Yeah. Yeah. So anyway, pretty cool. I recommend if you want to check this out, just go browse the gallery. That's the best way to see what this thing can do. I love pretty pictures.
I know. Yeah. This one definitely passes our, our tests for you must have pretty pictures 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 it for our main items. I want to tell you about a couple of things, then we'll get to yours 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 in 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 PryCharm, 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 paired 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 versus VS Code and whatnot. So that's really cool. And I've always thought like, well, that would be awesome for PyCharm. 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 CodeTogether. So CodeTogether is a freemium product. So this is a, not an 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, PyCharm, 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 LiveShare, because it didn't exist for what you're doing, you could check this out. I have not used it. I'm not endorsing it. I'm just saying it looks interesting and it might help people.
Oh, neat. Cool. Yeah. Yeah. 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 VanderVeen 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 local way. And he built it using Streamlit. So I thought, hey, here's an app that someone just sent
over that's like a cool running on Heroku Streamlit app. That would be a nice example of what I talked about at the beginning. And it 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 dropdown 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 it's 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 was saying. Like there's some line in the Streamlit 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 stuff's cached and then it'll redraw the graph. 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 Streamlit if people want to see that going. And the graphs are fun too because you can do like box 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 Streamlit thing, not forcing you to use their random graphing thing, but just other graphs that you might like. Yeah. Yeah. All right. Well, that's it for my extras. What else do you got? Well, I wanted to remind people that PyCon 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. Yeah, that's cool. 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 parameterized testing. Oh, yeah. There it is right at the bottom with a couple of new tags on it. Yeah. So I'm excited to have people get feedback from people to see what they thought. So that looks 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? They did it last year, maybe the last two years, but it's the Spanish language track. Yeah. It's neat. 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, a quick extra, if anybody's following the drama in pytest,
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 pytest. Yeah. They got the whole public statement there. So the folks who had dropped out, are they dropping back in or what's, or is there just permanent out fallout from that? I don't know that any more details. I know at least one person is back in, but all the people I was worried about are signers of this message. So. Yeah. So probably.
Kind of seems like maybe they're back in. Yeah. All right. Well, that's awesome. I'm really glad to hear that got resolved. And it sounds like exactly the outcome that I would have voted for as well. Okay. So you ready for some jokes? I don't know. These jokes. How about you? Are you ready for humor? Yes. Humor is good. Humor is definitely good. And so I found a couple of funny pictures and I'm going to 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 say allow pictures in this podcast feed, just like in the player as you're looking at the show notes, but certainly on the website, they'll be there. And these are Oh 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 animal on it, but make it silly. Right? 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? I'll 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. I feel like many, many things that used to be meetings these days are now an email and people are like, Oh my gosh, they really can just be emails. Like, why have we been going to all these meetings? Right? So, all right. You want to get the next one?
The next one is overriding your teammates code. My code is better than yours anyway. It's got a horse on the front. I don't know either. I really love this one. This one is the essential semicolon parenthesis. Sorry. Quote semicolon parenthesis drop table animals, semicolon dash, dash. And there's no animal because, well, this is a SQL injection that has deleted it. And it says now with user generated content. That one's that may be the best. Yes. Now with the security hole.
Exactly. Related. What's next? Okay. This one has a fish on the cover. Expert hoping nobody hacks you security by optimism and prayer. I don't know what the fish has to do with it. I must be missing it. But, no, but that's good. That's most people's security solution, right? That's true. So the next one is an octopus. Obviously many legs. It can type many things. And the title is the entire book is exiting vim eventually. Just memorize the 14 contextual dependent instructions.
Exiting vim eventually. Oh, I love it. I love it. Yeah. So you'll have to visit the 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 has been great. Thanks. Yep. Bye. Bye.