Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #34: The Real Threat of Artificial Intelligence

Return to episode page view on github
Recorded on Wednesday, Jul 12, 2017.

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:05 This is episode 34, recorded July 12, 2017.

00:11 I'm Michael Kennedy.

00:12 And I'm Brian Okken.

00:13 And we've got some great stuff to share with you.

00:15 But Brian, just let everyone know, this episode is brought to you by Rollbar.

00:19 So check them out at pythonbytes.fm/rollbar for some good stuff.

00:23 We'll tell you about that later.

00:24 Right now, I want to hear about logging.

00:25 Yeah, I'm one of those people that know that I should use logging more instead of just print statements.

00:31 But to say it like mildly, the standard library logging package is non-intuitive.

00:38 It's definitely not obvious.

00:39 Yeah, you're like, I got a logger.

00:40 It doesn't work.

00:40 Why?

00:41 What do I do now?

00:42 Yeah, the setting up the config and stuff.

00:43 And I get, anyway, I still get confused about it.

00:46 So I am welcome to look at, or I welcome new logging packages to try to clean that up.

00:53 And there's an article that came out, easy Python logging with Daiquiri.

00:56 And Daiquiri is a logger that works a little bit.

01:02 It's a little bit cleaner and works pretty good.

01:04 I played around with it a little bit.

01:06 But it uses colors in the terminal, of course, which is nice.

01:10 It supports file logging.

01:12 And it's supposedly journal D, which I have no idea what that is.

01:16 I like some of the features of it.

01:18 And what I really like about it is that it just sort of works right away.

01:22 You don't have to do much setup.

01:23 Although you do have to call, like, a get logger and call a setup function.

01:27 But it's not too bad.

01:28 Yeah, it's really similar to the built-in logging, actually, which is super nice.

01:33 And the two things that I like, one is the, well, three things.

01:36 It works just like you create it, and it works.

01:38 You don't have to go and configure it a bunch.

01:40 The other thing is that it prints color messages to standard out or standard error.

01:47 So if a thing is an error, it comes out red.

01:50 If it's good, it comes out, like, bluish or, you know, warnings or yellow, things like that.

01:54 Yeah.

01:54 It does have some, I can't remember what the dependencies are, but it does have some dependencies

02:00 that tripped me up at first when I was installing it.

02:02 Don't know why.

02:03 But then it was easy to install.

02:04 Not too bad.

02:05 Yeah.

02:06 The other thing that's sweet is it does native logging of exceptions.

02:09 So even if you don't catch the exception, it'll, like, print out the exception details, right?

02:14 Oh, yeah.

02:14 That's cool.

02:15 I missed that.

02:15 Yeah, yeah.

02:16 That's slick.

02:16 And then as I was thinking about this today, I just saw somebody mentioning log zero.

02:22 So I went and checked that out this morning.

02:23 And there's a link to it in our show notes.

02:26 But it's also pretty clean, and it has no external dependencies and also does color on the output.

02:34 And a little bit, I mean, if you're doing a quick and dirty thing, it's a little bit, you

02:39 don't, there's no setup required at all.

02:40 Yeah, that's pretty interesting.

02:42 Anyway.

02:42 And the logo of that one is like a beaver with a hard hat and, like, some plans, which is pretty

02:48 interesting.

02:48 Yeah.

02:48 One of the things I'd like to say about Daiquiri is I really had to check my spelling on it.

02:54 The first time I downloaded it, pip installed it, no problem.

02:57 And then I went to import it, and I spelled Daiquiri wrong.

03:00 So it's a D-A-I-Q-U-I-R-I.

03:04 Yeah, I'm not sure I would spell that correctly off the, you know, just off the top of my head

03:09 either.

03:10 But both are fun projects, so check them out.

03:12 Yeah, yeah.

03:13 If you're throwing logging in there, also check out Logbook, another good one.

03:15 Logbook, okay.

03:16 It's by Armin Roedeker from Flask.

03:19 I'll check that out.

03:19 All right, so I have kind of a deep article, a deep thought for us on the next one.

03:23 Python is probably the biggest space where artificial intelligence is done, right?

03:27 Like a lot of the AI machine learning algorithms come out for Python first, or at least come

03:33 with Python right out of the box, right?

03:35 So TensorFlow, Keras, and a bunch of the other things that you might do would probably be done

03:43 in Python.

03:44 So there's this interesting article that was in the New York Times of all places that I'm picking

03:49 it from called The Real Threat of Artificial Intelligence.

03:52 And, you know, we so often hear people talk about AI and the singularity and super scary stuff.

03:59 Like Elon Musk last year said that he's pretty sure that we live in a simulation, which I'm

04:04 pretty sure is silly.

04:05 What do you think about that?

04:07 That's pretty silly.

04:08 Yeah.

04:08 I mean, it's a fun mind game to think.

04:10 It's like a philosophy, you know, prove you exist sort of thing.

04:13 But how real is it?

04:15 And even if it is real, what can you do about it?

04:17 Whatever.

04:17 It doesn't matter.

04:18 But this article kind of says, all right, let's look at really what the implications

04:23 of AI for society are, right?

04:27 So AI is going to be reshaping work and what jobs mean.

04:33 And I'm not sure if it'll affect programming or not, whether AI will actually replace programmers

04:39 or we'll just program AI.

04:41 You know what I mean?

04:41 Like we just might shift around a little bit.

04:43 But if you do anything with AI, I recommend you check this out.

04:47 It's really interesting on the effect that it's going to have on the industry, basically

04:51 on society in general.

04:52 And some of the things they said, well, like, you know, there's so many jobs that are going

04:58 to be dramatically affected by this.

05:00 Like I was just telling you before we started, like the number one job for men in the United

05:04 States is driving.

05:05 Yeah.

05:05 And the combination between self-driving cars and self-driving trucks and the various other

05:11 ways that automation is going to happen could easily take that down to very small

05:17 percentage of what it is today.

05:19 What's that going to mean for society?

05:21 So these kinds of things are interesting to think about.

05:23 The other part was sort of geopolitical, like how do countries sort of evolve with AI?

05:29 So once there's an AI that can solve a problem, there's probably one that is way better than

05:35 all the other attempts because they have more data.

05:37 Think of Google, right?

05:38 There are other search engines, but they don't come close to Google, right?

05:41 For example.

05:42 And it would probably be like that for AI.

05:44 And so the countries that own the powerful AIs will be even more sort of unequal with the

05:50 rest of the world.

05:51 So if you're thinking about AI, you're doing AI and machine learning stuff.

05:54 This is a really interesting philosophical read.

05:56 Yeah.

05:57 It's also not just the people with the AI, but also the people with the data sets that control

06:02 the data sets.

06:03 That's a huge part of it, right?

06:05 Absolutely.

06:05 Who's collecting the data now that can be fed to these AIs that make them stand out?

06:09 Yeah.

06:09 One of the things that I liked about this article was this kind of AI sometimes can seem still

06:15 far out, even when we're trying to think about like driving cars and stuff.

06:20 But the model that right now a use for AI is just any time where you take a whole bunch of

06:27 data to use algorithms to decide on what decision for a particular circumstance.

06:34 And like, for instance, all of the information about somebody that they turn in with their

06:39 loan application, whether or not you should give them a loan.

06:41 Well, I think it's going to be pretty fast if like a lot of loan representatives are replaced

06:47 by AI machines.

06:49 I can see that basically be instantaneous.

06:50 Yeah.

06:51 Here's my information.

06:52 I want a loan.

06:52 Okay, you can have it.

06:53 No, you can't have it.

06:54 Here's why.

06:54 Yeah.

06:55 You know what I mean?

06:55 And also like first level, I mean, they even talked about customer service.

06:59 And when we've got like voice recognition things going on that are pretty darn good.

07:05 I mean, they're not great, but they're well enough to where your first level of contact

07:11 through a phone service is probably going to be a computer not too long from now.

07:15 Yeah.

07:16 Certainly with all these like smart speaker type things, it's going to push that technology

07:19 way out.

07:20 And this article does have a bit of a dark view on the world, but just think of the stuff

07:26 that AI can do.

07:27 There's going to be a bunch of really amazing and positive stuff.

07:30 Like one practical example, then we'll move on is shout out to the partially derivative

07:35 guys, the other podcasts that I heard this on.

07:37 They interviewed some people who are using data science and AI type stuff to make basically

07:44 to solve police violence problems.

07:47 And they said, if they use machine learning to figure out that if a policeman goes and handles

07:55 like something terrible, like a suicide case, and then is immediately sent back out and

08:00 pulls over somebody who talks back to them, there's a much higher chance of police violence

08:05 against that driver because they're still upset from that previous thing.

08:09 And so, you know, that was discovered through like data science and things like this.

08:12 So there'll be a bunch of good stuff coming out of it, but some interesting effects on society

08:16 and the jobs here.

08:17 Anyway, it's something to keep track of.

08:18 Yeah, it's nice.

08:19 Yep.

08:20 All right.

08:20 So let's move from sort of society philosophy to the philosophy of physics and science applied

08:26 to programming.

08:27 There was an article called the three laws of config dynamics.

08:31 And yes, that's config dynamics for like configuration files.

08:34 And I ran into this recently myself.

08:38 I've got, and they talk, the article starts out talking about how a project can like the inception

08:44 of the birth of a configuration file for a project.

08:47 And it often centers around something like what you're connected to, what database or

08:53 what service you're connected to, and being able to control that.

08:56 Right.

08:57 Soon as you have like a dev database and a production database.

09:00 Yeah.

09:01 Then.

09:01 Yeah.

09:02 Like in the book I'm working on, I had a config file to control.

09:05 It's a little task list application.

09:08 And I support both Mongo and tiny DB.

09:11 And so I have to tell the application which one to use and where it is.

09:16 And those are things that just happen.

09:18 But the, the article after come up with like how they're created in the first place talks

09:22 about these three laws.

09:24 And one of them was a config values can be transformed from one form to another, but can not be created

09:30 or destroyed.

09:31 And one of the examples of that is some people recommend putting the config values in environmental

09:37 variables instead.

09:38 But it just doesn't really solve the problem because people just create little scripts to,

09:43 to write their environmental variables.

09:45 And then now you've got a config file again.

09:47 I love the parody to the three laws of thermodynamics.

09:49 So the total length of config file can only increase over time.

09:55 And I think that's just, if left unchecked, one of the recommendations there is to regularly

10:01 evaluate your values in your config file and see if you can condense them or combine them

10:08 or somehow limit them.

10:09 Yeah.

10:09 That's a really, that was a really interesting one.

10:11 And I thought actually, you know, it was a good reminder that these things need maintenance

10:16 and trimming and, and clean up just like the rest of your code or it can get nasty.

10:21 And this one surprised me when I read it at first is the, the last one is a number three,

10:26 the length of a perfect config file in a development environment is exactly equal to zero.

10:32 And that's saying you should be able to run an application with no configuration file.

10:37 And it should be like fairly valid because otherwise, if it isn't, then you've got to have some

10:43 way to have each developer come up with what their default config file should be.

10:48 Right.

10:49 And so, you know, for example, you could have the dev database hard coded in, but if it's

10:54 passed some other value, like a production or staging database, it'll just use that instead.

10:59 So you don't need to specify the dev database.

11:01 Similarly for like app on email, just go like, if there's nothing here, we just don't send email.

11:06 But if there's something, we'll send it to this, you know, SMTP server and so on.

11:10 Yeah.

11:10 Yeah.

11:11 And then it said, it also talked about Docker helping it.

11:14 And since I'm not a Docker user, I just kind of got lost on that section.

11:18 But yeah, I feel like, like we said before, Docker shifts programming experience to ops experience in a lot of ways.

11:26 The way they said that Docker can help is with a Docker, you can consistently name the machines, the same thing in production and in development.

11:37 And it's the same.

11:38 So like the database server could just be called DB.

11:40 The API address could just be API or whatever.

11:44 And like you have different containers running in production versus development or whatever.

11:48 Oh, okay.

11:48 That makes sense.

11:50 So you can hard code the name, but change the infrastructure to just match it.

11:54 So I want to talk about Jupyter notebooks next.

11:57 But before we do, let's talk about Rollbar.

11:59 So Rollbar has been a longtime sponsor of the show.

12:02 And I'm sure a lot of you know, right, the job of Rollbar is you integrate it into your app, especially web apps.

12:07 If there's any kind of error, it gives you tons of information.

12:09 So I'll touch on a few things that I haven't last time.

12:12 So they support Python, of course, which is great.

12:16 And, you know, that's why they're a big part of this community.

12:19 But they actually support 26 languages and frameworks.

12:22 So Python, but also Node, .NET, and they even support Flash.

12:26 So if you want to get error handling your Flash apps that you somehow got stuck with, plug it in.

12:32 And another thing that they have that's pretty cool is they have what's called people tracking.

12:36 So if you have users, like anybody logged into your app, one of the problems is if somebody reports an error to you, they say,

12:43 I did this thing and it didn't work.

12:45 You're like, oh, gosh, I've got to go troll through the log files and find it, speaking of logging.

12:49 But here with Rollbar, you can actually associate that error with a logged in user.

12:53 And then you can go to your dashboard and say, find that user and see all the errors and workflow or flow through your app they ran into to find this error.

13:02 So pretty cool.

13:03 Check them out at pythonbytes.fm/Rollbar.

13:06 It helps support the show and it's a cool product.

13:08 Before we get on to Jupyter Notebooks, I have to say I just recently cleaned out my office and found my goodie bag from PyCon and found a Rollbar sticker and slapped it on my laptop because I'm really proud that Rollbar sponsors the show.

13:22 That's awesome.

13:23 Very, very cool.

13:24 Yeah.

13:25 My Rollbar t-shirt is quite threadbare these days.

13:28 Okay.

13:28 So let's talk about five tips for getting started with Jupyter Notebooks.

13:32 How are you with Jupyter Notebooks?

13:34 Do you use them often?

13:35 No.

13:36 Yeah, I don't either.

13:37 I mean, mostly I do web stuff with tons of files and like they all got to fit together.

13:41 So the workflow is just not that way for me.

13:44 I also often feel like, you know, I should really just get in the habit of firing up a Jupyter Notebook for certain types of work.

13:50 And so this is a nice little article, I think is by the ActiveState folks, about a couple of things you can do to just like start really quickly and easily with Jupyter Notebooks.

13:59 So the five tips are don't put your entire code into a single cell, right?

14:04 You have these little cells, you put little fragments of code and the cells like work together.

14:08 So you get the output of each step.

14:10 So if you break it apart, right, you get kind of, you can execute the steps independently.

14:15 You can have the data flow from one to the next.

14:17 That's cool.

14:17 There's different types of cells.

14:19 Like you can put markdown or you can put Python code or you can put a picture, all kinds of stuff.

14:24 So you can kind of build up a story with a code.

14:26 You can execute shells with shift enter.

14:29 This is not the ActiveState guys.

14:31 This is Esri, ESRI.

14:33 Anyway, you can explore like maps because you can integrate their ArcGIS stuff into it.

14:39 And they have a really cool way to get information about modules you might not know about.

14:43 So you could type, say, like import Daiquiri and then Daiquiri question mark and hit tab.

14:49 And it'll like give you a big summary of what you can do with Daiquiri.

14:51 Oh, wow.

14:52 Cool.

14:52 Anyway, there's a few simple things you do with Jupyter.

14:55 Hopefully this inspires you to check it out and try it for when it makes sense.

14:59 All right.

14:59 What's next?

15:01 Oh, coupling.

15:02 Coupling versus decoupling.

15:03 Tell me about coupling.

15:04 Coupling versus decoupling.

15:05 So this is an article by Kent Beck.

15:08 And I've followed Kent Beck since I was reading about extreme programming and test-driven development.

15:14 Yeah.

15:14 He's one of the original agile manifesto guys, the extreme programming, pair programming, all that stuff from back in the day, right?

15:21 Yeah.

15:21 And I ran across this article and I was confused.

15:25 At first I was confused.

15:26 It's called cost of coupling versus cost of decoupling.

15:29 And I'm like, why is he writing on like posting this on Facebook?

15:34 But he works at Facebook.

15:36 So that makes sense.

15:37 So anyway, two elements are coupled with respect to a given change.

15:42 If the change, changing one element implies changing the other.

15:45 So that makes sense for coupling.

15:47 So when you're writing tightly coupled code, it's hard to change things because things, every time you change one thing, you got to change a bunch.

15:55 Like if you've got, if you do copy and paste coding all over the place, then if you fix the algorithm, you got to fix it everywhere.

16:00 The other thing, other places where coupling often creeps up is very tightly coupled test and implementation.

16:08 So if you, with mocks and whatever, and if you, if you decide to change, change part of the design, you got to change all the tests.

16:15 So some people are okay with that, whatever.

16:18 But, and decoupled code is the opposite of that.

16:21 It follows the dry principle and uses smaller components or whatever.

16:25 But the nice decoupled code also takes more time to write and design initially.

16:32 So the article is just talking about thinking about the costs of both and making sure and understanding that there are places for both of them in your development.

16:42 And Kent splits it into explore and extract.

16:45 And that's, maybe those words are more meaningful to him, but that isn't very obvious to me.

16:51 So the explore phase being like a spike projects or your first draft of your implementation or happy path.

16:59 The point of that, your first writing through a project is just learning about it, answering questions quickly and,

17:06 and learning enough about the, whatever you're working in to, to ask better questions as you go along.

17:13 And then the extract phase is more like a final draft or architected stuff.

17:18 Economies of scale take over and you need to minimize the cost of changes so that you can,

17:24 you know, you know, the opposite of that.

17:26 Yeah.

17:28 Well, I think one of the things that's interesting about this is, you know, it's,

17:32 it's easy to like study design patterns or these types of things and say,

17:37 Oh, I'm going to apply this to like everything I do from now.

17:39 Cause this is amazing.

17:40 But if you're building something that's 5,000 lines and is like, just, you are going to work on it.

17:47 You're just going to be spending extra effort to make these, to apply these patterns and this decoupling and whatnot.

17:54 When you could just write it and be done.

17:57 Whereas if a team of 10 people is working on it and it's a hundred thousand lines and it's got to live a long time and be maintainable and evolve.

18:04 Well then, you know, these things make a lot more sense, right?

18:06 So definitely think about the trade-offs.

18:08 Yeah.

18:08 And also as you're like a more, as your project goes into maturity, the, the code base is going to get larger and it's going to cover a little corner cases.

18:17 So it is necessarily going to be your tests are going to cover those little corner cases and they're going to be more tightly coupled as well.

18:27 So it was a good to think about and to make sure that you okay with hacking things together at first, if, if you're learning stuff.

18:34 Yeah.

18:34 Sometimes it's worth it just to hack it together.

18:36 All right.

18:37 Last one for me is just an inspirational little project.

18:41 Something a lot of people out there ask me like, Hey Michael, I want to get started in programming in Python.

18:46 I want to build up some kind of portfolio that I could show people to get a job or to get a promotion or whatever.

18:55 Right.

18:56 So the guy who was over at PyBytes, not Python bytes, PyBytes, P-Y-B-I-T-E-S.

19:03 That's Bob and Julian.

19:04 You can see the link in the site, the show notes.

19:08 They did a hundred days of code challenge.

19:11 Have you heard of this, Brian?

19:12 Well, I've been sort of following them along with this.

19:15 They're pretty good at giving information about what they're up to because they had part of their challenge was they wrote a bot that would automatically tweet the process, their progress each day.

19:26 And there's a hundred days.

19:27 So they were just going after it.

19:29 One of the things I wasn't clear on, did they start the hundred days of code or did they?

19:33 I don't think they started it.

19:35 I think they said, we're going to do it for Python.

19:37 Okay.

19:37 Yeah.

19:37 And so they wrote, they found out they have all sorts of stats and pictures and stuff.

19:41 So the article, the writeup that we're referencing is really cool.

19:44 They wrote about 5,000 lines of code split across obviously 100 scripts per day.

19:50 And the number of lines was like between 50 and 200 per day, which is kind of an interesting thing.

19:55 They've got a whole bunch of projects.

19:57 They've got 10 projects that they built that they showcased.

20:00 And they're really, some of them are really neat.

20:02 Like I said, they auto tweeted their progress.

20:06 They ran some stuff, some analysis across their scripts, their 100 scripts and figured out they

20:12 used exactly 100 modules.

20:14 Wow.

20:15 So weird coincidence, right?

20:16 So a hundred different modules as part of it.

20:19 And their next a hundred day project is going to be around Django.

20:22 So if you're interested in Django, you know, follow them on Twitter or however they send out

20:27 their messages and about this stuff.

20:29 But anyway, if you're interested in like getting started, check out their article.

20:34 It may help you have some concrete things, small concrete daily things you can do.

20:39 And a hundred days later, you'll have a lot more experience.

20:42 Yeah.

20:42 I think it was Bob that was at PyCon.

20:44 Yes.

20:45 Yeah.

20:45 I ran into Bob and talked with him a little bit and great guy.

20:49 And I just, I like what they're doing.

20:50 They have like one person, I can't remember who, which is which, but one of them already

20:55 knew Python to begin with.

20:56 And the other one was like brand new, had never used Python before as they, as they started

21:01 the PyBytes thing.

21:02 So yeah.

21:03 Very, very cool.

21:04 All right.

21:04 What else you got for us?

21:05 That's, that's our news for the week.

21:06 What's up with you?

21:07 Good review of your book, right?

21:08 I just read it.

21:09 Yeah.

21:09 I ran across the first review I've seen so far for the book by Chris Shaver and well, the

21:16 link in the show notes, but it was nice to see a book review of it.

21:20 And it's fun to have more and more people reading it.

21:23 So it's good.

21:24 Yeah.

21:25 It was really a good write-up and summarized it well and gave it a good vote of confidence.

21:29 So I think it's well-deserved.

21:31 Nice.

21:31 How about you?

21:32 Finally, after a very long time, long journey, kind of book-like duration, the Python for Entrepreneurs

21:41 course has finally officially been finished and is ready to go.

21:46 So it's came in around 19 hours of content and you get it at talkpython.fm/launch.

21:52 So I'm super excited to be done with that course.

21:55 It came out great and move on to writing new courses.

21:58 Awesome.

21:58 Yeah.

21:58 It took so long, I actually wrote two other courses and finished them while that was getting

22:03 finished.

22:04 Well, would that have been faster?

22:07 Had you focused on one?

22:08 No, because I was waiting on other people.

22:10 I was waiting on editors.

22:11 I was waiting on Matt to do his sections.

22:13 I was waiting on PyCharm to fix a bug so I could finish another second.

22:17 There's just like lots of waiting.

22:18 So many things.

22:20 Okay.

22:20 But it's all good.

22:21 It's all done.

22:22 Wonderful.

22:22 All right.

22:23 Yeah.

22:23 So good to see our projects getting out to the world.

22:26 Well, thanks again for talking with me this week.

22:28 You bet.

22:28 And thank you everyone for listening.

22:29 See you next time.

22:30 Bye, Brian.

22:31 Bye.

22:31 Thank you for listening to Python Bytes.

22:34 Follow the show on Twitter via at Python Bytes.

22:36 That's Python Bytes as in B-Y-T-E-S.

22:39 And get the full show notes at pythonbytes.fm.

22:42 If you have a news item you want featured, just visit pythonbytes.fm and send it our way.

22:47 We're always on the lookout for sharing something cool.

22:49 On behalf of myself and Brian Okken, this is Michael Kennedy.

22:53 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page