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


Transcript #66: Wait, NoSQL with ACID and transactions?

Return to episode page view on github
Recorded on Thursday, Feb 22, 2018.

00:00 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 66 recorded February 22nd, 2018. I'm Michael Kennedy.

00:10 And I'm Brian Okken.

00:11 And we have a ton of stuff. As usual, we've scoured the web and actually, I don't know about you, Brian, but I had a really hard time actually picking the topics. Everyone I found was better than the last one.

00:20 It's exciting to see a lot of content out there.

00:22 content out there. Yeah, for sure. So I want to say real quick, thanks to roll bar, check out what they're doing at Python bytes, that FM slash roll bar, add a reporting and real time monitoring to your web apps and other things. We'll talk more about them later.

00:35 Right now. Let's focus on modern Python a little bit. I wanted to bring up there's, there's a lot of tutorials on how to do object oriented programming and also object oriented programming in Python. But real Python put out a object oriented programming in Python 3, which I think is just a nice update, just making sure that everybody understands currently how to do things if you want to do classes and objects and inheritance. And to be clear, all of Python is object oriented. It's just everything's an object. I hope that's true.

01:09 Yeah, even functions and numbers and all that stuff.

01:12 this is meaning is if you're going to define your own classes, how to go and how to go about doing that. And this is a pretty nice tutorial. The one thing one of the reasons why I wanted to call it out is there's a reason I'll get to later, but he kind of didn't brush by construction. So if you came from c++, one of the things that c++ does is it calls your base class constructors automatically. And I wanted to just call that out, right, especially if they're parameterless, right?

01:42 Like it'll just happen straight on the stack, right?

01:45 Do you have to be explicit?

01:46 Yeah.

01:47 - But in Python, you do have to be explicit.

01:48 If you override init, the base class init will not get called unless you call it yourself.

01:54 And there's been many incantations of it.

01:56 And I think the recommendation right now is to just call super.init with it to call the base class constructor.

02:03 - Yeah, yeah, definitely.

02:04 Very, very cool.

02:05 Worth checking out.

02:08 It really digs into the object model and inheritance and all that kind of stuff.

02:13 So if that's a little bit shaky to you, definitely check it out.

02:16 Even has some little exercises and examples in there, right?

02:18 - I guess also if you're, not a bad thing to brush up on if you're just about to go into an interview, probably.

02:25 It's a nice article.

02:26 Also, pay attention.

02:28 I've been playing with adders a lot if I need objects.

02:31 So make sure that it's a really easy thing to pick up if you wanna check that out as well.

02:36 - Yeah, that's cool.

02:37 is pretty sweet. Definitely a lot of really solid people make it a great recommendation.

02:42 So it appears frequently at the end as the featured PyPI package on Talk Python, for example.

02:49 So you want to stay on a GUI trip for a while? How about we keep going? We really opened a bag, man. When I started that, it really kicked off a, "Oh, but Michael, did you hear about this? Did you hear about that?" And I'm happy I did, and I love all the things people are sending us, learned about WX Python Phoenix, which I only knew about the older version, which is really awesome.

03:10 I learned about GUI, G-O-O-E-Y, and WUI, all these other interesting things.

03:15 So I come to you, Brian, this week with yet another thing called scripted forms.

03:20 So tell me, how's your markdown?

03:22 - I love markdown.

03:23 Use it all the time.

03:24 - Yeah, markdown's not hard.

03:25 Yeah, it's not bad, right?

03:26 So here is a project in Python that lets you basically sketch out a UI in Markdown, then it becomes an interactive GUI with input fields and everything.

03:40 - Oh, okay.

03:41 Neat, I gotta check that out.

03:43 - Yeah, so for example, like you want the title, like a big title at the top of your form, your window, hash, space, type out the title.

03:52 (laughing)

03:53 Isn't that cool?

03:54 - Yeah.

03:55 - Yeah, so you can do all sorts of interesting things in there.

03:58 It's not like a lot of these are not totally general purpose.

04:02 But if you want a simple UI, check out this thing called scripted forms.

04:07 Of course, we're linking to it in there.

04:08 And you just basically sketch it out.

04:10 And it runs actually on Jupyter.

04:12 But the way it gets packaged up is you just see like a desktop window pop up and then it's interactive.

04:19 So it's pretty cool.

04:20 They got some examples and all kinds of stuff.

04:22 You can have like sliders and live graphs.

04:24 And so this looks particularly interesting to data science-y folks who have that kind of display stuff going on.

04:31 - That's cool.

04:32 - Yeah, it's cool, right?

04:33 So, scripted forms, there's yet one more way in which you can create niche Python GUI apps and then bundle it up with something like PyInstaller.

04:40 - I'll definitely want to try that.

04:42 - Yeah, yeah, I do as well.

04:43 So, do you know that I'm a fan of MongoDB?

04:46 - Yeah, you're like the Uber fan.

04:48 - I am the Uber fan.

04:50 I love it, I talk about it, do stuff with it all the time.

04:52 Like for example, Python Bytes the web app is driven by MongoDB, for example.

04:57 But you actually, you are the one to bring the big news, not me, on MongoDB these days, right?

05:01 - I guess so, I was surprised, but I grabbed it.

05:05 The news that came out on the 15th was that MongoDB will, and it doesn't do it right now, but in the 4.0 release, it will do multi-document transactions and have ACID data guarantee, integrity guarantees.

05:21 - That's kind of blowing my mind.

05:22 Like one of the big things that Mongo's done is really focused on, we're gonna treat the document level record as the thing.

05:31 That way we can do sharding and auto scale out and all kinds of stuff and not worry about like communicating across machines and clusters and all the other pitfalls you can run into by trying to do like really complex transactions.

05:45 So this, you're right, this kind of is, I didn't see this coming either.

05:48 - So this is due out in the summer.

05:50 So the 4.0 is supposed to do transactions and the 4.2, which is the, I'm not sure when that's coming out, that will even deal with transactions across sharded deployments.

06:02 - Wow, that's really cool.

06:03 And it has snapshot isolation.

06:06 So even the sort of repeatable read type stuff.

06:10 Very cool.

06:11 So yeah, they said sometime this summer, right?

06:12 - The ability to do transactions and hopefully we'll get things like rollback and things like that.

06:18 These are a lot of the reasons why people don't choose a document database.

06:22 And so that changes the table of pros and cons.

06:25 It definitely changes the trade-offs that you're considering.

06:27 I just find working with these document databases so much easier.

06:31 Like the last time I ran a migration, or worried about upgrading my database schema to match a new deployment, was never.

06:40 Like I literally have not had to run any form of update script for the last two years on training.python.fm, on Python bytes, or any of these things, right?

06:50 Like, they just adapt, and it just makes the sort of living with it so much easier, and so I'm really happy to see it get one more check in the sort of comparison table, in that column.

07:01 - Yeah, definitely.

07:02 - Yeah, very cool.

07:03 So if I did mess up my schema, something went wrong, though, my web app would crash, that would be bad.

07:08 And actually, working with Mongo Engine, you can like basically take the site down, consider like not read records if it thinks it's inconsistent with them.

07:16 So that's a different type of problem.

07:17 Same thing happens with SQLAlchemy.

07:19 But if I did that, and I had rollbar installed, like I do, we would know about it right away, we get little notifications in Slack and email and pop ups and stuff saying, hey, the site is down, something has gone terribly wrong.

07:33 Like just the other day, I was sitting around and I started getting all these notifications of something going wrong with the site.

07:38 I'm like, Oh, what is this?

07:39 I've fired these, you know, like on Python bytes and talk Python and whatnot.

07:43 And I pull up roll bar and it says, cannot find MongoDB server, how about that?

07:47 And the reason is the digitalization of the host was actually patching the underlying Linux servers for the Spectre and Meltdown vulnerabilities.

07:57 So they had to take the machines down and they didn't do it in like a controlled way because they're just like, we're telling you at some time we're taking the machines down, we've got to fix this.

08:05 So even when it's not your fault, you'll know about it if you have this installed and you can at least switch up a dialog or something on a page saying, "Oh, site's under super maintenance "right now, sorry." - Yeah, that's cool.

08:16 - Yeah, so super easy to install it, not much work at all, plugs into all the web frameworks.

08:21 Check it out at pythonbytes.fm/rollbar.

08:25 So another kick that you've been on for a while, Brian, is Python packaging.

08:30 - Yes.

08:30 - We talked a lot about what the right structure that is and all those various things.

08:34 So this week I wanna feature this thing called Python packaging pitfalls.

08:40 It's not super new, but I thought it might be fun to cover anyway, because we talked a lot about it and we haven't covered this.

08:47 So a couple of items that I don't know how many there are probably 1012 little things, don't forget to do this, don't forget to that.

08:56 Like don't forget, you know, so if you're doing packaging, you might forget to clean the build directory before you do it, or you forget to specify package data, or using package underscore data or fine grained package data, all sorts of mistakes that are listed there.

09:11 And it says, why it's really nice.

09:13 The article says, why is this a problem?

09:16 How do you fix it?

09:17 Like hard coding your packages in the setup py versus like discovering the packages with Python code in your setup py.

09:25 Yeah, these are all great tips.

09:26 I haven't read this for a while.

09:28 I mean, remember reading it a couple years ago, to try to make sure that most of these look like they're still valid.

09:34 Yeah, I think so.

09:35 One of them that might be a nice and close for you is your test the installed code, they test what's actually in your working directory, rather than running the setup and testing the thing that actually was the result of that.

09:49 Is that one of the things to avoid?

09:51 That's one of the last things to say, be careful of, make sure you test the actual install result, not just your code on development.

09:58 Yeah, and that's one of the reasons why I really like Tox is because Tox creates like like these clean environments.

10:05 But you still have to be careful of that, even with talks.

10:08 That's why we talked about using a source directory.

10:11 - Absolutely.

10:12 So a while ago, I had a bunch of authors, including you on Talk Python, about writing.

10:18 And some people were asking, how do you become a better writer?

10:23 And you said, by writing.

10:25 (laughing)

10:27 Right, just get out there, blog, write, do things like that.

10:30 So you came across something like that again this week, right?

10:33 I came across an article called "Blogging Principles I Use" by Julia Evans, which I think is cool.

10:40 She goes by Bork on Twitter with a zero.

10:43 But I'm just going to read through her tips and then we can talk about them.

10:47 Be honest about what you know.

10:49 Try not to write anything too long.

10:51 Be positive.

10:52 Write for the past you.

10:54 Stick with your own experience.

10:56 It's okay if not everyone likes it.

10:59 And a lot of these really hit home with me.

11:03 One of the things, try not to write anything too long.

11:05 I tend to try to completely get my head around something and not want to write about it until I completely understand it.

11:14 And then sometimes I don't have time to do that.

11:16 And I think that's too bad.

11:18 And I love it when people just have a couple screens full of information of just, "Hey, I learned this neat new thing.

11:25 Here's how to do it." And just go and teach it so other people can learn from you.

11:30 It doesn't have to be huge.

11:31 So be okay with short things.

11:33 - If you do short things frequently, that's probably better than saving up that one long post that actually never gets written, right?

11:40 - Yeah, also one of the things you can do is with metrics as well, if you, instead of writing a long blog post that has like five subtopics, write five different posts, and then you can find out which piece of this resonates more easily.

11:55 Your metrics will just point it out.

11:56 - Yeah, that's a really good point.

11:57 - The last one is it's okay if not everyone likes it.

12:00 And her example actually is, she's got a, I forget which article it was, but one of her articles is more popular than others and she needs to remind herself to not try to keep up with that.

12:14 It would be a mistake to try to hit that every time.

12:16 That's actually something that hits with me is I haven't been blogging a lot lately.

12:20 I do want to pick it up.

12:21 I think I need to, it will help me to try to write shorter stuff.

12:26 And also, I've got a few tutorials out there that are really popular, and I don't know how to beat that.

12:32 So don't try, just write little things.

12:35 Like I learned a few new things during the webinar today.

12:39 I learned some new things about PyCharm, and I could just write a short blog post about cool things I learned about PyCharm today.

12:47 - Yeah, that's awesome.

12:47 - Why not?

12:48 - Yeah, why not?

12:49 And definitely, I feel like these little series ones are real nice.

12:53 I've done several.

12:55 I'm gonna blog 10 blog posts in this kind of theme.

12:58 And those turn out to be really easy to write.

13:00 But I also find that I periodically get distracted and just life gets in the way and I don't finish them.

13:05 I'm like, here's the top 10 and they have seven filled out.

13:09 So I think that's a really great way to do it, but maybe actually write the 10 and then do the, hey, I'm doing a series on it.

13:16 You know what I mean?

13:17 Like kind of do it in reverse a little bit to bring it together what you've done.

13:21 I think that one of the takeaways I would add is like, It is so hard to predict what is going to be popular and what is not gonna be popular.

13:29 It's just, you know, you look at things and you think, oh, this is gonna be so popular, and it gets like 100 views.

13:35 Like, you're like, I guess I'll throw this out.

13:37 Why not, I got a half hour, and it's kind of on my mind.

13:40 And maybe it won't matter, like it's thousands or hundreds of thousands of views.

13:44 You're just like, okay, why is that?

13:46 Like this, right?

13:47 So, just put stuff out there, and it will happen.

13:49 - I think the, right for the past you, I fall into this trap of trying to write for, either write for experts and try to impress the people that know more than I do, which that's a bad place to try to be.

14:03 And trying to write for absolute beginners, but I haven't been an absolute beginner for a long time, so I don't really know how to do that.

14:10 So I think writing for me a month ago, if I would have read this article a month ago, it would have saved me time.

14:17 So just write it down.

14:19 - Yeah, yeah, absolutely.

14:20 Very cool.

14:21 We spoke about pipenv a while ago, but I want to bring up something that I just, I don't know why I found this, I just randomly ran across this.

14:32 So I was looking at pipenv again for something.

14:35 So pipenv is a way to kind of package up virtual environment, dependencies, requirements.txt, pip, activating the virtual environments, all that kind of stuff into like one little workflow.

14:47 And now, Kenneth writes is behind this in a significant way.

14:51 But I somehow was looking across it and I saw it on github.com/pypa, the Python packaging authority slash pipenv.

15:00 Interesting.

15:01 And then I scrolled down it says pipenv, the officially recommended Python packaging tool from python.org.

15:08 Free as in freedom.

15:09 Did you know this is the official way like pip and requirements.txt is apparently out?

15:14 No.

15:15 I didn't either.

15:16 Wait, what?

15:17 I mean, I know there's pip file and pip file.lock and all that kind of stuff, but it seems to me, reading this at least, that, 'cause this comes from PyPA, that pipenv is the way we should be doing things.

15:27 So I don't know about you, but I need to study this and kind of get in touch with it, because I feel a little bit lost when I use pipenv.

15:35 And I'm really confident with pip and requirements.txt and all the stuff I do there.

15:40 - I guess I'm comfortable with pip and setup files, so I will have to read up on this too.

15:45 So do you know if you can just get away with doing this and then pushing a package up to IPI?

15:52 - I don't know, but one of the things you can do is you can tell it to generate a requirements.txt from its behaviors and its lock files and stuff.

16:04 So let me give you the quick workflow.

16:06 If you go there, there's a docs.pipinf.org, which you can go to, and it has a nice little screencast from Kenneth Wright.

16:12 It's like four minutes.

16:13 It says, let me show this new tool.

16:15 I've been working on it with a bunch of people and it seems really nice.

16:19 Here's how it goes.

16:20 And so you just go into a directory, no virtual environment, nothing set up, and you say pipenv install a thing.

16:27 And if it's never run, it will create right there, what is it, a pip file and a pip.pipfile.lock.

16:34 And it will somewhere in like your temp working area create, not in that folder, somewhere else, create a virtual environment and install it into that.

16:42 If you type pip install a pip and install another thing, it'll put it into that same environment 'cause it now is like tied to the pip file and it'll actually automatically add the requirement to your pip file and to your pip lock.

16:53 And the pip file is like requirements.txt.

16:57 The pip file.lock is like that plus the dependencies.

17:00 So it's like pip freeze everything, not just what you pip installed.

17:05 So it's pretty cool.

17:06 And then you could just pip shell, pip M shell to kick it off, or you can find the, There's a command for finding the virtual environment.

17:14 So then you can, you know, source activate it just traditional, like traditionally.

17:18 - Okay.

17:19 And actually the video is like the reason why I gave it a shot because just reading about it confused me even though I read it like seven times.

17:27 - I know, I was like, why is this bouncing off me?

17:29 - But then you watch him use it in like this little couple minute video and it's like, oh, okay, that's easy.

17:33 - Yes, exactly.

17:34 Another thing I like about it is it says Windows is a first class citizen in our world.

17:39 - Wow, that's rare.

17:40 - That is, it's really nice.

17:41 I have a Windows 10 setup, but I typically work on my Mac.

17:45 But I know many, many people in the world use Windows, especially in large enterprise environments, and having Windows be a first-class citizen in the Python space is good for everyone.

17:57 - Yes, this is neat.

17:58 - Yeah, so just really the news for me is it's a review of pipenv, but the fact that it seems to be the officially recommended way over the traditional ways we've been doing it means I need to pay more attention.

18:09 Yes.

18:10 Very cool.

18:11 All right.

18:12 So that's our set of items for the week.

18:15 You just did a webcast, right?

18:17 Which you will probably have live certainly by the time this goes, well, probably by the time this goes out.

18:23 Well, it was already live.

18:24 It was live this morning.

18:25 Well, I mean, the recording will be out and available.

18:28 Recording should be out.

18:29 Yeah.

18:30 That was with, yeah, the JetBrains PyCharm team.

18:33 And that was super fun.

18:34 I had a good time.

18:36 We talked about using pytest within PyCharm, and we just scratched the surface.

18:43 There's a lot more to cover, but it was fun.

18:44 - Sounds really cool, awesome.

18:45 So we'll definitely link to the video next time, I'm sure, 'cause we'll know where it is.

18:51 Also, I have two quick follow-up items.

18:53 One is the pandas, the whole pandas project, super important in data science.

18:59 I'm sorry, I forget the guy's name who sent it to me.

19:02 I got a message saying, And hey, we're having this really interesting idea of the pandas documentation sprint.

19:10 And these are throughout the world.

19:14 And to say how many locations I don't know, quick, quick counting, let's say 15 locations throughout the world slightly biased towards Europe, but also everywhere.

19:24 But apparently Australia, or Antarctica, there's these physical locations like San Diego, Seattle, so on, where people are getting together to do sprints on the documentation for pandas.

19:39 That happens on March 10, 2018.

19:42 So a couple weeks.

19:44 Yeah.

19:45 And it has a countdown all the way down to the seconds.

19:48 Definitely has a yeah, down to the second we start now.

19:50 I think this is a cool idea if you've never contributed to open source and you want to get that checkmark on your resume.

19:58 And you want that on a major project.

20:00 a really cool way to become a contributor to pandas without deeply understanding it or having majorly adding a feature.

20:09 And also you get to hang out with people who are experts in pandas.

20:12 And so those are probably good connections to make.

20:14 So check that out at python dash sprints dot GitHub to IO slash pandas.

20:19 That should be fun.

20:20 Yeah.

20:21 And every open source project will love you if you write documentation for it.

20:25 Yes, absolutely.

20:26 Okay, so really great.

20:28 Then the other item I wanted to follow up with is we talked about the workflow in Unreal coming from Autodesk, I think.

20:37 Anyway, really, really cool stuff that they're doing there.

20:40 And now someone followed up and said, "That's really great.

20:43 Do you know you can now embed Python in the Unreal Engine 4?" There's this project called Unreal Engine Python, and it lets you just embed there.

20:53 So it's like a plugin for embedding the entire Python VM, three or two in there.

20:59 And then you can basically add scripting into your game and let people write Python and control your 3D environment.

21:07 Pretty cool.

21:08 So just a quick follow up from when we talked about that before.

21:12 Thank you for being here.

21:13 It's great to chat with you and I love your pics this week.

21:15 - Thank you, you too.

21:17 - Bye.

21:18 Thank you for listening to Python Bytes.

21:19 Follow the show on Twitter via @PythonBytes.

21:22 that's Python bytes as in B Y T E S and get the full show notes at Python bytes dot FM. If you have a news item you want featured, just visit Python by set of him and send it our way. We're always on the lookout for sharing something cool on behalf of myself and Brian Akin. This is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page