Transcript #151: Certified! It works on my machine
Return to episode page view on github00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to
00:04 your earbuds. This is episode 151, recorded October 2nd, 2019. I'm Michael Kennedy.
00:10 And I'm Brian Okken.
00:10 And this episode is brought to you by DigitalOcean. Check them out at pythonbytes.fm/digitalocean. Get $50 credit for new users. More on that later.
00:18 Brian, how are you doing?
00:19 I'm really good.
00:20 Super. We are on PDX Python Meetup West, PDX West Python Meetup, whatever you're calling it.
00:28 It's Eve, aren't we?
00:29 Yeah, it's like just right around the corner.
00:31 Yeah.
00:32 Although it'll probably already have happened by the time this comes out.
00:35 Yeah, it may. It's going to be tight. So, well, I'm sure it went wonderfully. So,
00:40 got all the speakers lined up and everything. I'm really excited to have that as part of our
00:46 community around here. Who knows? Maybe we can put it online somehow, but no plans for that,
00:50 it sounds like. You know, I hear a lot about containers. And when I first heard of Docker
00:56 Docker and things like that, I thought Docker was, I thought they had created containers,
01:02 right? Like they had come up with this idea of this other kind of isolation relative to,
01:06 say, a virtual machine. And looking into it, it turns out that's not the only option. And they
01:10 actually didn't even come up with it, right? They just bundled it up and packaged it nicely.
01:14 I think what Docker has done is very cool, but I have yet to find a use case where I needed it
01:19 so far. And there are other options. And one of our friends of the show, Matt Lehman,
01:25 has written an article called Python Alternative to Docker. The article uses a tool called Shiv
01:32 from LinkedIn, which is a hilarious name. We actually did mention it briefly on episode 114,
01:39 but I didn't know much about it. And so this is kind of a neat, neat article. It talks about
01:44 that Shiv uses a zip app. And I think we've talked about that before that you can,
01:49 and I think there's a few tools that utilize that.
01:52 Right. Things like pecs and stuff. Yeah.
01:54 Yeah. You can zip up a Python application with all its dependencies.
01:57 And I don't think that at that point it includes Python, does it?
02:03 I don't think so. And that was actually super disappointing to me that it didn't just deliver
02:07 a thing that ran. You still have to have Python, but it's like, you don't have to install the app.
02:12 As long as you have Python, you can run it, was my understanding.
02:14 This article is talking about, and this totally makes sense. You've got a continuous integration
02:20 build pipeline where you're making changes and maybe you're updating dependencies, but on the
02:26 deployment machine, you're not deploying, you don't have to update Python all the time.
02:32 You're just updating the thing that you package. And that's, it's kind of a neat thing about Shiv
02:36 is you're, all your dependencies, maybe you're updating dependencies, or maybe you're updating
02:40 your own application or fixing bugs or whatever that can all be put together and tested as one
02:46 deliverable unit. And then that just that can be updated to a server machine, but then all the
02:53 steps of like, okay, that sounds in concept. That sounds great. But what are all the steps I have
02:58 to go through to actually get that done? And Matt has done that. He just basically,
03:02 walked through all the steps to try to get that done. And I thought it was really great.
03:06 He does talk about packaging a little bit because you kind of have to have to talk about packaging
03:11 when you're talking about deployment. So this is kind of fun. He does do a shout out to,
03:16 if you didn't use Shiv or Docker, what would you do? What were, what are all the little steps
03:21 you'd have to do, which just makes it sound like something that you'd either hire somebody else
03:26 to do? Like that's not, I'm not doing that. Yeah. But he also does shout out to platform as a service,
03:32 things like Heroku and Python anywhere. And I think that's cool that there's other options. Like if you
03:38 want to just throw money at it, you just use one of these. Yeah. And these actually aren't that expensive.
03:42 If you're trying to just save time, that's a fine trade-off. But if you want to do this,
03:47 this is a neat idea. Also Docker is a big hammer. I mean, a lot of people love it and that's great,
03:55 but bring up with a lot of people that you want to try to put Docker, deploy with Docker. And if it's
04:01 a thing like this, like you're just deploying an application, that might be overkill.
04:04 It seems like it's a middle ground, right? Like I'm packaging up not just my Python code,
04:08 but my Python dependencies and a lot of the setup around that. You still have to have Python there,
04:13 but beyond that, right? It's like not really much to it. Yeah. If you need to depend on other things,
04:18 like I need Redis running on this port and I need Postgres like that. And then I also want this other
04:24 thing in Linux doing something like all of a sudden, then you're like, you've outgrown,
04:29 you know, bundling Python more cleverly. But if you don't need that, it sounds like a pretty cool way to
04:34 do it. Yeah. Like in this example, the example that Matt gives is a Django application that uses
04:40 a Gunicorn or G Unicorn so that all those dependencies are bundled together. It's not
04:46 like a special kind of Django app with a huge backend that's necessary. But although, I mean,
04:51 Django uses a database, so I'm not sure. Yeah. Yeah. Interesting. While you're talking about Docker,
04:56 I'm a fan of Docker in general, but kind of like you, I don't do a ton with it day to day. I just,
05:02 the stuff I do is just not that complicated. But I recently read an article in ZDNet,
05:07 that site actually still exists apparently. And it actually says, this is surprising to me,
05:13 sort of kind of like I was surprised when GitHub got acquired. I realized afterwards, like, oh,
05:18 they're actually financially in deep trouble. And maybe this is good rather than just going away.
05:22 The article says Docker is in deep trouble. A leaked internal memo, the Docker CEO reveals that the
05:28 troubled company is looking for more money. And they talk about like pushing through with
05:33 perseverance despite lack of clarity on the future and stuff like that. So anyway, just something to
05:39 think about. Definitely. And I read that and I forgot that Docker was a company.
05:43 Yeah, exactly. And I don't even know if it matters if Docker as a company goes away. I mean,
05:48 there are parts of Docker that are important, like the registry and stuff like that. But you could
05:53 totally use Docker if you just had the tools. But still, it's, I don't know, it's just always
05:58 interesting to see these, how this is playing out and something you want to consider if you're going
06:02 to bet your project on it, right? Yeah, definitely. So I have a bit of a theme for this week as well.
06:08 And it has to do with helping scientists do Python stuff a little bit better. So this first thing I want
06:14 to talk about is an article that's kind of a how-to from this woman named Anna Noagrodsky. I'm going to
06:22 go with that. Sorry if I messed up your name, Anna. And it comes to us by a recommendation from a listener
06:27 named Jason Thomas. Thanks, Jason. And the title is How to Support Open Source Software and Stay Sane.
06:34 Nice.
06:34 And this is referring to scientists who develop libraries like NumPy, or some form of Scikit-learn or
06:42 something like that. And then they release it to the world. And then all of a sudden, they've got all this
06:47 software development work and, you know, 100 GitHub issues. They got a review and they're like, I was
06:52 just trying to give back a little bit. What just happened, right? So the article has some interesting
06:57 quotes. So I'm going to do a little bit of quoting from it because it's, I think it's, it's pretty
07:01 revealing. Anyway, it says, the premise of the idol is that releasing lab-built open source software
07:06 involves mountains of unforeseen work for the developers, right? Like you think you're done when you
07:11 release it and it kind of starts. But it opens up saying, on the 10th of April, astrophysicists
07:17 announced that they had captured the first ever image of a black hole. This was exhilarating news,
07:22 but none of the giddy headlines other than us mentioned that the image would not have been
07:27 possible without open source software. And the image was created by Matplotlib, a Python library for
07:33 graphing data, as well as other components of the open source Python ecosystem. Here's where it gets
07:38 interesting. Just five days later, the US National Science Foundation, the NSF, rejected a grant
07:44 proposal to support that ecosystem, saying that the software lacked sufficient impact.
07:48 What even?
07:51 What even, right? So like I said, it's kind of a how-to. It talks about where you're, as a scientist,
07:57 if you're creating software like Matplotlib or something, where do you go to get funding? Where
08:02 have people been turned down? What has worked? And so on. It also talks a lot about using some software
08:08 software development, software engineering techniques for having successful open source
08:13 projects that grow without killing you. It's pretty good. It talks about the challenges of not knowing,
08:19 as a scientist, how you might not have fluency with Git. You might not have a continuous integration.
08:25 Unit testing might not be a thing that you are super skilled in. And it mentions places like
08:32 the eScience Institute, the University of Washington, the software carpentry workshops, places like that,
08:37 where folks can go get that training. And then also talks a little bit about when do you keep your
08:44 software going? And when do you decide like, it's obsolete, we're not going to work on it anymore?
08:48 What else are we going to go build? So if you're a scientist out there, or you work with scientists,
08:52 you want to help them get rolling with Python and releasing their projects in a way that they'll
08:58 stay sane, you know, check that out. I think it's pretty good.
09:00 It's a continuous problem.
09:01 Yeah, it is. And some of the recommendations are things like, make sure you have continuous
09:05 integration, make sure you have version control, make sure you have testing. And one that I really
09:09 liked was that you should focus on code readability over peak performance.
09:14 No, definitely. Always.
09:15 Right. Yeah. Because you're gonna have to fix bugs. And you had a friend who had this saying that was
09:21 really interesting that debugging software is harder than writing software, generally speaking. So if you
09:29 write software at the edge of the complexity that you can handle, you probably can debug it. So you need
09:34 to step it back a notch, take it a little bit simpler. And then when it goes wrong, you could still deal
09:39 with it. Yeah, I like that saying. So before we get to the next one, though, let me tell you about
09:43 DigitalOcean. So DigitalOcean, all of our infrastructure runs there. When you get your
09:48 MP3s that you hear our voices on, those came through a whole bunch of stuff that's happening
09:54 over at DigitalOcean. And they have two new services that I've been telling you all about for a little
09:59 while. But when I keep telling you about it, because they're good. If you want to use MySQL or Redis,
10:03 they now have those as a service, right? There's go flip a switch and turn them on. That's in addition
10:08 to Postgres as a service as well. So definitely coming along. Speaking of the software,
10:13 as a service over at the DigitalOcean side, I'm still a fan of fire me up a VM and install some
10:19 stuff and let it roar. But you know, that's all good. Check them out at pythonbytes.fm slash
10:23 DigitalOcean, get $50 credit for a new user. And they're doing good work. So we can recommend them.
10:28 Nice.
10:28 So you found another license in addition to MIT or GNU?
10:32 Yes.
10:33 I don't know what to make of this. So I wanted to bring it up just to hear your thoughts as well.
10:38 So there's a license. I can't remember where I ran across it. But some I think probably Twitter or
10:44 something. I spend way too much time on Twitter. It's a license called the Hippocratic license,
10:49 like the doctors have the Hippocratic.
10:51 Right, right. First promise to do no harm, things like that.
10:54 Yeah. I mean, I know it's way more than that, but that's all average people remember,
10:58 like me. So this is interesting. It derives from the MIT license and it adds a restriction.
11:05 And the restriction reads, Interesting. Yeah.
11:29 That's an interesting thing. And I like, I kind of like it. My first reaction is,
11:33 wow, that's great. You can say, I'm going to let everybody use my, use this software,
11:38 but I don't want it to be used to harm people. Completely fair. But I don't know if anybody,
11:43 the people that are like intentionally harming people, they don't care.
11:47 Yeah.
11:48 Do you really think people that are in this are really going to go, oh, yeah, we really can't use this software to guide our, like, you know, does this cover military?
11:58 I don't know.
11:59 Also, a lot of this has to do with the human wellbeing. That's up for debate and like a
12:05 perspective, right? Like, well, we had to start the war to help people or, you know, but obviously,
12:10 if you're on the other side of that, like that, you're not helping us. This is not helping. Thank
12:14 you for not, for blowing us up. It's really hard to interpret. And I think you're right that it is
12:18 very challenging because the folks who are most likely to abuse it, it's like the hackers are like,
12:23 yeah, well, I was going to steal that, steal that $10 million from the bank, but it's got the wrong
12:26 license. Yeah. It does still send a message that the person who works in the project cares and it's
12:32 not necessarily a negative, even if it's not super enforceable. It's enforceable, right? I mean,
12:38 I was sure that things about like the MIT license people break. I don't even know what you've got to
12:42 do to break it, but you probably could.
12:44 I actually think it's an interesting thing to have around. I could definitely see people coming up
12:48 with like different sorts of alternatives to the MIT license also, like, like not necessarily
12:56 maybe this plus other stuff. Like I know people that intentionally would never work for a military,
13:01 work for the military or work for a government or a military contractor because of they don't want
13:07 to. And I think it'd be completely legitimate for somebody to say, to have a license that said,
13:13 my open source software doesn't want to, I don't want that to work for these people either. So,
13:17 but I haven't seen that.
13:18 Yeah. Not putting any judgment on those things like working for Boeing or whatever. If you wanted
13:26 a license like that, I think you could, you'd have to be more explicit.
13:29 It's a slippery slope, but the things that I kind of agree with, I'm like, oh yeah, well,
13:33 that's completely reasonable.
13:34 Yes, I know.
13:35 What if people like release software that said, this is okay as long as you don't live
13:40 in Oregon because I don't like Oregonians. That would be lame, but people can do that.
13:44 It would definitely be lame.
13:45 Yeah.
13:46 That's why you set up a server in California and you just remote in.
13:49 I'm vacationing permanently in Oregon.
13:55 Exactly. Exactly. It's an interesting find. Yeah. So the next one, like I said, I'm on a bit of a theme
14:00 here. And this next one is also about helping scientists do more, but more computational people.
14:07 So this one is a real Python how to on why and how to make the switch from MATLAB to Python.
14:15 Oh, this is great.
14:16 Yeah. It's really, really detailed, like standard real Python stuff. I'm not entirely sure how many
14:23 pages it is, but it's, it's quite a few. So it's a good thorough, it's almost like a mini book
14:29 on this as Dan and his crew are used to doing. So it basically compares the philosophy of MATLAB
14:37 to Python, closed source to open source, things like that. Then it walks people through how to set
14:43 up Python. And then just, you use these computational libraries in MATLAB. Here's your Python ones.
14:50 You did these operations like graphing. Here's how you do it in Python. And so if you're out there
14:55 working on a team that uses MATLAB, and I know there are a ton of them out there. I've worked with
15:00 some even around here, a great team who was moving from MATLAB to Python, who I worked with for a few
15:06 days, like helping, helping to speed that transition and things like that. There's a ton of these
15:11 science like groups, data science, not quite maybe data science, but on their way to that world,
15:17 who I think would really benefit from that. Like I long ago even use MATLAB for a little bit of work
15:24 at this research lab that spun off into a company and did like wavelet decomposition of real time eye
15:30 measurements. 250 hertz per second, you know, 250 samples a second. Like wavelet decomposition is
15:36 like a way harder Fourier transform, but it's funky stuff.
15:41 Anyway, to do that, it was fine. But the little toolbox, I think it's called, the wavelet toolbox
15:48 that you got was $2,000 per user.
15:52 Yeah.
15:52 That's a lot of money when you can pip install something that also does that.
15:57 So there's MATLAB used a lot in our company as well, or there used to be. I don't know what it is
16:02 now, but similar sorts of things. There's engineering. I'm more familiar with communication algorithms
16:09 using FFTs and other communication transforms being mocked up in MATLAB before they go to like
16:18 ASICs or something. Yeah, this is very common. And I'm really glad to see more and more people
16:23 moving to Python from MATLAB.
16:25 Yeah, absolutely. I think it's just another one of those slices of the technology ecosystem where
16:30 tons of people are leaving that space and coming over to Python because the great computational
16:34 support that's developing things like JupyterLab and all the NumPy, SciPy type things.
16:40 Also in this article, I learned that there apparently is this thing called GNU Octave,
16:43 which is a free and open source clone of MATLAB that looks pretty good, actually.
16:47 Oh, interesting.
16:48 Yeah. Not that we want to encourage people to just go do that. They should come do Python,
16:51 but this is still pretty interesting. I didn't know that exists.
16:55 Yeah, definitely.
16:56 Have we spoken about GUIs?
16:57 Yeah, quite a bit.
16:58 I feel like we should actually cover that sometime.
16:59 Yeah. So I almost felt guilty about covering this, but it came up in episode 143 already.
17:07 But Nicholas Tollerby has got a project called PiperCard. I mean, I remember HyperCard.
17:14 I never really used it back in the day, the dark ages. But PiperCard is kind of this neat
17:20 little thing. And did you use HyperCard ever?
17:22 No. I have some friends who did, but I've never used it.
17:24 It was a Mac only thing. And it was this thing where you kind of have a whole,
17:28 it's designed as if there's a whole bunch of different cards and a GUI window was just a
17:34 card idea. And then you could print whatever you wanted on the card. And then there would
17:39 possibly be buttons or something on the card. And if you push one of the buttons, you go to a
17:45 different card. And so you can think of an application as a deck of cards or a choose your own adventure
17:51 type game. And that's where a lot of a lot of really complicated choose your own adventure games
17:56 were made on HyperCard. And so PiperCard is a similar thing just in Python. And it started out
18:03 with Adafruit, but it's now gone. Nicholas has made it. You can just run it on your anywhere and you can
18:10 just pip install it. And I was playing with it the other day. And at first I dismissed it. But when
18:15 I had him on testing code on episode 89, and we talked about a little bit and I didn't realize
18:21 this. So one of the ideas is you have basically a simple list of what's in the card and then what
18:28 card to go to next with different buttons and inputs and stuff like that. But if you, instead of saying
18:34 which card to go to, you give it a function to go to, you can run any Python code as long as that
18:41 function returns a string to tell you which card to go to next. So that makes it actually pretty
18:46 powerful to build up some fairly complex logic very simply. Anyway, it's fun to work with. I can even
18:53 think, I was even thinking of some work business uses that I could use this for and get it mocked up
18:59 really quick.
18:59 That's cool. It looks interesting. It feels a little bit like a visual workflow executor, right? Like I go
19:06 down this step, then I do this step, then there's a decision, and then I do this step or that step,
19:09 and it's all represented by these cards. It's pretty cool.
19:12 He has an example of a Celsius to Fahrenheit converter, but also like, I mean, there's a lot
19:18 of little simple conversion math stuff applications in businesses that would be a good use for it.
19:24 And it's also uses that user interface thing that I always forget, but it was like, nevermind,
19:31 I can't remember what it is. It's one that you don't see very many examples of.
19:34 Cool. Yeah. And it looks like a nice project. Cool.
19:36 You know, something we don't talk a whole lot about on this show is Node.js.
19:39 I don't know if we ever have. Have we?
19:41 You know, I think the extent to which we talked about Node.js was maybe some security issue in
19:46 like NPM and how it is an analogous thing over at PyPI. Maybe. Like that's the extent of it.
19:52 Okay.
19:52 So Node.js obviously is a pretty big server side framework for running JavaScript code on the
19:58 server. Right. And you know, the story is like, Hey, if I got to write JavaScript on the front end,
20:02 I might as well write it in the back end. That's not my philosophy. Mine is more like,
20:06 how do I minimize the amount of JavaScript I write? Let's not also do that on the back end. I mean,
20:11 not that I hate JavaScript, but I don't want to overdo it. Anyway, there's a cool project that brings
20:19 some integration between Python and Node. So imagine you're working on some project,
20:25 or you're on some team, and they're like, we've chosen Node. You're like, sigh, sad face. But you
20:32 still want to use some Python, or maybe you want to use some kind of Python library, like, I don't know,
20:37 NumPy, TensorFlow, whatever, something that doesn't have a JavaScript equivalent, right?
20:42 Yeah. So you can use this thing called PyNode. And what it does is it's a bridge between Node.js
20:47 and Python that allows you to call Python code directly from JavaScript. Oh, wow. So this is on
20:54 the server, right? Like if it was on the client side, then who knows, we'd have to use something
20:58 like Sculpt or Brython, and then it would convert the Python to JavaScript. Like that's a different
21:02 thing. This is the CPython interpreter with everything that Python can do on the server. But you can
21:10 interact with it, call it and get return values from those functions in Node.js. You call into Python
21:16 and you get your answer back. Nice. So that's pretty cool. And the API for working with it's not too bad.
21:21 You have to basically, you know, in Node.js, you require stuff to load it up. So you require PyNode.
21:27 And then you go to get your PyNode, you can say start the interpreter, which will, I'm guessing,
21:32 embed CPython into the node process. And then you just call functions. The way you directly call them
21:38 is kind of crummy, you say like PyNode.call, and you would say quote add, comma one, comma two to call
21:45 the function add by passing one and two to it. And then you get a callback from that. I think you
21:51 could do some interesting stuff by wrapping this up into a JavaScript class. So you just say, you know,
21:57 create it. And then you just start working. You just it has a dot add that takes a one and a two.
22:03 And you could put like a facade that makes this much simpler. Do a little async and await to get
22:07 rid of the callback potentially things like that. But yeah, it's, it's definitely got some potential
22:12 there. And if you're working in Node.js space, you're like, I really wish I had Python. Well,
22:17 PyNode. It's great. I mean, there's more and more projects where they really aren't one language,
22:22 you're trying to do lots of different things, or you're trying to migrate from one thing to another,
22:26 use the language that works the best for wherever you're at.
22:29 And similar to the last one that I covered, not trying to send people away to that thing,
22:33 not to Node or to Octave or whatever. But, you know, just acknowledging, right? Like just what
22:39 you said that there are these environments where you don't always get to pick Python. Here's another
22:43 environment where you can now blend these together.
22:45 Yeah, there's lots of languages that are good. None of them are as good as Python, but just saying.
22:50 That's right. All right. Well, those are the major topics that we're covering for the week.
22:55 Do you have anything extra to cover?
22:56 No. Although like putting together a meetup is more work than I expected.
23:00 I appreciate you doing that. I'm sure that it is.
23:02 I did submit. There's like call for proposals out and I did submit to a couple of conferences. So we'll
23:08 see.
23:08 Awesome. Good luck on that. The call for proposals for PyCascades, right? And also I think main PyCon,
23:13 right?
23:14 Yeah. PyCon's open. Tennessee's open. A couple others are open.
23:17 Super. I actually have nothing extra to share except for I have a joke.
23:21 Oh, good. I didn't bring a joke.
23:22 It's not exactly a joke, but it's definitely something that's very funny. So have you ever
23:27 heard the excuse that, man, this works on my machine?
23:31 Yeah. It's closing a defect with cannot reproduce.
23:34 Exactly. Like, dude, this is working. Like, why does this not work for you? I just, who knows what
23:38 it is? It could be the version of some library that's installed. It could be like permissions.
23:42 Who knows? But there is a, it works on my machine certification program that I want to tell you
23:48 about. Okay.
23:49 Okay.
23:49 This is a real program and it has like an honors badge. It says works on my machine. It's kind
23:53 of golden. You can put that on like your wall when you get certified and there are like real
23:59 steps. This is not new. This front, this is a pretty old certification, but I thought it'd
24:03 be fun. We haven't talked about it before. So there's some specific steps that you got to
24:08 follow. And the steps here are talking about like a compiled language. So maybe like it
24:12 slightly varies with Python, but it's still, I think it's funny. So step one is you have
24:17 to compile your application, getting the latest version from any recent or any recent changes
24:22 from other developers is purely optional and not required for certification. Okay. Step two
24:28 is you launch the application or website that's just been compiled. Step three is you cause,
24:34 you're going to like this part as a person who's into pie tests and stuff. You cause one
24:39 code path in the code that you're checking to be executed. The preferred way to do this
24:44 is with ad hoc manual testing of the simplest possible case for the feature in question.
24:48 You may omit this stuff if the code change was less than five lines, or if in the developer's
24:54 professional opinion, the code change could not possibly result in an error.
24:57 Yeah.
24:58 And finally, you now check your code into version control. Congratulations. You're certified.
25:03 That's nice, right?
25:04 Yeah.
25:04 There's probably a lot of certified people. They just need to like claim credit. They've done
25:08 this. I'm sure.
25:09 Yeah. They just don't know.
25:10 Well, they can now get the star and put it on their wall.
25:14 Yeah.
25:15 All right. Well, thanks for being here as always, Brian, and sharing all this news with everyone.
25:20 Well, thank you. Bye.
25:21 You bet. Bye.
25:22 Thank you for listening to Python Bytes. Follow the show on Twitter via at Python Bytes. That's
25:27 Python Bytes as in B-Y-T-E-S. And get the full show notes at pythonbytes.fm. If you have
25:33 a news item you want featured, just visit pythonbytes.fm and send it our way. We're always on the lookout
25:38 for sharing something cool. On behalf of myself and Brian Okken, this is Michael Kennedy. Thank
25:43 you for listening and sharing this podcast with your friends and colleagues.