Hey there, thanks for listening. Before we jump into this episode, I just want to remind you
that this episode is brought to you by us over at Talk Python Training and Brian through his pytest
book. So if you want to get hands-on and learn something with Python, be sure to consider our
courses over at Talk Python Training. Visit them via pythonbytes.fm/courses. And if you're
looking to do testing and get better with pytest, check out Brian's book at pythonbytes.fm slash
pytest. Enjoy the episode. Hello and welcome to Python Bytes, where we deliver Python news and
headlines directly to your earbuds. This is episode 250, recorded September 15th, 2021. I'm
Michael Kennedy. And I'm Brian Arkin. And I am Grayson. Grayson, welcome to Python Bytes. Yeah, it's a
pleasure. I've been looking so much forward to joining you guys. Yeah, you've been somebody out
there who's been giving us a lot of good ideas and topics and helping us learn about new things. So
you've been a big supporter of the show and now you are part of the show.
Yeah, I'm hurrah.
Hurrah.
Yeah, yeah, hurrah. It's, yeah, it's, I've been looking so much for it. Like, for the first
time I saw, oh, we can take part in this. I go like, oh, I should try to just get myself
in there. And here I am.
Yeah, here you are. Thanks for, thanks for doing that. That's really nice. Tell people a bit
about yourself before we dive into Brian's first topic.
Yes. Well, my name is Grayson Daniel and I'm originally from Tanzania, but living in Denmark,
married with three awesome kids. Currently, I'm a principal data scientist at NTT Data Business
Business Solution here in Copenhagen. And yeah, so accidentally became a data scientist and somehow
discovering that I was really, really good at it. Then I just started climbing my way out
thanks to the Python community and everything that is out there.
Yeah, awesome. Congratulations. Nice to see you finding your way in the data science world.
Very cool. Accidentally becoming a data scientist. That's interesting.
Exactly. All right, Brian, have people been doing things wrong?
I think so.
Including race conditions with screen sharing.
Yeah. So I just couldn't resist this article. There's an article out called Exciting New Ways
to be Told That Your Python Code is Bad, which is just a great title. And the, the,
the gist is there's two new pilot errors. So it's pretty simple. There's, but it made me think
about my code a little bit. And the first one is, is an error to tell you to consider ternary
expressions. So if you, if you have, if you've got like if condition, and then you assign a variable
in both the, the, if clause and the else clause, and it's a short thing, maybe, maybe use a conditional
expression instead and do all in one line, like say, in one, one of the examples in the blog post says,
um, X equals four, if condition else five. So ternary operators are pretty cool. and they're pretty
easy to read in Python, but I was just curious what you thought, is this, is a ternary expression
easier to read or more difficult? Well, for me, I think this is pretty nice. I'm always on the edge
about the ternary condition, the value, if condition else, other value. A lot of times it starts to
stretch out to be a little bit verbose. And then it's kind of, you know, it's not entirely obvious.
One thing I recently learned about, I don't know how it took me so long is the simpler version of that,
like variable or other option at, without the, the, if else, just the thing or that thing. Right. So for
example, if you try to get a user back, and you just want to return the user or you want to return,
uh, maybe you want to check if they're admin. If they are, you return them. Otherwise you might turn
them back. You could say something to the effect of like, you know, if I say user or a result equals
user or false or, or something like that. Some, it's not a totally good example here, but this like
super short version of value where you kind of have the return value and the test and then the fallback,
the else case, it wouldn't work in the example that I have here, but that one, I actually,
I started to really like because it's so concise. Yeah. I don't know. I think I'm very traditional.
I like reading my code up, going down. So whenever it started stretching sideways to me, I'm like,
Oh, okay. I think I just love the flow of if, then I know I have to look down for the else. Right.
But now I have to look the else from the other side. Then they, yeah, but I, well, line is,
good in some places, but in most of the cases, out of readability, I usually just try to avoid them.
Yeah, I do as well. The one thing I was thinking is interesting on the data science side,
Jason is a lot of times you're trying to take instead of statements, multiple lines,
you're trying to create little expressions that you can put together in like little list
comprehensions and other types of things. And these, these one liners become really valuable there.
Yeah. Yeah. Definitely. Definitely. Mostly when we're using lambdas everywhere, right?
Yes, exactly. Yeah, exactly.
So the, then the next error condition is funny, I think, and it's just the while is used. So it's just a
warning to say you have a while in your code. And this, the comment really is there's,
it's just not really usually good to have a while because it can, like never terminate. You can,
there's no, it's not guaranteed to terminate if you've got a while loop. So, I thought that
was interesting. I, I actually was just thinking about this the other day is that I, I don't,
I can't even remember the last time I've used a while loop in some code. So I think this,
I think this is actually pretty good just to warn people they've got a while loop.
It's pretty strong. It's a pretty strong warning to say you have used this language construct. That's
a problem. I certainly think it's, I'm on board with the, the Zen of the idea that most of the time,
a while means you're doing it wrong. Most of the time you could probably iterate over a collection
or you could enumerate and then iterate over the index and the value. But there are times where you
actually need to test for something and then break out and, and to put it as a full on warning just for
its existence. To me, it seems a bit too far, but it's, it's interesting to say the first one.
yeah, I think these are both sort of in the eye of the beholder a bit.
Yeah. Yeah. I actually been in like in our team or in my whole existence, I, I think we're using while
only once, and this is on the computer vision. So you are trying to capture videos, from the
camera and then do analysis with them. So it says, while there's a frame, keep on doing this. And of course,
you always have to catch, some way to go out of this while loop. But I think that's the
only time we use while. And we usually want one people says never use while, except when you are
doing computer vision.
Interesting. Yeah. And especially if you got things like pandas and stuff, or maybe you shouldn't even
be looping at all.
No, no, not at all.
Not at all.
Yeah. Interesting.
Interesting.
A couple of thoughts from the live stream. So Sam Morley out there says X equals Y or Z is really
handy for setting instance variables in a class, where they're using nuns. I totally agree.
Chris May. Hey, Chris says turn air is a great idea if it's simple else. Not so much.
Yeah. Brandon Brainer out there agrees with you,
that the traditional if else is probably easier to read. Henry Schreider says turn air is much
better for type type checking as well. Okay. Yeah. Probably because the type of print is more
obvious there. So yeah, pretty neat, pretty neat. Also speaking of neat stuff, what if you could have
all sorts of little placards and things about your read me? So here is a project I want to tell people
about called GitHub read me stats and get up read me stats is pretty interesting. It's, comes to us
from Poma. So thank you, Poma, for sending that in. And the description says it's
dynamically, dynamically generated stats for your GitHub read me's, but I feel like that scope is
actually way too short. It's dynamically generated little placards for wherever you want to put them
on the internet. You might want to put them on a project read me so the project can describe itself
more dynamically, but you might also want to put it on your about page on your blog or something like
that. So give you all a sense of what's going on here. If you come down here, you can have these
different, there's a whole bunch of different options. You can get like a GitHub stats card.
You can get extra pins. You can get the languages. Like for example, we could say what the languages
you are most likely to use across all of your repositories, the walk of time week stats.
there's a bunch of themes and visualizations and stuff. So I think the best way to get a sense of
this is to see an example. So I put a couple of projects in my own self in here to kind of pick
on me. So here's a image that I could add. I'll zoom that in. So I have this Python switch package
that I created a while ago when Python didn't have anything like a switch statement. So I wanted to add
a switch statement to the Python language. So I did. And apparently here are the stats of it. These are live,
right. If I refresh it, it'll regenerate it. And it gives you a little bit of info about the project,
like the name and it's little description. That's mostly Python. As it says, it has 238 stars and 18
forks, which is pretty awesome. So all I got to do to get that is to go up here and say, I want to get
the pin and I want to have the username be Mike C. Kennedy and the repo be Python dash switch.
And then this returns an image that I can put, like I said, anywhere, right? If you put this as the image
source, it'll go, it's not just like it'll only render on GitHub. It'll go wherever you put it.
So I think that that's pretty cool. Another example would be your stats. I'll refresh this
because your little animation, I can get my Michael Kennedy's GitHub stats. Apparently I have an A plus
plus, but a two thirds closed red ring. I'm not totally sure what the ring means, but kind of a
cool little graphic here. Apparently I've got 3.5,000 stars, which surprised me. A lot of commits,
73 PRs, 103 issues, 23 repositories that contributed to. I don't know if that's this year or maybe this
year, who knows? Or total. Anyway, that's kind of cool, right? You could put that on your blog or
somewhere where you're trying to talk about yourself, like you're trying to get hired or you do consulting
or something. And then the third one here is you can say your most used languages. So apparently I've
most used JavaScript, which is very much not true, but I've probably committed a ton of like
node modules to some projects that I don't actually want to have to, you know, re-NPM install.
I want to just make sure they're there for like a course or something like that. Right. But it'll show
you through the breakdown of your various languages and whatnot. So that gives you kind of a sense of
what these are all about, what the idea of this thing is. You generate these little cards and you can
put them, like I said, wherever you want. What do you think? Like on our resume page.
Yeah. Yeah. I really love it. But it's kind of sad because some most of our time is spent in GitLab and all
this other and all our commits are done there. And then when I come to my GitHub, it looks so empty and it makes my heart sick.
What has President been doing? He hasn't committed anything for a week.
Yeah. Yeah. So it's really, really awesome.
Yeah. Cool. Yeah. I guess it really only works for GitHub and that's where it's really handy, but still pretty nice.
Do you know if the stats are only on public repos or are they public and private?
It's a good question. So you can choose as a user, if you go down here and like the stuff that shows in your contributions in your GitHub profile, you can check whether you want public and private contributions to appear in that little green.
Okay.
How much contributions have you made this year by day?
Okay.
So maybe it depends on whether you've checked that or not. You know what I mean?
Probably.
But it might not.
Cool.
Anyway. Yeah. Pretty cool. A little project.
Brayson, you're up next. What you got?
Yes. Yes. Yes. So I got this one here. Actually, this is, it's something that has been covered, not covered, covered, but been mentioned.
So I could see it in footnotes as when I searched through. Actually, Brian, you covered it in episode 182 with hypermodern Python.
I think it's just a name that was there. Yeah. But it was not mentioned. I think it's just been, oh, this could be used in this hypermodern Python way of doing awesome.
stuff. And then in episode 248, it was mentioned again with hypermodern Python cookie cutter, but it's just like a footnote of, oh, it use Nox instead of Tox.
So this is really, really an awesome tool that we've been using recently because when we do machine learning, we are encountering a lot of problems where we have to test how our models are performing and how are they ethical.
So the test, when we do tests of our pipelines, we're not just testing that the models are accurate or they are doing the things that they're doing, like the API.
So we actually, you cannot just testing our API, you need to have keys and all those. We actually also have to test about the ethicalness of our models. So like if we say our models does not segregate between, let's say, gender.
So we test, we have counterfactual tests where we send different genders and see what are the models responding. Are they responding with the similar results?
So when we say it doesn't segregate between sexual orientation, then we send different inputs where it pretends to be either straight or homosexual and just try to say, do we receive the same results?
So we've been trying to run this very automatic way. And before that, we use a lot of TOCs.
But the problem is, TOCs, the way of defining your TOCs is just not Pythonic. Like you don't write this Pythonic way of doing things.
It's similar to, we had this issue with make. I really could not debug make. So whenever I made a make file, I copied from someone else and then changed some things.
Because anything I touched in, I have a syntax error. Oh, this thing is not in the right place.
And then I came across evoc, which it was almost like Pythonic. I can write everything in a Python way.
So this Nox is actually similar to what evoc did to make, but it's doing exactly to TOCs.
So in this case, you can create simple pipelines like this one here, where it creates a session, installs the package that needs to be installed, and then run whatever experiments you're trying to run.
And this is really, really handy. At least we found it really handy because you can select that it actually use the KONDA environment. Like the KONDA world has been used a lot in data science. So you can say first create a KONDA virtual environment, install these packages, and then test them.
So what I like about this tool, it's almost similar to pytest. Like if you know how pytest works, then you know how this guy works because there's a parameterization. And whenever you run tests, you can select which part of station needs to be run.
Like in pytest, we use the -k run this kind of test. And here you use the same thing, -k run only these kind of builds, right? So it is dark. We really, really enjoy that. Like you can pass in environment variable. But I actually wanted to show you the coolest part here.
-yeah. -yeah, this does look nice.
-it's just amazing. I cannot, I cannot, I mean, the guy who created this, I just give him all the thumbs up with everything that they have come up with. So it's really, really handy if you're not using it, or if you're using TOX, you should probably consider changing to NOX.
-that's cool. If you can, for example, write that you have a test and then say, I want this, you know, as a decorator, sort of parameterized. I want this to run on 2736, 3738, and it'll do that, right?
-yeah. So, so, so, so you can see, it's like this example here, right? So you can see we are parameterizing different Django. So we want it to first install this version and then run the tests, right? And then later it will come and take this version and run the test. But then in the command line, you can
actually just select it to run only the test with this guy and skip this guy here. So it's really, I mean, it's the ability that it, it gives you, it's incredible. So if I could see, so you can see like here, right here, right? This is exactly what like it goes into the py test-ish world.
-I see. So you can run it and say, don't, don't run the linter or just lint it, don't run the test or test. You can even put Python expressions. It looks like tests and not lint, for example.
-Is it, I mean, it's just, it's just, insanely great.
-Nice. Brian, what do you think of this?
-Oh, I really like NOX. It's neat. the parameter is, the, the, the use of parameters is really cool. and the example of like using a couple of different Django's is good, but you can also,
uh, build up, matrices of testing easily with like a couple, you can stack these so you can have two parameters together. it's, it's a pretty cool project. I, I just really love talks. So I haven't, I haven't switched. there's, but, but I, I know that the, you know, there's, there's like invoke also people are using invoke for automation, but people are using NOX for, more than just automating testing.
-You can automate, really whatever you want to, you can run. It's just running a command, right? So.
-Nice. Yeah.
-Prayson, you've got a lot of comments from the live stream on this one.
Henry Schreider says, "I love NOX. TOX is mired in backwards, compatibility defaults. It is hard to tell what's actually doing. Whereas NOX is simple. It doesn't hide or guess stuff. It's just program like pytest." Sounds great.
Sam Morley says, "This is the only way to write a make file with invoke."
-I had, I, I mean, I, I had, I had that one.
-Yeah. Henry also says, "The PyPA projects have some very powerful NOX files, CI build, wheel, pip, and so on." which is good. And then Sam Morley also has a question for you. "Can it also, NOX, run external tools? For example, build a C extension or run a C test suite?"
-Oh, I don't know, Brian. -I don't know that either. I assume so.
-It definitely can, because Python has sub-process, but can it do it without you forcing that into it? You know, but you could put technically, you know, Python call this other command.
-Oh, I don't know.
-You could put technically, you know, Python call this other command, right?
-Well, there's an example in one of the, in the tutorial of, of calling CMake.
-Yeah, I saw the CMake as well. So that probably counts, right?
-Yeah.
-Yeah, I think that would count.
-So it's just running a command.
-Yeah.
-Of course.
-And then, Brian, Brandon out there has a comment for you. New lights look great.
- Thanks.
-I agree with him.
I actually need to adjust my, my camera a little bit, which is a little bit off on the lights.
Very cool.
-All right.
-Uh, let's see. I think Brian, you got the next one.
-Oh, okay.
I forgot what I was talking about.
Um, yeah.
So I've got the old document there.
So I've got a couple of things I wanted to talk about.
So this is, one of those extra, extra, extra things, but there's just two.
Um, a couple of things around dealing with text and I've been playing with my blog a little bit lately,
not really writing much, which is a problem, but, but actually dealing with some of the old things.
-The whole thing you wrote looks really good now.
-
Well, I'm, I'm, I'm doing some, automated, trying to automate some of the parsing of some of the old stuff.
So I grabbed a whole bunch of blog posts from, from, WordPress and which, yeah, you can, nobody needs to throw eggs at me.
I'm already switching, and using Hugo now, but, but I've got a whole bunch of files that I automatically generated markdown files, but there there's problems with them.
So I have to, I have to keep track.
So I've got some scripts.
So they, a couple of tools are helping me.
Uh, Python front matter is, is a really pretty, it's a package that's, it's just a really small package, but it, all it does is really takes, like YAML style, front matter stuff.
And, and parses those, you could just load it.
So you load, I'm using a markdown files of the example shows a text file and, and you can get at all the pieces of the file, like the content and stuff.
But it, for instance, I can grab, I can grab the title.
You can look at what the keys are, but so for blog posts, I've got, you know, tags and, the date and it's all, it's all converted to, Python objects.
So, if I have a date, listed in, a blog post, it'll show up as a date time object.
So you can do math on it and all sorts of stuff.
So this is pretty cool.
Uh, it's really small, but super handy for it.
For what I need.
So it's good.
Yeah.
This looks nice.
The other tool I wanted to talk about, which is even a tinier use case, I think is, called FTFY fixes text for you.
Um, and really it just takes bad Unicode conversions and makes them good.
So it takes like common problems with Unicode conversions and, fixes them in like where it looks like you have Greek or Russian letters or something instead of a space or apostrophe or something like that.
Yeah.
Like the, one of the, the first example, a quick example, there's like, yeah, like this weird AE character and really it was intended to be a check mark.
So it just converted it to the proper, what it was.
What it was.
I'm not sure how it's doing this, but it's pretty neat.
That is very cool.
Um, the, the, this gets me all the time with stuff like goes from word.
If I'm converting from word or something, or copying, copy and pasting, or other things.
There's a lot of different quote marks that word processors put in and like, it just ends up being gross in a lot of places.
Yeah.
And, having that converted to just the, the, one example is, the Mona Lisa doesn't have eyebrows, but instead of the just apostrophe T it's this weird, ugly, big Unicode thing.
Um, yeah.
So just, just replacing that with an apostrophe is a good idea.
Yeah.
Nice.
Does it change single quotes to double quotes and stuff like that as well?
I don't know.
I don't know if it should either.
I'm not sure.
Yeah, this is cool.
So you just run this across like your Markdown files or something like that.
Yeah.
So, I'm not using it really for the blog stuff, but there's, there was some other text parsing I was doing where I was scraping some information from somewhere.
And it just was just gross.
Uh, there's a, had a bunch of gross Unicode stuff in it.
And I just wanted to, you know, have something easy to just convert it quickly.
And this does the trick.
Yeah.
Very cool.
Nice one.
Nice finds.
So I'd follow up on that.
I was playing with my, Oh, my posh shell and the new windows terminal and the new windows
power shell on windows 11 earlier this week, trying to set up some testing over there.
And I found they have all these cool themes that show you all kinds of neat stuff.
So you can see like, the get branch you're on and they've got these little cool arrows and all these colors.
And they'll even do certain things for like showing the version of the Python virtual environment.
And they'll be able to do certain things for you to do.
Posh Shell is tested on Nerd Fonts.
But Nerd Fonts is full of all these amazing developer fonts that have font ligatures and all sorts of cool stuff.
And they're all free.
There's like 50 developer fonts and terminal fonts and stuff.
So, yeah.
One more thing along those lines to check out.
Very neat.
But what I wanted to talk about is stealing this idea from Preycin that he was going to cover.
But I got to it.
Got to it before.
So, there's this new project that recently is making traction.
It's been around for a couple of months.
Even, I guess it's about two years old, honestly.
But somehow it got discovered and is now getting some traction called Empire.
M-P-I-R-E.
And the idea is it's a Python package for easy multiprocessing.
It's like the multiprocessing module, but faster, better, stronger.
It's like the Bionic one.
So, the acronym stands for multiprocessing is really easy.
I love that thought.
And it primarily works around taking multiprocessing pools, but then adding on some features that make it more efficient.
For example, instead of creating a clone, a copy of every object that gets shared across all the multiprocessing,
it'll actually do copy on write.
So, it won't make a copy of the objects you're just reading.
It'll only make a copy of the ones you're changing.
So, if you start like 10 sub-processes, you might not have to make copies, 10 copies of that, which can make it faster.
It comes with cool like progress bar functionality and insight to how much progress it's made.
It's also supposed to be faster.
I'll talk about it in a second.
But it has map, map unordered, and things like that.
Interim maps.
The copy on write I talked about, which is cool.
Each worker has its own state and some like startup shutdown type of behaviors you can add to it.
It has integration with TQDM, the progress bar.
What else does it have?
Like I said, some insights.
It has user-friendly exception handling, which is pretty awesome.
You can also do automatic chunking to break up blocks of queues across sub-processes and multiprocessing,
including NumPy arrays.
You can adjust the maximum number of tasks or restart them after a certain number.
Restart the worker processes after a certain amount of work.
So, in case there's like a memory leak or it just hasn't cleaned it up, you can sort of work on that.
And create pools of these workers with like a daemon option.
So, they're just up and running and they grab the work.
Let's see.
It can be pinned to a specific or a range, specific CPU or a range of CPUs,
which can be useful for cache invalidation.
So, if you're getting a lot of like thrashing and moving across different CPUs,
then the caches have to read different data, which is of course way, way, way slower.
So, a bunch of neat things.
I'll show you a quick example.
So, in the docs, if you pull their page up, there's a multiprocessing example.
So, you write a function and then you say with pool processes equals five as pool, pool.map,
and give the function and the data iterable and it runs each one through there.
With the empire one, it's quite simple, similar.
So, you just create a empire worker pool and you specify the number of jobs.
And it says the difference of the code or small, you don't have to relearn anything,
but you get things like all the stuff I talked about, the more efficient shared objects,
the progress bar, if you want.
You can just say progress bar equals true and you automatically get a cool little TQDM progress bar.
You get startup and shutdown methods for the workers so you can initialize them and what else you need to do.
So, yeah, pretty cool little project.
And benchmarks show it down here at the bottom in the fast area.
So, you all can check that out.
Grayson, what did you like about this?
Well, I think it's also going to transition really well to the other topic that I have.
I like when one creates an API that you can just easily plug to your existing code.
Yeah.
So, you can just import this as this and do not change the entire code and then you take care of that.
You know, like writing your code in a way that one can just plug and play.
That's the amazing thing.
So, it's easy that you don't have to relearn a lot of stuff, but it just gives you the power that you need.
So, this is why we move toward this one.
So, we gain the power without changing much of our code.
Yeah.
Yeah, definitely.
I love that as well.
You know, I think of like HTTPX and requests for a while.
I think they diverged at some point, but yeah.
Let's see some feedback from audience real quick.
I'll jump back to the nerd fonts.
Chris says they're amazing.
Henry Schreiner says, "Fish shell plus Fisher plus oh my fish."
And then the theme, "Bob the fish plus sauce code pro nerd font is fantastic."
Oh my gosh.
I have no idea.
I've explored this yet.
These are great names.
Yeah.
You're going to see me on a serious rat hole.
I'm going to be losing like the rest of the day.
No, I'm afraid.
To just fiddle with that, I'm afraid.
Well, I keep on messing my terminal every time I start fiddling around, right?
That's right.
Because I'm using WSL, Windows Subsystem, Linux, right?
Right.
So, whenever I fix something, then I get it right.
And before I know it, I broke it again.
And so, but yeah, it looks really awesome.
Yeah.
Fantastic.
And then on topic, what I was most recently talking about, Chris Mesa's "Whoa, Empire looks
nice."
Alvaro asks, "Will it help to get logging working in multiprocessing?"
I don't know that it'll make any change.
I mean, it really is mostly still multiprocessing.
So, probably not.
Yeah.
Very cool.
All right.
Grayson, I think you got the last one here.
Yes.
So, I have this awesome tool here.
It's called Scotch.
It's really like a mixture of scikit-learn and torch.
This is really, really cool bit, whereas we were talking about building an API that it's
easy to integrate.
So, if someone already knows scikit-learn and a bit of torch, then you don't really need
to learn anything in this tool because everything just fits in together.
So, basically, when you're using scikit-learn, so if you are not familiar with scikit-learn,
it's just this, what we call it, the must-have toolkit for data scientists, because here they
have created a really good tool with a really good API where you can build an entire pipeline
from cleaning your data to building interesting models and everything like that.
But the biggest problem which we keep on experiencing when working with scikit-learn is when it comes
to neural networks, that you really don't have a lot of power to customize your networks in
the way that you will, like, it's very limited with this input that you already have here.
And in most cases, someone says, "Well, just create your own neural network classifier
or a regressor and then wrap it in the scikit-learn wrapper." But then, oh, sometimes one does not
want to do that. But nice thing is, another guy just came up with this project, which is really, really neat. So, basically, it's just, I think mostly I will just go about, maybe I should shamelessly show you an example.
I should shamelessly show you an example in one of my gifts, which is, I know this is a shameless way to do it, but it's easier like doing a demo on how it works, right?
So, like, if you're using scikit-learn, you are very familiar with all these other tools that someone needs to have, like the way to split your data, et cetera, et cetera.
But then it's the pipeline and all that kind of stuff. But the coolest thing is, instead of using one of the scikit-learn models, you can create your own custom neural net, right? So this will be like a neural network where we decided what, how many, what will, how many nodes we want in the first layer, how many nodes we want in the first layer, how many nodes we want in the first layer, how many nodes we want in the first layer.
How many nodes we want in the second layer. And here we can build as many interesting net as we see fit, right? And then basically here, we just do the calling of it. So this is very standard, high touch way of creating your net.
The awesome part is that now this net, forgetting about all this process, we can see. So we just create this net, wrap it up like this, and now we are using it as part of our pipeline. So you can see, I will just go down right here.
So I am having my preprocessor scikit-learn-ish and I'm having my net. And the coolest thing is, now I just call this thing as I will do with any scikit-learn model with my classifier.fit this. And later I will do my classifier.predict these things, right?
So this example is, we are trying to predict the species of penguin given the data that we have. So this whole thing is really, really cool because it obscures the whole fuzz of, when you do it in PyTorch, pure PyTorch, you will have to write this folder with optimizer, stepping up, stepping down, all these things.
But here, just transforming to the scikit-learn-world, where you just do fit, which just train your model. And now you can just do predict as if you're predicting any other scikit-learn tool.
So, so Scorch is a really, really tool that just does that. So it allows you to connect your touch net with the scikit-learn pipeline. So this is really, really awesome.
So I would just, I encourage people to take a look at it.
I love the idea of it, that basically you can create these PyTorch models and do what you need to do to set them up and then just hand them off to the rest of the scikit-learn world.
And I can see some really interesting uses for this. Like I've got some library and it can either integrate with PyTorch or it can integrate with scikit-learn and it just uses this little wrapper to pass it around. I like it.
Yeah. Yeah. So just for me, it's like, it just gave me this ability to create this, more extended, algorithms, and then just continue using my scikit-learn, my scikit, my, scikit pipelines.
So that's the coolest thing that I don't have to change my code because I just want to replace one line and that is the model. So I get the model from, scotch and then pass it in my ordinary, something like logistical regression.
Instead. Now I'm using a net.
Love it. Nice. Brian, what do you think? You like this pattern?
Yeah, I do. I like the, I like the pattern of, being able to use, not have to change your entire tool chain, just, to change one piece. Nice and clean.
Yeah. I like it as well. So, that's it for our main items. Brian, I've got one. I feel like, I feel like I should have let you have this one, but I grabbed this little extra thing I wanted to throw out there. Cause I thought it would make you happy.
Cause I thought it would make you happy. Neat. Can't wait. Yeah. So, Marco Garelli sent over this thing and said, if you want to work in JupyterLab, right. I know that one of your requirements for working with tools and shells and stuff is that they're Vim ish. You can do Vim keyboard things to it. I'm excited. Yeah. So he sent in this thing called JupyterLab dash Vim, which is Vim notebook cell bindings for a JupyterLab. So if you're editing a notebook cell, you can do all of your, your magic Vim.
Um, he's to make all the various changes and whatnot, that you want. So yeah. Cool. What do you think?
I'm definitely going to try this. Yes. Yeah. Awesome. All right. Let's see. What else do I have? I got, oh yeah, this, I nevermind my picture. I didn't really intend to put that up there, but I just want to point out that I'm going to be speaking. And the reason the picture is there is the conference, the pie bay conference that is running next month. they featured my talk that I'm doing. So that's why there's a picture of me, but the pie bay 2021 food truck.
And food truck edition, they have rented out an entire, like food cart topia type place with a bunch of these pods and having a conference outdoors and putting up multimedia, like camera TVs and stuff for each pod. So even if you're not at the, like a great line of sight, you can still see the live talks, but sit outside and drink and eat food, cart food in California. Sounds fun.
Sounds fun. So I'm going to be talking about, what, what did I say? My title, my talk was, is going to be HTMX plus flask modern Python web apps, hold the JavaScript. So I'm looking forward to giving that talk in there. So people, if they're generally in that area, they might want to check that out.
I might, that just sounds fun.
Yeah. Yes, indeed. All right. That's it for my extra items. You got any extras, Brian?
No. How about you, Preston?
Yes, I got one. I, I had to actually search if this one has been covered and I was surprised that has not been covered.
I don't think it has. What is this?
It's so it's, you know, there is something called pi dot inf. So we've been using pi dot inf to, of course, ones can say, why don't you just use always dot inf then get whatever that is. Why do we need to, to install another package just to get the environment variable or something. But this is pretty, pretty neat. it's quite recent project, I think. and it's rising slowly.
And, there's a lot of contributor and it's, yeah, it, it's very promising. so what it does, I think I can just bring it, somewhere here. it allows you to do all this, type convention, casting, et cetera, et cetera. Right. Like you can say, you say, I'm going to get my debug here and then I will set the, the defaults and also I will do the casting here. Right. So this is really, really neat.
So often when you're reading config files, everything is a string and then you're like, Oh, this one is a date time. So I got to parse it. This one. Yeah. Yeah. Yeah. Yeah. So I got to parse it. Yeah. Okay. Yeah. But it's really even, it's so much that. So there's another way where you can say from decouple import auto config.
So it goes in search, dot in file is. So, otherwise you can just tell where the environment variable is, but it's just, it's just neat. It's very simple. It does what you want it to do.
So I will really encourage people to look at it. It's, I just, we, we, I've just changed every places where I've been using, dot in or always dot in with, with this one. And it's just, helped me clean some unnecessary steps in my code.
That's pretty cool. Yeah. Yeah. Great, great idea. Definitely check that one out. All right. Well, I think that's it for all of our items. Well, what do you think? Should we do a joke?
Definitely. I love it. Cause I've almost forgotten what the joke is. So it's going to be new to me as well. All right. So the joke is called adoption. This comes from monkey user.com. And you've heard about the, the Python idea of you came for the language, but you stayed for the community.
Well, what if it is a little bit different? What if actually people get brought in unwillingly and then they kind of realize they like it. So here's a picture of, like kind of an open field, you know, think, gazelle or something. And there's, there's a couple of developers just running and there's one who is fixated on a butterfly who doesn't actually see what there's a bunch of like a pack of Python developers coming to adopt them. It says a pack of Python developers spotting a junior dev away from its pack, initiate their conversion assault.
Yeah. Silly, silly, silly, silly, silly, silly. Man, I'm that way even for non-programmers. So, and my family just sort of like rolls their eyes every time this happens, but every time I like get a, some, a young, somebody going, coming over either in college or high school or just out of college, I'll, I'll say, so if you haven't done it already, I, no matter what your field is, you really should learn how to code. and while you're at it, why not?
Just choose Python. So I'm trying to make Python developers out of every person I meet.
I think that's, you do him a favor. It's, it's, it'll, it'll be their superpower amongst all their non-developer friends.
Yeah.
Awesome.
That's funny.
Brian, thanks as always. And Pracin, really great to have you on the show this week and thanks for being here.
Yeah. Thank you, Michael. Thank you, Brian.
Thank you.
You bet. Bye.
Bye.
Thanks for listening to Python Bytes. Follow the show on Twitter via at Python Bytes. That's Python Bytes as in
B-Y-T-E-S. Get the full show notes over at Python Bytes.fm.
If you have a news item we should cover, just visit Python Bytes.fm and click submit in the nav bar.
We're always on the lookout for sharing something cool.
If you want to join us for the live recording, just visit the website and click live stream to get
notified of when our next episode goes live. That's usually happening at noon Pacific on Wednesdays
over at YouTube.
On behalf of myself and Brian Okken, this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.