Transcript #70: Have you seen my log? It's cute!
Return to episode page view on github00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
00:05 This is episode 70, recorded March 15, 2018.
00:09 I'm Michael Kennedy.
00:11 And I'm Brian Okken.
00:11 Brian, how are you doing?
00:12 I'm doing great. It's good to talk to you again.
00:14 Yeah, you as well. Super excited to talk about some of these things that you got here.
00:18 Before we do, though, let's just say real quick thanks to DigitalOcean.
00:21 They're sponsoring this episode like they do many of the episodes, so check them out at do.co.python.
00:28 You know, I'm a big fan of Cookie Cutter. I've done a couple of things with it.
00:31 Yeah, actually, I'm warming up to it, and I use it for quite a bit now.
00:36 That's nice. You've found an interesting online Cookie Cutter thing. What is this?
00:41 It's from Konstantin Pavlovsky. That's a cool name.
00:44 Anyway, online Cookie Cutter generator.
00:47 And so Cookie Cutter is a command line thing where you point it at, you give it a link to usually a GitHub Cookie Cutter,
00:56 but you can have them be local also. And it starts asking you questions about what you want to fill in the project,
01:02 and then it starts like a Python project for you. You could probably describe it better.
01:06 It's more of a templating thing you could do anything with.
01:08 It's pretty interesting. So the way Cookie Cutter works is it's a CLI thing, and you run it,
01:12 and it will ask you questions, right? Like, what's your email address? What's your full name?
01:17 What do you want to call the project? Do you want to use Jinja 2 or Chameleon Template, etc., etc.?
01:21 This is like that, but it's like a website with a web form that asks the questions like that way, right?
01:28 Right. So he doesn't have, like, everything up, but he's got quite a few up now that are some of the common templates,
01:35 the PyPackage and PyPackage Minimal and a Flask and Bottle and actually quite a few others.
01:43 And instead of doing it on a command line, you select it, and it shows you basically all of the questions that you're going to get asked.
01:52 And you can just fill it in and then generate project, and it generates a zip file for you, and you can download it.
01:58 So basically, like, if you don't have Cookie Cutter installed, you can still execute the Cookie Cutter template by going to the site.
02:05 Yeah.
02:06 Nice.
02:06 If you just kind of want to see all of the questions before you get going, gather those up first.
02:11 That's quite cool.
02:12 I thought it was neat, and he's a pretty cool guy on Twitter, so if you have a favorite Cookie Cutter that you'd like to have him put up there,
02:21 I bet if you just contacted him, he'd probably put it up there.
02:23 Yeah, for sure. Very cool. So check out the online Cookie Cutter generator. I like it.
02:28 So did we go on, like, a rant about GUIs for a while?
02:31 Yeah, for a bit, yeah.
02:33 So I'm not exactly going to talk about, like, another GUI platform that, like, I don't know, takes restructured text and turns into a UI.
02:40 Nothing like that.
02:41 But there is a really cool project that integrates with standard Python logging.
02:45 So Python logging works in a certain way where it's got, like, the time and then, like, the module or the category and then the level, like, trace or info or error, and then the message, things like that.
02:58 So someone built a really cool UI that will let you, in real time, watch and accumulate the logs into a rich application just by starting up and running it.
03:09 Oh, yeah, this is actually really cool.
03:11 Plus, you can filter your different levels and filter them out.
03:14 Exactly.
03:15 So, like, imagine, like, if you want to tail your log, right?
03:17 I'm going to tail it and see what's coming through.
03:19 And then it's just, like, ripping by.
03:20 You're like, oh, my gosh, there's all this stuff.
03:22 Was there an error?
03:22 I'm going to search.
03:23 Oh, like, it's kind of hard to correlate, right?
03:25 So what you do is you install into your app, you install a socket handler as one of the trace sources.
03:33 And then you just, this just listens to that UDP source.
03:36 So you install, like, a socket handler thing.
03:39 And then you run this app and it just, boom, it just starts capturing the logs in real time as if you're tailing them.
03:45 But with a UI, you can filter and sort and interact with.
03:48 Yeah, and change the color on them and stuff.
03:50 It's got a dark mode.
03:51 You know it's for developers.
03:52 Yeah.
03:53 Yeah, but quick shout out to just the framework, though.
03:57 It is based on PyQT5.
03:59 And it's all open source.
04:01 So you can go check it out and see how they built it.
04:03 It's a pretty decent looking app.
04:04 Yeah.
04:04 And actually, I haven't been putting a lot of levels of logging in some of the work apps that I do.
04:11 But I might with having this logger like that.
04:14 It's pretty cool.
04:15 So it allows any number of simultaneous connections.
04:18 So you can have different people can watch it.
04:20 You can change the look of the feel.
04:22 You can filter, like you said.
04:24 You can search.
04:24 You can view exceptions and tracebacks and stuff on separate windows.
04:28 So you can pop out the traceback and just look at the details.
04:31 It's pretty cool.
04:31 Yeah.
04:32 Okay.
04:32 Yeah, very nice.
04:33 So there's a really cool CMS for Python called Wagtail, right?
04:39 Yeah.
04:39 And I'm actually surprised we haven't talked about it yet.
04:41 But there's, I know that when I think of a CMS, I'm usually thinking like for a lot of stuff, I think of like maybe WordPress or what's that other popular one?
04:53 Like Squarespace, something like that.
04:55 Drupal, Drupal.
04:56 Drupal, that's it.
04:58 Yeah, there is one for, there's actually, I think there's several for Python, but Wagtail is one of the more popular ones.
05:03 And it's got a really nice look.
05:06 And 2.0 just came out.
05:09 And they're pretty excited about it.
05:11 We did cover Django 2.0 changes recently.
05:14 And this Wagtail 2 does support Django 2.0.
05:18 And there's apparently a better, newer text editor that they're excited about.
05:23 And some fixes in scheduling your published content.
05:27 Yeah, it's awesome that it's based on Django 2.0.
05:30 And of course, that means goodbye Legacy Python as well, right?
05:34 Yeah.
05:34 But one of the things that I wanted to highlight as well while we're talking about Wagtail is if I'm thinking about a different framework,
05:42 often I kind of want to know really what it's going to be like.
05:47 And that's really hard to tell without just starting it.
05:50 But they do have a couple things to help.
05:51 There's a, we're going to link to both of these.
05:53 One of them is a gallery of sites made with Wagtail.
05:57 So it isn't really how to do this, but these are things that are possible with this framework.
06:01 And some of them are professional and they look really nice.
06:05 Yeah, they do look really nice.
06:06 And like the whole, what one is it?
06:08 It's the Royal College of Art in London.
06:12 Its entire site is driven by Wagtail.
06:14 Wow, that's nice.
06:15 And then there's a couple of e-commerce sites that are in there too.
06:18 So you can set up e-commerce as well.
06:20 And then the other thing is they have a Zen of Wagtail page that talks about,
06:26 they have kind of their design philosophy of how they're set up their code and what they're in with the end user.
06:33 So it's neat.
06:34 I like it that they have that kind of philosophical guidance to help you to go along.
06:38 It's cool.
06:39 Yeah, I would definitely consider Wagtail if I was building a site and other people had to add stuff to it who were not developers.
06:45 And you wanted it to be CMS-like.
06:47 It's very cool.
06:48 Yeah, actually, I think I'm going to set up something for work using Wagtail just to try it out.
06:52 Yeah, super nice.
06:53 So speaking of setting up stuff, let me tell you about DigitalOcean.
06:56 So with DigitalOcean, you know that you go and create a new server and you get like a Linux machine and some variety that you pick.
07:04 You SSH in and then you begin your process of building your infrastructure, right?
07:09 Do you want WordPress?
07:10 Then you've got to go set that up.
07:11 You want Django.
07:12 You've got to like make sure Python's installed and all the things are all set up and whatnot.
07:17 That doesn't even mention the database, right?
07:19 So one of the cool things that they have that I want to highlight is they have the ability to create what they call one-click apps.
07:24 And those are actually entire virtual machines that are pre-configured to run the thing that you want.
07:30 So you want a ghost for, you know, like that blog service, static blog service, whatever it is.
07:35 So you just click, go to the one-click apps and say, I want a ghost server.
07:38 Boom, it's up and running.
07:39 You want a MySQL server?
07:40 Click that.
07:40 You got it.
07:41 MongoDB configured so it's all safe on the network.
07:43 Click that.
07:45 Super cool.
07:46 They have Discourse.
07:47 They have WordPress.
07:48 They even have a machine learning and AI pre-built thing.
07:51 So you want to click that and then just log in and start doing your TensorFlow and things like that.
07:56 It's just like ready to roll.
07:57 Yeah.
07:57 One of the things I like, they have a GitLab one so you can set up your own, like your own team GitHub-like thing.
08:03 Yeah, that's super cool.
08:05 And you don't need to know that much about it, right?
08:07 It's like all the stuff is set up and running.
08:09 You just have to be able to keep it running more or less.
08:11 Cool.
08:11 Nice.
08:12 All right, yeah.
08:12 So check them out at do.co slash Python.
08:14 And they're big supporters of the show.
08:16 So check out their stuff.
08:17 Tell them thanks.
08:18 So I'm a big fan of databases.
08:19 We talked about MySQL and MongoDB there.
08:22 What's the most popular way of accessing databases, you think?
08:25 What would you use?
08:26 Raw SQL statements.
08:27 I'm sure it's the most popular.
08:30 But outside of that, I'm thinking like Django ORM, SQLAlchemy.
08:35 Like these are the major tools, right?
08:37 Yeah, ORMS.
08:38 Yeah, the ORMS.
08:38 So there's another one that's really cool that's really small and lightweight called PeeWee.
08:42 You would never know by the name.
08:43 It's a good name, actually.
08:46 I like it.
08:46 It is a good name.
08:47 So it's a simple and small ORM.
08:49 There's a few but very expressive concepts to make it easy to learn, intuitive to use, and so on, right?
08:55 That's what they say about it.
08:56 It's been around for a while.
08:58 But the news is they did a complete rewrite of it and released PeeWee 3.0.
09:03 Nice.
09:04 Yeah, so it's pretty cool.
09:05 It's developed with Python 3.6, so it embraces all those features.
09:10 It has built-in support for SQLite, MySQL, and Postgres.
09:13 Those are all nice.
09:14 And it has extensions for things like full-text search and migrations and whatnot.
09:19 So that doesn't sound so PeeWee.
09:20 Actually, that's a lot of features.
09:21 It's a lot of cool stuff.
09:23 One of the reasons it's really interesting to me is because there's a separate project called PeeWee Async.
09:29 Okay.
09:29 One of the challenges you have, like, doing any async stuff is, like, everything that is blocking or slow has to be async, or there's kind of no point to even getting started, right?
09:38 If I'm going to call a web service, I have to use, like, the async, the AIo HTTP client, or it just doesn't make sense, right?
09:44 It's just blocking.
09:45 Like, there's no async behaviors.
09:47 And you run into that problem often with accessing databases, like, say, SQLAlchemy and stuff.
09:52 So this thing, PeeWee Async, will let you add async ability to your queries.
10:00 So it's super cool.
10:01 So you're going to go, if you want to insert something, you would just say, like, await objects.create, and you pass off the object you're going to insert to the database.
10:08 You want to do a query, you just say, like, all objects equals await objects.execute, like, you know, your model.select, like, in the syntax.
10:16 So it basically allows you to just plug in this async and await to very, very minimal effort to make your code much more scalable.
10:23 That's pretty cool.
10:24 Yeah.
10:25 Neat.
10:25 Yeah.
10:25 So I'm pretty excited to see them doing this.
10:27 This is really cool.
10:28 I don't know a whole lot more.
10:29 I think this is a really cool thing that's out there, and I wanted to shine a little bit of a light on it because I think Django and SQLAlchemy get most of the sunshine.
10:37 Yeah.
10:38 So I told you that DigitalOcean, you can go push that button and create a machine learning thing.
10:41 But what if you don't know about machine learning?
10:43 Which I'm kind of in that camp.
10:45 I know most of the buzzwords, but I haven't really done much work in it.
10:49 So I was excited to see that there was somebody that put up a repo, a GitHub repo, called Machine Learning Basics.
10:57 And the idea behind this is it's a repository of a lot of the machine describing and showing a lot of the machine learning algorithms,
11:08 but not necessarily how you would do it in production because in production you've got all these fancy server tools that you can use to make things really fast.
11:18 But if you're just trying to understand the concepts, I want to see the code.
11:23 And so what they've set up is a bunch of Jupyter Notebooks, actually, to go through and describe how you would do it in raw Python.
11:33 How would you do, what does it mean to do linear regression or logistic regression or K means clustering or K nearest neighbor?
11:41 And there's a bunch of different algorithms there.
11:44 And if you're just sort of learning what these are, being able to look right at the code and being able to play with it,
11:51 I think that that might help before you jump into using some of these extra tools.
11:55 I think this is really cool.
11:57 And it's super simple.
11:58 The pictures and graphics are really clear.
12:00 The notebooks are just a couple of pages.
12:02 And yeah, it's just pure Python, right?
12:04 It's not like, oh, you call this thing a TensorFlow, then magic, magic things happen, right?
12:09 It really shows you the steps.
12:10 So quite nice.
12:11 Right.
12:11 I mean, when I'm just learning stuff, I don't need it to be fast.
12:15 I just, and I don't need to hook up to TensorFlow right away.
12:18 I don't even, I just want to know more about this stuff.
12:21 This is a great thing.
12:22 Yeah, definitely.
12:23 Yeah, well done.
12:25 And if you're getting started in that, definitely check that link out.
12:28 All right.
12:28 So final thing I want to talk about is Severus.
12:31 Very cool name for a project.
12:32 It is a cool name.
12:34 So it's got this, I think, Greek name.
12:37 I'm not sure.
12:37 So it's the name for the god or the character that is the watchdog of Hades, whose duty it was to guard the entrance.
12:45 So the idea is that this is a validation framework created by Nicola Ioroshi.
12:50 And what you do is you can give it like a schema.
12:54 So the schema is a dictionary.
12:56 It has the names of the fields.
12:58 And then you can do type validation, min max validation, all sorts of different things that you can plug in there.
13:05 So you create this dictionary that's where it says, these are the fields I want to validate.
13:09 And here's their types and restrictions and whatnot.
13:12 And then if you receive any form of document, it could be from like a rest post.
13:18 It could be something you'd read out or write to a database, whatever, any kind of dictionary.
13:22 You can just say validate this.
13:23 And it'll go through and validate.
13:25 So like make sure that, say, the name is a string or if you say the age is five, but in your schema you said it's an integer and the minimum is 10, you'll get an error back.
13:35 Sorry, there's a problem or a set of problems.
13:37 One of them is the age and the min value is 10, but you get five.
13:40 Okay.
13:40 What do you pass it?
13:41 Is it JSON or?
13:42 No, it's just a dictionary.
13:43 Okay.
13:44 Yeah.
13:44 So it looks very JSON-y, but you just give it any dictionary.
13:47 And so anytime you're reading data that comes in in a dictionary form and you want to validate it, this is a really rich and extensible way to do that, right?
13:56 So quite cool.
13:58 That's a great way to write at your API level to make sure that bad data doesn't go down to the rest.
14:04 Then you can simplify your code in the rest of your project because you can assume that data is going to be in the right forms.
14:11 Absolutely.
14:11 Like these fields are required.
14:12 It has to be this format.
14:14 You don't have to go, okay, well, I know it comes in the string.
14:16 Can I convert it to an integer?
14:17 No, that's an exception.
14:18 Okay.
14:18 So then I'm going to capture that error and say it back, right?
14:21 There's just so many like if statements and like clauses for testing.
14:24 And you could just define these schemas in one place, call validate when you get the data and off you go.
14:29 It's really, really nice.
14:30 Nice and really very cool that you put that as a separate project so that other projects can use it.
14:35 Exactly.
14:35 So this is used in the E framework, which is a restful framework based on Flask and Mongo.
14:40 But instead of baking that into the framework, it's like I'm going to create this validation thing, which is totally separate.
14:45 It makes sense to be used wherever, but it just also happens to be the validation layer in the rest framework.
14:52 So quite cool.
14:52 Neat.
14:53 Yeah.
14:53 Very, very neat.
14:53 All right.
14:54 For all the cool things you found.
14:55 Yeah.
14:56 Thank you.
14:56 Bye.
14:57 Hey everyone.
14:59 Just a quick bit of news before we get out of here.
15:01 When Brian and I recorded, I didn't have anything to share, so we didn't talk about it.
15:05 Since then, I've just launched a new course over at Talk Python Training, and it's called 100 Days of Code with Python.
15:13 So if you're thinking about doing 100 days of code or you want this big challenge where you write a little bit of code each day,
15:20 check out the course at talkpython.fm/100 days.
15:23 So 100 days.
15:25 Thank you for listening to Python Bytes.
15:28 Follow the show on Twitter via at Python Bytes.
15:30 That's Python Bytes as in B-Y-T-E-S.
15:33 And get the full show notes at Python Bytes.fm.
15:36 If you have a news item you want featured, just visit Python Bytes.fm and send it our way.
15:41 We're always on the lookout for sharing something cool.
15:44 On behalf of myself and Brian Okken, this is Michael Kennedy.
15:47 Thank you for listening and sharing this podcast with your friends and colleagues.