Latest / Talk Python To Me / #222: Interactive graphs with Bokeh and Python
Transcript
- 0:00Do you have data you want to visualize and share? It's easy enough to make a static graph of it,
- 0:04but what if you want to zoom in and highlight different sections? What if you need to rerun
- 0:09your machine learning model on the selected data? Then you might want to consider working with Bokeh.
- 0:13It does this and much more. Join me on this episode where you'll meet Brian Vandeven,
- 0:18who heads up the Bokeh project. This is Talk Python To Me, episode 222, recorded July 24th, 2019.
- 0:25Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries,
- 0:43the ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter,
- 0:48where I'm @mkennedy. Keep up with the show and listen to past episodes at talkpython.fm,
- 0:52and follow the show on Twitter via at Talk Python.
- 0:55This episode is brought to you by Ting and Linode. Please check out what they're offering
- 0:59during their segments. It really helps support the show. Brian, welcome to Talk Python.
- 1:03Hi, thanks for having me.
- 1:04Yeah, it's great to have you here. You know, I've often thought about ways in which I could
- 1:09use some of these cool Python visualization libraries, and I haven't recently had some
- 1:14great excuses to use them, so I haven't really covered them enough on the show, but I'm really
- 1:18excited to talk about Bokeh with you this week.
- 1:19Oh, I'm super excited to be here. I think Bokeh has really developed a lot over the last year or so
- 1:24in particular, and so this is a great opportunity.
- 1:26Yeah, absolutely. Before we get to it, though, let's start with your story. How'd you get into
- 1:29programming in Python?
- 1:30In Python? So I think the first version of Python I ever used was Python 1.4, actually way,
- 1:34way back in the day, and I was doing some system administration kind of job, so there was a lot
- 1:39of Perl, but I happened to get into using Python for a few things, and it was a lot of fun. Put it
- 1:44down for a while, picked it up here and there, but I've been using it pretty extensively
- 1:47probably since about 2005 or 2006.
- 1:51Okay, yeah, those are pretty early days, Python 1, right? We don't have that debate about 1 versus
- 1:562 anymore. It's moved on to 2 versus 3.
- 1:58Yeah, I don't think there was ever really much debate. Everyone was ready for Python 2 for sure.
- 2:03Yeah, absolutely. So how'd you get into programming in the first place?
- 2:05Let's see. The first thing I ever did was on a TRS-80 that was actually checked out from our
- 2:10local library. They had a program to check out TRS-80s for two weeks, and there was a logo cartridge
- 2:15that came with it, so we could do logo programming. A little bit later, we had some Commodore computers,
- 2:19and so I did, you know, basic, and I think at one point I even got into like 6502 assembly,
- 2:23you know, when I was getting to be a teenager or something, but yeah, you know, just 8-bit
- 2:28programming way back in the day.
- 2:30Yeah, how interesting. Yeah, that's funny with assembly language, like that's not a super
- 2:34easy compare it. Like you've got basic on one side and assembly language on the other. Not
- 2:38a whole lot in between, huh?
- 2:39Well, there's not a lot of different ways to program on a Commodore 64.
- 2:44You had to earn your programming stripes back in the early days, that's for sure.
- 2:48Nice. Okay, so Boca is a very visual thing. For a long time, you were at Anaconda Inc.
- 2:55So, is there a science background as well that got you sort of in that path, or how do you get
- 3:01interested in all of these things? Yeah, I've had a pretty tortured academic path. I went to school
- 3:05for computer science, then left for a while, and I worked in some research labs, and I realized,
- 3:09hey, I want to go back to school, and so I actually ended up in graduate school for physics eventually,
- 3:12and so I have a pretty strong, you know, mathematics, physics background, but ultimately,
- 3:16I did decide to sort of go back into computer science, software engineering. I really like working
- 3:20on software, though, that's in the service of analytical endeavors or science and that sort of thing,
- 3:24and so this is why, you know, being able to work at Anaconda on all these tools has been really
- 3:28fantastic. Yeah, it's got to be super rewarding to have so much impact on the science side. Are you
- 3:34still at Anaconda? What are you doing these days? Like, what's a, what kind of programming and work
- 3:38do you do day to day now? Yeah, no, I actually just recently left earlier in the year, so I was at
- 3:42Anaconda from the beginning. I think I was the last original employee to leave, in fact, except for
- 3:46Peter Wang, of course, who's still there, but, you know, eight years is a long time, and so it's just time for
- 3:51me to go look for something different, and I actually went to go work at Microsoft, and that was really on the
- 3:54strength of some interactions I'd had with folks at DevDiv and Microsoft around Python, around open
- 3:59source. Everyone there has been really terrific and really supportive of Python and open source, and so I
- 4:03think it's a very different company than when I, you know, thought about it 15 years ago, where I
- 4:08probably would have used M dollar sign very sincerely on an angry forum post or something, but, you know,
- 4:12everyone there has been really terrific. It's been a good experience, and day-to-day, I work on Azure SDK
- 4:16for Python these days, which is, you know, a lot of PR reviewing, writing some code, and
- 4:21helping move the direction there.
- 4:23Oh, that's really interesting. You probably feel like you're bringing a little bit of the outside
- 4:27to Microsoft, right? Like, it is a very different company. They're more open to external stuff, but,
- 4:33you know, historically, it hasn't always been that way, so it's probably like, let me tell you about the
- 4:37Python scientific stack, folks, things like that, yeah?
- 4:40It's definitely interesting, and there's a lot of give and take. So I've actually learned,
- 4:43I haven't been in an organization this large in a very long time, and so it's been a lot of personal growth
- 4:47and learning for me, just to be in that kind of environment where, you know, people have to interact
- 4:51in different ways, and that's been very gratifying and helpful for me, but definitely, I think I have a
- 4:55pretty useful perspective to bring as well, especially in terms of, yeah, data science applications
- 4:59in Python and that sort of thing.
- 5:01Yeah, yeah, super cool. It sounds like a fun job. So let's start off this conversation talking about
- 5:06Bokeh by kind of getting the, like, a big picture of, you know, making pictures with Python, right?
- 5:13So if I have a graph, I want to do a map, if I want to do some kind of bar chart or some
- 5:18visualization of data, what are my options nowadays?
- 5:23There are a lot. So if people want to Google, there's actually a chart made by Jake VanderPlas,
- 5:29who, you know, is very active in sort of the PyData, SciPy community. He tried to draw a map,
- 5:34basically, of all the Python visualization landscape, and there are a lot of tools available. And some
- 5:38people think this is really great, and there's a lot of choice, and then some people think that
- 5:42there's just, you know, too many things, and they don't know what to deal with. But there are a lot
- 5:45of tools. So obviously, you know, MapPlotlib is the very big tool that's been around for a very long
- 5:49time. It's a really fantastic tool, and all the devs there, you know, they work really hard. And
- 5:52it's been great to see the sort of the strides that it's made in the last few years. In terms of,
- 5:57like, web visualization, there's, you know, Bokeh, of course. Plotly is another offering that's out
- 6:02there by the company Plotly. Altair is another tool that's been fairly recently added. Actually,
- 6:07Jake VanderPlas and Brian Granger from Jupyter put that together. And so it's inspired by
- 6:12the Vega plotting sort of toolkit that's available in browsers. And it's sort of a Python wrapper for
- 6:16that.
- 6:17Yeah, that's cool. I've heard a lot of good stuff about Altair, and that it's really quite nice as
- 6:21well.
- 6:21Yeah, I don't have a lot of experience with it. I mean, it's definitely intended for
- 6:24very high level sort of exploratory data analysis. It's very, you know, useful, especially in notebooks
- 6:29in particular. And so it looks very attractive from the things that I've seen. I just am so,
- 6:34you know, I'm very involved in Bokeh. And it takes up so much of my time that I almost don't
- 6:38have time to look at too many other things very often. But, you know, Jake's a fantastic guy.
- 6:41Brian Granger, of course, is great and has made just amazing things for the PyData and SciPy
- 6:46communities. So that's a great tool that they put together.
- 6:49Cool. And, you know, there's always things like the JavaScript libraries, like D3 and stuff like
- 6:54that. Is that really relevant? Or are we kind of got a handle with things like Bokeh and Plotly and so on?
- 6:58You know, so people ask that a lot. Like, what's the difference between Python and D3? Or why would you use
- 7:02one versus the other? And I think if you have people that are, you know, already using JavaScript
- 7:07and they want to work on things with D3, D3 is an amazing tool and it can make incredible, you know,
- 7:12output and really fantastic graphics. And there's probably things that are doable in D3 that maybe
- 7:17would be more difficult in, you know, Bokeh, for instance. But where I think the sweet spot for Bokeh
- 7:21is we've really tried to make it so that people who are already very productive in Python, they're doing,
- 7:25you know, work in data science or science, who are using all these tools that are in the PyData stack,
- 7:30you know, NumPy and SciPy and Pandas and scikit-learn and, you know, Dask and Numba and all
- 7:34these tools that are really productive with these in Python. We won't let them have access to very
- 7:38interactive, powerful visualizations in the browser without having to reach for that JavaScript
- 7:42and web tech and sort of be distracted from the actual work that they want to do. And so
- 7:46in terms of productivity, I think if you're already working in Python, I think Bokeh is a great
- 7:50choice, to put it that way.
- 7:51Yeah. Well, Bokeh to me feels like I get a lot of the benefits of the rich JavaScript stuff,
- 7:56but that I don't actually have to make it.
- 7:59That's a very, yeah.
- 8:00Yeah. A very succinct way to put it. Yeah.
- 8:02Okay. Interesting. And then maybe we could talk really quickly about Plotly just as a compare and
- 8:06contrast. So Plotly, like I don't fully understand Plotly. When I go to work with it, I feel like,
- 8:12okay, I'm working with a library, but then it seems like it has like a backend that they provide that
- 8:17I have to deal with. And then there's also a commercial version. Like what is Plotly? I don't really
- 8:21know where it fits. So in terms of their business, I actually don't know a lot. To be honest, I don't,
- 8:26I don't really follow that very closely. And so I think they've actually changed some of their
- 8:29offerings from, from what they used to be. I think they used to, you know, sell Plotly and I think
- 8:32they're not in that business anymore, but I can't really speak to that very carefully. But the main
- 8:36similarities are it's a Python API that generates a declarative, you know, specification,
- 8:41typically some kind of JSON that can be rendered by a front end library. Now, you know, Plotly is an
- 8:46entire company centered around this. And so they have had some really nice resources for, I think,
- 8:50developing both, you know, some things in ways that Bokeh hasn't had. Like I think, you know,
- 8:53their front end is a little more polished and some of the, you know, design stuff is definitely
- 8:56polished. And I'd love to get some help on the Bokeh side to sort of bring that up to speed.
- 9:00But, you know, relatively speaking, I think we've done a pretty good job at, you know,
- 9:03having the same set of features. They're very contemporaneous. They started at almost the same time,
- 9:07you know, way back in sort of 2012 kind of era. They have a lot of similarities,
- 9:11but definitely there's a little bit of difference. You know, my background comes from a lot of science
- 9:15stuff. So I'm really familiar with folks that have use cases, for instance, around like dense
- 9:18arrays, like, you know, big images. And so we've really focused on some things like having an
- 9:22efficient array protocol for the Bokeh server that can transmit large arrays, you know, very efficiently.
- 9:27And whereas I don't think they've sort of gone down that route, you know, again,
- 9:29they've worked on some other features that are more around slick dashboarding and, you know,
- 9:34that sort of thing.
- 9:35Okay. Yeah. Interesting. You know, let's talk about the history of Bokeh. Like you're saying it that way,
- 9:40and I guess I'm as well, I'm trying to anyway, the way the proper pronunciation is.
- 9:45I usually say Bokeh, but Bokeh, I think is also fine. Amusingly, long ago when we were funded through
- 9:50this DARPA X-Data initiative, there was some video that someone made, you know, unrelated to all the
- 9:55actual projects, but they made about the projects. And I remember in that they were describing all the
- 9:59projects that was under the X-Data initiative. And they mentioned the visual database Boke,
- 10:04I think. That's the only wrong pronunciation.
- 10:05Bokeh is not Bokeh. All right.
- 10:07Okay. It's fine. Yeah.
- 10:08All right. Excellent. And so where did it get started? It started out of research grants and
- 10:14this DARPA funding. Is that where it came from?
- 10:16No, the research grants really helped, but it started before then. So going back a little bit
- 10:20further. So I've been interested in visualization for a long time. Actually, the first, one of the
- 10:24first things I use in Python and Python 1.4 was a plotting plugin for Apache. And it was just,
- 10:28it amazed me that you could like take data and have a website just make a plot. It was incredible.
- 10:33I worked a little bit on VTK here and there years ago. A few, my first open source contributions
- 10:37were to VTK. But in the middle aughts, I guess, I went to work for a company with Peter Wang,
- 10:43who eventually founded Anaconda. And I worked with him on a library called Chaco, which was a rich client
- 10:49library for interactive visualization. So instead of in the browser, you would write like a Python
- 10:52application that was using like, you know, QT or, you know, the GTK, you know, kind of real
- 10:58application. And it was also contemporaneous with Plotlib.
- 11:03But ultimately, Matt Plotlib won sort of that battle. And the reason was pretty clear. It was
- 11:07because, you know, while Chaco had all this really rich capability for an activity, it was a very sort
- 11:11of fiddly API, very detailed, kind of verbose. And so later on, when Peter was getting Anaconda
- 11:19started, and I was on board to help with that, we had talked about wanting to update this idea of
- 11:23Chaco and create a new library that supported interactive visualizations and in browsers,
- 11:28because right, browsers is the right place for it to be in 2012, right?
- 11:30Of course.
- 11:31And so we had this idea, we started it. But getting the, you know, the funding through the
- 11:35DARPA X8 initiative in the early years of Anaconda, is then called Continuum Analytics,
- 11:39really helped, you know, mitigate business risk for us to put more resources into it. So it really
- 11:42accelerated the development, I would say. But we have certainly, you know, we started talking about
- 11:46the ideas behind Bokeh in sort of middle 2011, probably.
- 11:49Okay. Yeah, that's, that's pretty interesting. It's been around for a while. I guess that's,
- 11:53at that point, Ajax and interactive browser stuff's pretty well established, right? So it's pretty
- 11:58clear that was the right place.
- 11:59Yeah, I mean, we just knew that, like, the future of presentation and the future of getting, you know,
- 12:03this content in front of people was going to be in browsers. So writing another rich client library
- 12:06was not something that was really interesting to us. And so we definitely wanted to do the browser.
- 12:11And then we definitely wanted to make it architected in a way that it was very flexible,
- 12:15that it had this declarative specification that described what you wanted to visualize.
- 12:19Because, you know, that affords a lot of possibilities. So we've talked about the Python
- 12:21side of Bokeh, but you can actually have other languages drive Bokeh plots in the browser,
- 12:25you know, there's an R Bokeh binding, there is a Scala Bokeh binding that hasn't been updated in a while.
- 12:30I'm interested in actually reviving a Julia Bokeh binding. But that's all because there's this
- 12:35JSON specification. And any language that can, you know, dump out the right JSON can create these
- 12:39Bokeh plots in the browser. Now, we've spent a lot of effort investing in the Python bindings,
- 12:42because, you know, Anaconda is a big Python shop. But certainly the possibility is there for other
- 12:46languages as well.
- 12:47Okay, so maybe it's worth just touching on the architecture a little bit, and we can dive
- 12:51into the details more later. So there's a, I guess there's a couple ways we can use this,
- 12:55right? Like, there's a, probably the most straightforward way is we have a Bokeh server.
- 13:00And then there's some front end stuff that is the rendering point, right? Like I want to put a,
- 13:06some kind of graph in a browser, and the server handles all the data, and maybe it only prevents,
- 13:12presents like a slice into that world of the data and things like that, right? Can you tell us about
- 13:18that?
- 13:18That's absolutely a great use case for the server. But I will say the server is,
- 13:21in fact, optional. I would say most usage of Bokeh probably doesn't involve the server. So Bokeh can
- 13:25generate this JSON, and it can send it to a web page that can be embedded in like a Flask app or a Django
- 13:30app. It can be embedded in, you know, Jupyter notebook output cells. And it doesn't have to be
- 13:34connected to the Bokeh server. Bokeh.js will take that JSON and render it. And you've got an interactive
- 13:39plot that has panning and zooming. You can even have linked behaviors between plots. You can have custom JS
- 13:43callbacks that, you know, do work whenever you make a selection or click a button. None of that
- 13:47requires the Bokeh server. What the Bokeh server is really great for is when you want to connect all
- 13:51those interactive features to real running Python code. Like you want to click a button and have a,
- 13:55you know, a scikit-learn regression or a scikit-learn model run, or you want to, you know,
- 13:59make a selection on a plot and compute a linear regression line through those selected points
- 14:03with real Python code. That's what the Bokeh server is really great for, making that sort of two-way
- 14:07connection between this front end and real running Python code. But you can use Bokeh very effectively
- 14:12without the Bokeh server. And in fact, I guess, I think most usage is probably, we call it standalone
- 14:16usage, where it's just generating this pile of JSON that is used to drive a Bokeh plot in a webpage
- 14:21somewhere. This portion of Talk Python To Me is brought to you by Ting. Let me tell you about Ting,
- 14:27a new mobile service available in the US that's targeted developers and other technically savvy folks.
- 14:33First of all, their average customer only pays $23 a month, but they're no discount provider.
- 14:38Their service runs over T-Mobile's and Sprint's fast nationwide network.
- 14:42If you don't use that much data because you're usually on Wi-Fi, like many of you are,
- 14:45then Ting will save you a ton of cash. But don't worry, you can still use as much data as you like
- 14:50for just $10 per gig. One mobile feature I use all the time is tethering. And with Ting,
- 14:55you get unlimited tethering at the same data rate with your account. $6 a month for a phone line,
- 15:00$10 a gig, $3 a month for text if you usually chat over iMessage or WhatsApp. Think about it,
- 15:06no contracts and super clear and fair billing. Visit python.ting.com. That's python.ting.com and check
- 15:14out their savings calculator. Enter your usage and see exactly what you'd pay. Use that link and you'll
- 15:19get a $25 credit to try them as well. That's python.ting.com or just click the link in the show notes.
- 15:26The server is mostly about the interactive bits if you want to add smarts to your plots.
- 15:32Yeah, absolutely. If you want to connect all those PyData tools, NumPy, SciPy, Pandas, Dask,
- 15:37Numba, OpenCV, any of those tools. If you want to connect those things directly to
- 15:42these interactive visualizations with a minimal amount of fuss, that is what the Bokeh server is for.
- 15:47Exactly.
- 15:47Okay, cool. Before we move off the history and Anaconda Inc. and all that, when you created it,
- 15:52it sounds like you tried to create it as a standalone project with its own fundraising and its own
- 15:58outreach. What was the thinking there rather than just making it part of Anaconda?
- 16:02Well, I mean, in the very early days, it was definitely a project that was started at Anaconda.
- 16:06And the DARPA thing came along somewhat serendipitously. Not something we counted on or
- 16:11knew about when the company started. And that was a big sort of funding for a long time. After that ran
- 16:15out, because that was a fixed number of years sort of support, Anaconda very generously supported the
- 16:20development of Bokeh. But ultimately, it was always the goal to try to create these tools as sort of
- 16:25self-sufficient, self-governing, push them out in the open kind of projects. And so it took a long time
- 16:30to get to that point. The first step in that was for Bokeh to become a NumFocus fiscally sponsored
- 16:34project. But of late, we've really ramped up the self-governance and the self-sufficiency. So pretty
- 16:39much at this point, I think the cord's been cut and Bokeh is really out there. It's managing its own CDN
- 16:43resources. We're doing a lot of outreach and fundraising on
- 16:45our own right now that wasn't happening even six months ago. We just had or still having actually
- 16:50a July fundraiser going on to try to help pay for some of our infrastructure costs. But we're also
- 16:55ramping up some corporate engagements and trying to talk to corporations and see if they want to offer
- 16:58support. But that all is pretty new. For a long time, Anaconda was the primary beneficiary or
- 17:03benefactor, I should say, of Bokeh.
- 17:04Sure. And it just makes Python and data science stronger, which is really the heart of Anaconda Inc.
- 17:11anyway. So it seems pretty reasonable. You said that the project was a NumFocus
- 17:15project. And we spoke a little bit earlier about NumFocus a bit. And I guess my understanding is a
- 17:22little bit off. I saw NumFocus as a thing that kind of provides funding to these projects. And
- 17:30that's not quite exactly right, is it? What is NumFocus and what did it do for you all?
- 17:33Yeah, it's sort of yes and no. So NumFocus was started by Travis Alphont, who was one of the other
- 17:38co-founders of Anaconda. Of course, he's the original or he's the author of NumPy, building on previous work.
- 17:43But NumFocus is this nonprofit, 501c3. And its main role is to be an umbrella organization for
- 17:51open source projects, right? So open source projects often are not legal entities. And so that actually
- 17:55makes it quite difficult for them to accept money, right? It sort of gets very complicated with taxes.
- 17:58And so they're this legal entity that can accept donations on behalf of projects and then handle all
- 18:04the tax stuff. They also do a lot of outreach. They hold, you know, they support the PyData meetups and
- 18:10PyData conferences around the world. So they're this organization that sort of helps and supports
- 18:13open source. And they do fund these projects in the sense that, you know, they help the donations that
- 18:17come in get back to the projects. And also sometimes they spread some of those funds around. They get
- 18:21bigger donations that they can also use to give to projects that, you know, don't necessarily raise
- 18:24their own money. But yeah, that's their main role. Just to be this umbrella organization, they help out
- 18:28with the bureaucracy and take away that load from these open source projects.
- 18:32Yeah, that's really interesting. I guess it took me a long time to realize that it's
- 18:35actually hard for companies to give money.
- 18:39It's really hard.
- 18:40To these projects, right? Like it's not just a matter of put aside the point whether they should
- 18:44put aside the point whether they fiscally could. Of course, they most of them can and they should,
- 18:49right? But just the way that they're set up is they buy things. They exchange money for a service or a
- 18:58good. Even given to a charity like NumFocus probably is a little bit odd and hard for them to do.
- 19:03That is exactly right. There is just an impedance mismatch. I mean, the sums of money that would help
- 19:07a lot of open source projects, I think, are relatively small compared to the budgets of the
- 19:11companies we're talking about that are using these projects. But yeah, there's just an impedance
- 19:16mismatch for how do you actually it's not a purchase, right? And so it's not hiring someone. So what
- 19:21exactly is it? And companies just, you know, right now don't know how to handle that and don't know how to
- 19:25deal with it. And so there's some other efforts to make that easier. People are trying different
- 19:28things. There's, you know, Travis's company, Quonsight, is trying out some models for, you know,
- 19:32getting support for open source projects by engaging with companies in various ways. Tidelift as well
- 19:37is also trying that. GitHub is, you know, trying their new sponsorship sorts of things. So people are
- 19:41trying to find novel ways to attack this problem. And I hope we get there, but it's definitely
- 19:44something that will take some time.
- 19:46Yeah, I hope so as well, because it would make a huge difference and it would be
- 19:49a blip for these companies to make that contribution, right?
- 19:52Yeah. I mean, as an example, our goal for the July fundraiser was to raise a thousand dollars,
- 19:56right? And we have, you know...
- 19:57That's very modest, right?
- 19:58I think several hundred thousand users and we did, you know, I'm really happy to report that we did,
- 20:02but, you know, I had to tweet out a lot every day to make it happen. It was, you know, sort of
- 20:06knocking on doors and, but yeah, I'd love to be able to go to companies and try to be more effective
- 20:10and efficient at fundraising, if that makes sense.
- 20:12Sure. Well, while we're on the subject, let's talk about your fundraiser real quick.
- 20:15If you're going to raise a thousand dollars, that's probably not money to pay developers,
- 20:19right? It's something else.
- 20:21Yeah. I mean, I actually raised this exact issue around the sustainability conference that NumFocus
- 20:26is going to have later in the year. I think there's sort of two different buckets where things go into
- 20:29there's, you know, paying people. And I hope someday we can figure that out really well. And we can
- 20:33support, you know, people to be maintainers of open source software by actually paying them to do
- 20:37that work directly as a sort of a job or a living. But there's also just the matter of a lot of open
- 20:43source projects, I think, could use a fairly small amount of money just to cover expenses or help
- 20:48take some strain and stress off the maintainers. Like in the case of Bokeh, we have to run this,
- 20:52you know, CDN to deploy Bokeh.js. So all the users around the world can get Bokeh.js to display their
- 20:57plots. That is run on, you know, AWS CloudFront. And so we have to pay for that. Someone has to pay for
- 21:02that. Right. And so that's what this fundraiser was for. And so in the sense that it, you know,
- 21:06sort of reduces my stress because it helps me know that this is sort of taken care of for the next year.
- 21:10That's what that level of sort of funding is for. And there's other stuff too. There's,
- 21:13you know, it's good to get developers face to face sometimes. And so this could help with that
- 21:16as well as other infrastructure costs.
- 21:18Right. Some having some like yearly meet up with the core developers. It's odd. There's a lot of
- 21:23projects where the core developers have never actually met.
- 21:25Definitely. For sure. I think I've met everyone at least once, but there's some folks that are pretty
- 21:30scattered for Bokeh. But for sure, I have no doubt that's the case.
- 21:33Yeah, for sure. So you said that Bokeh works with this JSON output and it can just basically render
- 21:39anything that can generate the JSON. It can go out and render that. You know, I think when I think of
- 21:44graphs, I mostly think of notebooks and Jupyter and things like that. But also we can just plug this
- 21:50into whatever. Is that right? I can plug it into just a Flask site. Can I plug it into even like a,
- 21:55some kind of command line app and like somehow pop it up?
- 21:58Yeah, I don't see why not. I mean, anything that can run JavaScript basically, right? Anything that can
- 22:01load Bokeh.js. So if that's like an Electron app, I think that would be feasible, certainly in the,
- 22:06you know, in the Jupyter notebook. But, you know, there's a variety of ways. We have a whole Bokeh.embed,
- 22:10you know, API. And so there's a variety of different ways to embed Bokeh content. But if you're running a
- 22:13Flask site, you can use one of those ways to pop up Bokeh content in the middle of your site and in
- 22:18your template and sort of wherever you want to put it.
- 22:20When I think about the data science space, there's some libraries and data structures that are just used
- 22:27over and over and over. You mentioned Travis before. So there's NumPy. There's,
- 22:31of course, Pandas. There's a bunch of other stuff built on top of that. Is there special
- 22:36integration for those types of libraries? Like if I already have some NumPy array or I've got some
- 22:42Panda data frame, is there a way to just like plug it into Bokeh?
- 22:45Yeah. So Bokeh works really well with all those things. NumPy is an actual requirement,
- 22:49runtime requirement for Bokeh. We tried to avoid that. Even in the beginning, we wanted to make Bokeh as
- 22:53minimal and as accessible as possible. But NumPy is a requirement now. Pandas is not a hard
- 22:57requirement, but Bokeh works really well with Pandas. If you have Pandas data frames,
- 23:00you can basically plug them in anywhere a Bokeh column data source would go. I can automatically
- 23:05sort of convert them or use them in a way that's useful, either data frames or group by objects.
- 23:09And so we've tried to make it very easy to integrate with Pandas, but also make Pandas
- 23:13not required. And so that's sort of the state where things are at. Anything that can sort of behave
- 23:17like a list or an array or a Pandas series works pretty much out of the box with Bokeh.
- 23:21Okay. Are there other major libraries that I don't know to ask about?
- 23:25I think Bokeh works really well with Dask, I assume, because Dask has a data frame-like API.
- 23:29Matt Rockland actually used Bokeh to develop the interactive dashboard that's sort of the cluster
- 23:34monitor for Dask.
- 23:35I think it's great as well. And I did have Matthew Rockland on before to talk about Dask,
- 23:39but I don't know if everyone's listened to that one. And also if they've seen the actual
- 23:45visualization of that. So could you maybe describe that real quickly, what Dask is and then that
- 23:49dashboard? Because when I saw that, that just like blew me away.
- 23:53Yeah. Dask is a tool for basically parallel distributed programming. And it's trying to
- 23:57do so in a way that is a very sort of Pythonic, very Pandas-like API, right? So there's other
- 24:02tools that do this sort of thing, but they come from other languages originally. And so their APIs are
- 24:06maybe not very Pythonic and they kind of don't fit in well with Python tools. But Dask is meant to be
- 24:11a very Pythonic tool for this distributed computing task. And so to that end, it has this dashboard
- 24:16that Matt Rockland developed using Bokeh that can visualize everything that's going on around a
- 24:20cluster that's doing computation all at once, right? So it can show you what
- 24:23nodes are computing or waiting or they're transferring data in real time. And so that's
- 24:27really helpful for diagnosing problems with parallel distributed computations. And so Matt has always
- 24:32been very clear that Bokeh was great for him because he didn't have to write all this JavaScript to have
- 24:36this really interactive dashboard. He could just write it in Python and connect it directly to his
- 24:40telemetry that he was getting back from clusters and visualize it very quickly. And so I think it's
- 24:43been a great tool for his users. I shouldn't say his users. It's a big project now. Dask has actually
- 24:47grown up quite a bit. So I should say the Dask project's users. But we're happy to see that kind of thing happen.
- 24:52You know, love to see Bokeh used in those kind of use cases.
- 24:54Yeah. And it just looks so good and professional and, you know, live updating. It's really a nice
- 25:01use case for Bokeh. And I think it's also a good testament to what you guys have built.
- 25:05Well, it's also good to get feedback from real use cases like that. Nothing sharpens your tools
- 25:09better than sort of having them honed against real problems, right? And so we love when people do
- 25:13awesome things with Bokeh and tell us, you know, hey, this was great, but also this could be a little
- 25:16bit better or easier. You know, this is how you could make my life, you know, simpler or here's some pain
- 25:20points I had. That kind of feedback is really helpful from users.
- 25:23Yeah. It's great to design something, but once it actually meets real users and real use cases,
- 25:29like that's where it gets real. So you talked about Dask. Let's just touch on some of the other
- 25:35things that is built upon Bokeh because Bokeh has been around since 2011, 2012, like you said,
- 25:41and it's pretty stable for the most part.
- 25:43It's a lot more stable recently. Yeah.
- 25:45Yeah, that's great. So things are starting to build on top of it like Dask and just using it.
- 25:49So what else is out there like that?
- 25:50Well, there's a couple of different things in different classes of things, right? So first of
- 25:53all, there's other libraries now that are starting to build on top of Bokeh. So there is Chartify,
- 25:57which was created by the data labs at Spotify. And so it's their sort of high, very high level
- 26:02sort of data science, opinionated data science API on top of Bokeh. There's a project called Pandas
- 26:06Bokeh that just came out recently. That's sort of very tight integration with Pandas and using Bokeh to
- 26:10generate interactive plots. There's also a set of tools created by some folks who are still at Anaconda
- 26:14called sort of the efforts called PyViz. And so there's a tool called HoloViews, which is a very
- 26:18data centric API, and it can generate interactive visualizations using Bokeh and other tools as well.
- 26:24But there's also, you know, some tools like Data Shader, which are for, you know, very large data,
- 26:30you can finally control how they're rendered. And so you can combine Data Shader with Bokeh, you know,
- 26:34using HoloViews. So it can drive things at a very high level. So I'd love to see this effort where
- 26:37people are building these things on top of Bokeh. And I'm also glad that now, you know, Bokeh was
- 26:41a moving target for quite a while. And I very much appreciate the patience of all of our users who
- 26:45sort of, you know, kept with us as we were figuring things out. But I would like, you know, we're trying
- 26:49to be much more stable now. I think we've done a very good job since 1.0 was released at being,
- 26:53you know, much more stable. That's very good. The other kind of things that get built on top of
- 26:58Bokeh are more like applications or, you know, other projects. So there's a project called Microscopium
- 27:04that is for, you know, sort of biosciences research. There's a tool called Light Curve that a bunch of
- 27:09astronomers put together, which uses Bokeh to let you drill down. So you can see like an image of,
- 27:13you know, some star or something and hover over a single pixel and really drill down into something
- 27:17about, you know, that image using, you know, all the tools that are in Bokeh. You know, there's
- 27:21actually quite a, Dask, of course, is a great example. And then there's actually a bunch of other
- 27:25ones on GitHub. And I'm sorry, I don't have a list at the top of my head, but there are a lot of
- 27:29exo-bioscience projects that are built on top of Bokeh. And, you know, financial trading is another
- 27:34thing that comes up. People have done drug discovery type work on Bokeh. It's interesting where things are
- 27:39popping up, especially, you know, now, and now things are more stable. I think it's really a great time for
- 27:43that to happen.
- 27:44Yeah, that's super cool. The Light Curve project looks amazing. I mean, to explore like data from the
- 27:50the Kepler and TESS telescopes, that's pretty cool for exoplanet discovery. I mean, that's,
- 27:57it's really exciting.
- 27:58Like the project that you worked on is helping scientists like actually look for exoplanets.
- 28:03Like, that's incredible.
- 28:04That is a, no, it's really gratifying. Like, that's exactly the sort of thing that, you know,
- 28:07I'd say we wanted to be able to enable and, and, and help, help make happen. So it's really
- 28:11gratifying when people are able to use Bokeh for those kinds of situations.
- 28:14Yeah, absolutely. Do you see Bokeh being useful or appropriate for like real-time dashboard type
- 28:23of scenarios? I mean, obviously it draws great graphs. And then, you know, we talked about Dask
- 28:28and the real view of that. So like, let's imagine I'm like building software for software, for
- 28:33stock trading company or something like this. And I want to show in real time what the market's doing.
- 28:39All the data the traders need. Would that be appropriate? Is it too low late or too high
- 28:43latency or what's the story? I think it could be there's real time. And then there's quote,
- 28:46unquote, real time. Right. So it's always depends on what exactly people mean when they say real time.
- 28:50When I hear the word real time, I have images of like, you know, very low level, a certain kind
- 28:54of system that's implemented that has very specific guarantees about its performance. And for that kind
- 29:00of work, Bokeh is probably not suitable. Right. But if you're talking about real time, just in terms
- 29:03of like streaming data coming in from a financial system or, you know, from, IOT type devices
- 29:09or, you know, that sort of thing. And I think Bokeh can, has been useful. There's certainly
- 29:13people who have come looking for support on our discourse or on our other support forums,
- 29:16talking about using Bokeh, connecting it to real time sensors, for instance. Right. So they're in a
- 29:21factory or a warehouse and they've got data coming in. I want to visualize something. So people do do
- 29:24that. So if you mean, you know, quote unquote, real time, and just in the sense that I've got data
- 29:28coming in and I want to visualize it in a best ever kind of way, then I think Bokeh is definitely a
- 29:32good choice.
- 29:33Yeah. And that's mostly what I meant. I mean, obviously not like we need seven millisecond response time or else
- 29:37the plane crashes, something like that. Nothing like that. Right. But like, like when you're
- 29:42thinking of graphs, right, like a human has to see the graph and interpret the graph. Right. So that's,
- 29:46you know, how long is that? It can't be quicker than a hundred milliseconds. Right. Like the human
- 29:51can't understand graphs that quick.
- 29:52Well, and so real time is not even necessarily about quickness. It's really about predictability. It's
- 29:56about specific kinds of guarantees. But, but yeah, so I should mention, yeah, Bokeh does have some APIs
- 30:00for streaming specifically. Right. So, you know, if you've got data coming in or you want to update,
- 30:04you know, just the newest point, you've got a, you know, a time series with a hundred thousand points,
- 30:08you know, plotted and you've got new points coming in at the end. Bokeh can very efficiently just send
- 30:13the new data, right. Without sending, you know, the entire data set. So it is very useful for that sort
- 30:16of thing. Yeah. So then you load up the historical data and then you just take, you know, the update
- 30:21every half a second or something. That sounds pretty doable. Yeah, absolutely. Okay. Even more often.
- 30:25Yeah, yeah, yeah. Sure. That sounds, that sounds super interesting. One of the capabilities kind of
- 30:30around that, that you talked about is being able to work with like quite large data, maybe having some
- 30:36on the server or something like that. And then either interpreting that or running a machine learning
- 30:41model against that or something like that. Maybe tell us some of the use cases there.
- 30:45Yeah. There's a couple of different ways you could use Bokeh for that. So one is that, you know,
- 30:49if you have a large data set, you know, you're not going to send a billion points into your browser,
- 30:51right? Your browser will just fall over. So you've got to find some ways to sort of minimize the data.
- 30:55And that can be done in a variety of ways. And one of the ways is for instance,
- 30:57it's downsampling. So if you have a large data set and you've got some reasonable way that makes
- 31:01sense for your use case to downsample it, the Bokeh server can just do that downsampling and then show
- 31:05you the subset of data that's relevant, right? So that's one way that you can use the Bokeh server
- 31:09to handle sort of large data sets. Another way is I mentioned this tool data shader, which is
- 31:13actually specifically designed for being able to, you know, very efficacious visualizations, images of,
- 31:19you know, hundreds of millions or billions of points, right? It gives you very fine control over the way,
- 31:22basically the more sophisticated version of alpha compositing happens. So you can actually try to
- 31:25emphasize the things you want to emphasize in a meaningful way. And so you could use data shader
- 31:30to data shade those 100 million points. And then that just produces an image and then you can send
- 31:35the image to Bokeh. And so that's a very fast operation. So the data shader is sort of a form of,
- 31:39you know, data compression in that sense, but it's still very interactive because, you know,
- 31:44you can use the events that Bokeh generates to when you, if you resize the plot to get a new image
- 31:48generated, if you've, for instance, changed the balance of the plot, if you pan or zoom,
- 31:52you can get a new data shader image based on those new, on those new dimensions. And in fact,
- 31:55HoloView sort of does that all automatically for you. You can do it by hand with Bokeh and data shader,
- 32:00or, you know, at a high level, HoloViews can sort of take care of that for you. That's another way in
- 32:04which, you know, you can sort of reduce the amount of data that you're going to send into the browser.
- 32:07Coming up next year, I hope we can actually raise though the ceiling of the number of points you can
- 32:11send. We're going to try to do some work, hopefully, to better improve the WebGL support in Bokeh,
- 32:16and maybe even just have Bokeh be based entirely on WebGL. In which case, I think we could,
- 32:20you know, right now, Bokeh, you could send a few hundred thousand points to it,
- 32:23and it's typically okay. But I think we could raise that sort of ceiling a little bit higher
- 32:27once we are able to render completely in WebGL.
- 32:29Yeah, that would be pretty amazing. Is it using like canvases or something now?
- 32:33Yeah, exactly. So it uses the HTML canvas. There is currently some level of WebGL support.
- 32:37And the person who maintained that and originally wrote that is just, he's moved on to other things.
- 32:40And so that WebGL support is sort of, it needs a little work, a little love and care. And we'll
- 32:46probably just go ahead and try to do things sort of from the beginning and re-found that in a cleaner,
- 32:51better way going forward. But yeah, there's some WebGL support now, but most of the rendering happens
- 32:55on HTML canvas.
- 32:56Okay. So let's talk a little bit about some of the internal implementations of this. Like,
- 33:02when most people interact with Bokeh, they're probably interacting with some Python API. And as far
- 33:10as they're concerned, like that's the end of it, right? Like, I call these functions,
- 33:13the plot comes up magic.
- 33:14Yeah. And actually the API is actually quite light. So by and large, we've turned the problem
- 33:19of creating an interactive data visualization web app into the Python problem of creating a bunch of
- 33:24objects and setting their properties, right? So, you know, I mentioned this JSON representation and
- 33:28that JSON representation actually mirrors on both sides, a set of objects and those objects being a
- 33:32graph. So there's a set of objects like a plot, which has, you know, a bunch of renderers and has a
- 33:36couple of axes and some ranges and some data sources. Maybe that's in a layout that also has some
- 33:40buttons. So there's objects we call the models that represent all of those items. All of those get
- 33:45turned into JSON. And then on the JavaScript side, there's a one-to-one correspondence basically of
- 33:49objects that those get turned into JavaScript objects. The role of the Bokeh server is just to
- 33:53keep those two sets of objects in sync bi-directional, right? But in terms of what you use from Python,
- 33:57you create this plot, maybe use the figure function, which sort of puts a lot of these objects
- 34:01together for you in a convenient, meaningful way. And then you can twiddle their properties. You can
- 34:06change, you know, the start and end of a range, or you can add the data to the data source, or you can
- 34:10change various properties of a circle glyph because you want to change how it appears. And so all of
- 34:15this is, you know, just setting these properties on these Bokeh models. And that is the main, the main
- 34:20thing that people do, I think. Apart from that, you might be writing callbacks. If you're using the
- 34:24Bokeh server, you can write callbacks in Python, you know, for if a button gets clicked or a selection
- 34:28is made, you can run Python code. But you can also create JavaScript callbacks for the standalone
- 34:32case where, you know, I don't have a Bokeh server, but I still want something to happen when a button
- 34:35gets clicked or, you know, the selection is made. You can write a little snippet of JavaScript and that
- 34:39will, you know, do that amount of work. And typically those callbacks, the end result of that is, again,
- 34:43setting some properties on these objects, right? They might update the data source, which causes the
- 34:47plot to update, or they might change the range bounds, which causes the plot to zoom out, that sort of
- 34:51thing. So there is definitely API. There are functions, you know, there are functions for embedding,
- 34:55there are functions for showing things in notebooks, there are functions for creating plots to start with.
- 34:59But most of the content of the Bokeh library is these objects, you know, we call models, and they all have
- 35:04these typed properties that you can set values for. And that's the main interaction mode.
- 35:09Yeah, so very declarative in that sense, right? You set the aspects or the features that you want,
- 35:15and it just figures out how to make that interactive.
- 35:18Yeah, exactly. Yeah.
- 35:19Nice. So it sounds to me like, listening to you talk, there's a lot going on with JavaScript
- 35:24here, even though the typical consumer user of it, the developer doesn't have to care or work with it.
- 35:31What are you using there? Like, what was the history? Was that always just straight JavaScript?
- 35:35Or what's what are you doing?
- 35:36Yeah, it's actually never been straight JavaScript. But you're right, the bulk of the work of Bokeh is
- 35:40actually in this library, Bokeh JS, right, which is JavaScript library.
- 35:42How big is it?
- 35:43So minified, I think the main core library is about 600k. It's a pretty hefty library.
- 35:48That's a pretty hefty library.
- 35:50It is, right. We're looking to make things, you know, as optimized as we can. We definitely could
- 35:53use help from, you know, more experienced JavaScript developers. So when Bokeh started, I mean, it was
- 35:58started by me and a few other folks who are working in none of us, I think, had a lot of front end
- 36:02experience. I didn't have any JavaScript experience when this project started. And so we actually chose
- 36:05CoffeeScript at the time. And so that, I think, was maybe a good choice for the time, because it
- 36:10allowed us to iterate very quickly and sort of make, you know, mistakes more quickly, I guess.
- 36:13You try out things, you know, it's sort of Python looking like, you know, it's one of these
- 36:17transpiled languages that turns into JavaScript. But ultimately, once the project grew very large,
- 36:22it wasn't really suitable for that. And so we actually did a large effort. Most of that work
- 36:26was done. Heavy lifting was done by one of our core contributors, Mateus, to port Bokeh to TypeScript.
- 36:31And that's been a huge win for the project. I mean, just in doing the port to TypeScript,
- 36:34a lot of latent bugs and problems were uncovered. Certainly since it's been done, you know,
- 36:39I've been prevented from checking in things that would have been an error, you know, by the TypeScript
- 36:42compiler. So I'm a big fan of that and glad for that. There are certainly new contributors who find it a
- 36:47little bit more difficult or daunting sometimes to work with TypeScript so that there is a barrier
- 36:50to entry that's a little bit high for Bokeh. And that's actually just in general, been a problem
- 36:55for us, I think, to attract sort of contributors on that side, right? Because Bokeh is targeted towards,
- 37:00you know, Python developers with the promise that they really don't have to worry about JavaScript
- 37:03if they don't want to. But all the work's actually in JavaScript. And so, you know,
- 37:07we need JavaScript developers to come help make Bokeh better. And so for the most part,
- 37:11and so that's been a challenge for us a little bit.
- 37:13You have this bimodal distribution of skills and desires and stuff like the Python folks and the
- 37:19JavaScript folks. And yeah, it's interesting.
- 37:21So we're trying to make Bokeh itself like a, you know, there are people who use the Bokeh
- 37:24JavaScript library just by itself as a JavaScript library. I would say that from my perspective,
- 37:28quite a bit of work is needed to do to make that a serious sort of contender for something people
- 37:32want to use. But we definitely would like to get that done. And we'd love to get help doing that.
- 37:35I think making Bokeh JS as sort of a first class JavaScript library in its own right would be very,
- 37:39helpful for our project. And certainly it'd be great to get a community around that as well.
- 37:43But that's a longer term goal.
- 37:47This portion of Talk Python To Me is brought to you by Linode. Are you looking for hosting that's
- 37:52fast, simple, and incredibly affordable? Well, look past that bookstore and check out Linode at
- 37:57talkpython.fm/Linode. That's L-I-N-O-D-E. Plans start at just $5 a month for a dedicated server
- 38:04with a gig of RAM. They have 10 data centers across the globe. So no matter where you are or where your
- 38:09users are, there's a data center for you. Whether you want to run a Python web app, host a private Git
- 38:14server, or just a file server, you'll get native SSDs on all the machines, a newly upgraded 200
- 38:20gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
- 38:26Need a little help with your infrastructure? They even offer professional services to help you with
- 38:30architecture, migrations, and more. Do you want a dedicated server for free for the next four months?
- 38:35Just visit talkpython.fm/Linode.
- 38:38It's interesting that you found TypeScript to be a nice way of working and whatnot. And I find it'd be
- 38:46pretty nice as well. Certainly, if I had to choose between CoffeeScript and TypeScript, I would
- 38:50definitely choose TypeScript. You know, I think TypeScript is interesting in that it's a superset of
- 38:55JavaScript. So all your regular JavaScript just works, but you can like typify it and make it have other
- 39:00features and capabilities that that language brings. And that's a pretty interesting way to approach that
- 39:07problem.
- 39:07Oh, definitely. Yeah. And to be clear, I think CoffeeScript was the right choice in 2012. I don't,
- 39:11it's not at all the right choice for anything, I don't think, in 2019. I think at the time,
- 39:15Bokeh was one of the largest CoffeeScript libraries probably ever developed, which is interesting,
- 39:20sort of a bit of trivia. But like I said, it let us move fast, especially not having a lot of
- 39:24experience in front-end dev. But, you know, after time, we just needed something more,
- 39:29a little more serious, for lack of a better word.
- 39:30Yeah, sure. I'd just like to get your thoughts real quick. Like, so TypeScript is all about,
- 39:35you know, sort of static typing and checking and whatnot of your code. And we kind of have that
- 39:42in Python a little bit now, to the extent that people want to bring it in with mypy and type
- 39:47annotations. But it's not really the main zen of the language of Python.
- 39:52What are your thoughts of like working in these two languages, kind of side by side on the same
- 39:55project?
- 39:55Well, so this is a really interesting question. So there is actually a history of various projects
- 39:59that add what's called, I think, manifest typing to Python. And so that goes back to,
- 40:03there's definitely a project called Traits that Joseph Morrill created that was, you know,
- 40:07sort of, you could add types to classes, and those would get checked at runtime. And you could also
- 40:11do things like reactive programming and event-based programming based off changes to those values.
- 40:15Traits auto-created like QT GUIs, I think, from classes as well, the panels.
- 40:20And there's another one called Param. And I think there's now one called Struct. But Bokeh
- 40:24also has its own property system. I mentioned these properties of models. Bokeh has its own
- 40:28property system, which is rooted in a bunch of fun metaclass programming that lets you add these
- 40:33declarative types. So the actual models I mentioned for Bokeh objects are typically have no code in them.
- 40:38They're just classes with these property definitions that say, oh, you know, my plot width is an int,
- 40:44or my source property is an instance of a column data source, or the range has two floating point
- 40:50values start and end. And so we're able to provide runtime feedback. If people try to set, you know,
- 40:55the range.start equals some string value, we say, hey, that's not an appropriate value. It needs to
- 40:59be an integer. And we also know what properties are on objects. So a feature people have really
- 41:03complimented it's about is people sort of fat finger a property name, we'll actually give a suggestion
- 41:07and say the nearest property names are named this. And so we-
- 41:10Oh, that's nice.
- 41:10Kind of a type system. Yeah, a really nice feature. It's sort of one of those simple things
- 41:13you don't think about until you see it. But we've had a type system in Bokeh since the beginning,
- 41:17right? And so it's a little interesting now that mypy is becoming more popular. We are interested in
- 41:22looking to use mypy basically after Bokeh 2.0 comes out and we drop Python 2 support. We're
- 41:28interested in trying to integrate mypy, you know, wherever we can. I think it's a useful tool.
- 41:31I hadn't used it much until recently, but I have seen it used to good effect. And so I'd like to try to
- 41:35improve that. I don't know how much we'll be able to use mypy to replace our existing
- 41:39sort of type property system because that would be a huge endeavor because our properties,
- 41:43they aren't just the type checking. They also plug into our documentation system so we can auto
- 41:47generate our reference documentation. Wow.
- 41:49And of course, all the auto synchronization is based on this too, right? A lot of the machinery for the
- 41:53automatic synchronization and serialization is based off these property definitions, right?
- 41:57Right. Like to notify that something has changed to people who are interested and things like that.
- 42:02Yeah. So replacing it with mypy is not something I'm sure we can do for the properties,
- 42:06but there's plenty of other places in the library where mypy would be a great benefit
- 42:10to help us sort of tighten things up. And so we're looking at that after Bokeh 2.0.
- 42:13Okay. Yeah. Yeah. Very cool. Maybe we could do a quick tour of some of the interesting graphs
- 42:18or visualizations that you find, you know, like kind of interesting and worth talking about,
- 42:23like over at demo.bokeh.org or just bokeh.org and just click on the gallery and demos and stuff.
- 42:29There's a bunch of cool ones that has the source code. There's some interactive bits and so on.
- 42:33You want to tell us about something you think are worth checking out?
- 42:35Yeah. So for sure. So first off, if you go to demo.bokeh.org, these are all specifically
- 42:39Bokeh server applications. So these are all backed by running Python process. And when you click a
- 42:44button or make a selection, that triggers real Python code. If you go to the gallery on the docs,
- 42:48most of those are standalone. And so they don't, they aren't backed by a Bokeh server just to get
- 42:52that distinction out of the way. But at demo.bokeh.org, there's a couple of interesting ones here.
- 42:55The first one on the upper left is this movie data explorer. And this is actually a fairly direct
- 43:00comparison, intentional on our part, to a tool called the Shiny Movie Explorer. So people have
- 43:05asked for a long time, where, you know, where is Shiny for Python? So Shiny is this tool for creating
- 43:08sort of interactive data visualization applications from the R language. People ask, where is Shiny for
- 43:13Python? So we're trying to answer that question. And I think Bokeh is a pretty good, decent answer to
- 43:16the question of where is Shiny for Python. But so we made that as a pretty direct comparison. So that's
- 43:20one that's interesting. Right next to it, there's this selection histogram, which I think is pretty
- 43:23cool. So it's got a couple of distributions of scatter points on a plot. And if you make a
- 43:27selection, it shows the histograms on both axes. And if you make a selection across those points of,
- 43:31you know, a subset of those points, it then highlights and shows you the histogram of just
- 43:35the selected points. And then sort of in the opposite direction, the select the histogram of
- 43:39the unselected points and sort of a shadow faded out version. Wow. Yeah, that one's really cool.
- 43:43That's a cute one. We've been working on that one for quite a while. It's gone through several
- 43:46iterations that actually helped us uncover some problems with the Bokeh server early on. It was just sort
- 43:51of behaving in a weird way and stuttering and realized that events were sort of boomeranging,
- 43:54sort of making a boomerang effect. And so we had to sort of fix that out. But that was a great example
- 43:59to help us figure out some of those problems. And we have a lot more things under a lot more rigorous
- 44:02tests now. So that's good. But yeah, I like that example a lot. Another one we have is this
- 44:07reproduction of the gap, the gap minder demo. So, you know, Hans Rosling did this, you know,
- 44:12famous TED talk where he showed all this data. And so we've reproduced that in Bokeh. We've also
- 44:16embedded the YouTube video. We wanted to be able to show being able to use, you know,
- 44:19a template to embed Bokeh content in a template with other content. So this also has this YouTube
- 44:23video embedded.
- 44:23Yeah, that talk by Hans Rosling, you have the video there. It's really worth watching. Like
- 44:30that guy really makes statistics and just data like relevant for humanity in a great way.
- 44:37Absolutely. No, I'd recommend anyone to go watch the video, regardless of where they look at the
- 44:42Bokeh bar. It's a great video. And I think it's a really compelling one. Tells a great story. So
- 44:46I'd recommend anyone to go check that out. For sure. Let's see, lower left, there's actually a
- 44:50financial chart. So here you can have time series from two sort of financial, you know,
- 44:54data sets and you can do sort of a cross correlation between them. And you can see the
- 44:58pandas sort of statistical summary there. And you can, you know, use the dropdown to choose
- 45:02different time series and then the table updates and the data, you know, the plots update. So that's
- 45:06a nice one as well. And then on the bottom right, there's kind of interesting one that's got this 3D
- 45:10plot. And this is maybe confusing for some people. Bokeh itself is not a 3D plotting library and has
- 45:14no inherent 3D capability built in. But Bokeh is very extensible. At some point, we realized that,
- 45:19you know, lots of users have use cases that are eminently reasonable and, you know, really cool
- 45:24that we're just not ever going to have the capability or resources to sort of do in the library. I mean,
- 45:28you have to sort of limit the scope of the core library at some point. Yeah. So we work to make
- 45:32Bokeh extensible. And so you can create these custom extensions that behave just like built-in
- 45:36Bokeh models. And they plug in just like, you know, the plot object or a widget object, right,
- 45:41into Bokeh content. And so this is an example of that. And so this is a custom extension that wraps
- 45:46a little 3D JS library. And you use the standard Bokeh data sources and you update them. And then
- 45:51this little 3D plot updates because basically the custom extension just wires together the Bokeh data
- 45:55source with whatever this other library expects. And so it's really neat example of that. And there's
- 46:00other examples of extensions in the docs as well for different kinds of use cases. If you want to like,
- 46:04if you have some really cool JavaScript widget, you want to connect to Bokeh content. If you actually,
- 46:07if you have a cool JavaScript widget that you want to connect to, you know, all these PyData tools,
- 46:12like you want to connect this JavaScript widget to, you know, scikit-learn or to Dask or to Numbo or,
- 46:16you know, pandas, Bokeh is a great bridge for that, right? You can just write a custom extension that wraps
- 46:21the JavaScript component and then it's automatically Bokeh server can connect it to all those tools.
- 46:25Yeah. And get all the change notification and interactivity and everything. Yeah.
- 46:29That's super cool. Okay. Let's see. What else do you want to talk about? You all have Bokeh 2.0 on the
- 46:35roadmap. What's going on with that? Yeah, absolutely. I would say we were targeting August,
- 46:39but I think maybe a little more realistic at this point is September. We're always a little optimistic
- 46:43in our estimates for our schedule. Welcome to software development, right? That's how it goes.
- 46:48We're all like that way. I don't even want to speculate the first time we promised Bokeh 1.0 and
- 46:52sort of stability. That was probably a couple of years too early, but we're a little more on track
- 46:57for Bokeh 2.0. But the main thing about Bokeh 2.0 is just that we are dropping Python 2 support and
- 47:02also Python 3.4 support. So Python 3.5 will be the minimum version. As long as we are doing a major
- 47:06version bump, we're also going to take the time to clean up a few other minor things. So there's a few
- 47:10minor changes that are coming. Hopefully nothing that's too disruptive for anyone. We're going to
- 47:14be sure to outline and document all those in a migration guide. But that's the main thing is the
- 47:18Python 2 support. And it gives us a chance to do some things like move to native coroutines. So we use
- 47:23tornado as the base for the Bokeh server. But if we move to Python 3.5 as a base, we can use native async and
- 47:29await coroutines everywhere. I'm still with tornado, but it helps us clean up the code a lot. And just
- 47:33in general, it'll help us clean up the code base and make it a lot more maintainable and sort of
- 47:36shrink it. And it's always good to delete and shrink code for sure.
- 47:39Yeah. If you maintain it by deleting it, like you're good. Yeah, that's a good way to do it.
- 47:44Do you think that'll help attract more maintainers to say like, hey, you could work on this cool async
- 47:48IO, async and await library rather than, you know, this thing called tornado and these
- 47:53coroutines?
- 47:54Well, so it's still going to use tornado. And tornado is a really great tool, but I think it may.
- 47:57It broadens the thing a little bit to hopefully some more developers. And there are, I stress that
- 48:02there's a lot of work in Bokeh TS, but there's plenty of work on the Python side to do as well. And we'd
- 48:06love to have contributors. And honestly, there's actually a lot of work that's not coding. I'd love
- 48:10to get other contributors involved in all kinds of ways. And if I can speak a minute about that, I mean,
- 48:14yeah, go for it.
- 48:14Obviously, people talk about, hey, we need testing help and docs and design help and that's,
- 48:18or docs help. And that's certainly true for us as well. But other maybe ways people don't think
- 48:22about it is, you know, we'd love to get like designers, front end designers to come help
- 48:25make our assets better, to come, you know, help us improve the visual appearance of Bokeh. Cause
- 48:29you know, we've done okay, but we're not designers. And so it'd be great to get that kind of help.
- 48:34We actually have a lot of infrastructure now on places like DigitalOcean and AWS, and it would be
- 48:39great to get experienced people that know those, those systems and those DevOps on those systems to
- 48:44come help us optimize them for cost, optimize them for usage, you know, whatever.
- 48:47Yeah. You guys are doing cool stuff with Docker, right?
- 48:50Yeah, we do a couple of things with Docker. So we run the demo sites, actually a Docker image that's
- 48:53run on Elastic Beanstalk. And I actually just recently changed some of the instances that that
- 48:57was running on to hopefully make them a little bit more cost effective for us. But we also just
- 49:01recently had a spike in S3 usage on one of our buckets that I couldn't really explain just yet.
- 49:06And so I'd love to get experienced people that can, you know, help with those sorts of things.
- 49:09Outreach is another area. We're really trying to ramp up our outreach, both to the community in terms of,
- 49:13you know, fundraising, but also talking to companies. And we've had a couple of people help with that.
- 49:17And actually just offering support, right? We just moved our mailing list to a discourse instance,
- 49:22discourse.bokeh.org, which is infinitely better. I mean, the discourse is great for users because
- 49:27there's a lot of features for code highlighting, for math texts, just, you know, all kinds of things
- 49:31we could imagine maybe putting an extension to put in actual bokeh content into these discourse posts.
- 49:35But it's also great for us as maintainers because discourse has a lot of information about what are
- 49:39people searching for, you know, what topics are popular, that sort of thing. So that helps us know maybe
- 49:43where attention needs to go. But just answering questions there, people want to go offer support
- 49:47and help other people use bokeh. That is also a huge deal. I think bokeh has been successful because
- 49:52we've had a few people that have been able to put a lot of time into helping, you know, the community.
- 49:55But as the community grows, that's got to scale. It needs to have more and more people helping each
- 49:59other. And so that kind of thing would also be a great way to contribute to the project. And so
- 50:03there's all kinds of ways people can plug in. And we'd love to, you know, engage with anyone,
- 50:07really, about any of those tasks.
- 50:08Right, right. If you're a designer and you want to make the website look shiny,
- 50:12that'd be great. If you want to make the graphs look better, or maybe you're a visualization
- 50:17expert and you've got a different kind of graph you want to bring, whatever, right?
- 50:20Yeah, absolutely. Or just even making new examples for the docs, you know, making really cool uses of
- 50:25bokeh to show off, to tweet about, to put in our docs and our gallery. I mean, there's all kinds of
- 50:29ways to make very valuable contributions to the project just because there's a lot of things to do. And
- 50:33you know, presently not enough people do them, probably never enough people do them,
- 50:36right. But obviously, the more help we can get, the better.
- 50:39Sure. So if I could summarize, you're willing to accept contributors to the project.
- 50:43Yeah, absolutely. If I hadn't made that clear, yes.
- 50:46That's awesome. Yeah, it's a cool project. It would be fun to work on.
- 50:50Yeah.
- 50:50As part of this bokeh 2.0 thing and the dropping of Python 2, which I like to refer to as legacy Python,
- 50:56and Python 3 just as straight Python. But as part of dropping legacy Python, one of the things you did,
- 51:03this is kind of a trend in the data science space, not, I haven't seen it as broadly adopted,
- 51:06and I'm not really sure why, you signed the Python 3 statement. You want to tell folks about that?
- 51:12Yeah. So the Python 3 statement is just, you know, it's a GitHub repository where projects can go and
- 51:16sort of make a PR to list themselves on this website. And it says, we're going to, we pledge to drop
- 51:20Python 2 support, you know, by sort of this date or this timeframe, and support Python 3 going forward.
- 51:25And so there are a lot of projects that have signed that. And it's interesting, I thought going in that
- 51:29bokeh was going to be maybe kind of a leader in this, I wanted to be fairly aggressive. But
- 51:33all of a sudden, this year, a ton of projects have started releasing, you know, new releases that sort
- 51:37of are cut off from from that. And so like things like I think Matt Potlib, and yeah, and I think,
- 51:42you know, Dask, maybe and I forget what else, but there's all these sort of big projects that are
- 51:46just suddenly, you know, we're never behind the curve, right? They've already dropped Python 2 support,
- 51:50and we're sort of lagging behind. But I think it's time. I mean, bokeh is definitely used a lot in,
- 51:54you know, analytics space. And I think things do move a little bit faster there.
- 51:57Part of that is because of Conda and Anaconda and Conda Forge, they sort of push things forward.
- 52:02I think also data scientists, you know, do a lot of exploratory work, and they're willing to sort of
- 52:06move a little bit, you know, in that exploratory work, they're willing to sort of move and put up
- 52:09a little bit more change to get new features and to, to get that level of performance better.
- 52:14Once things get deployed, that's when things get a bit more sticky. And that's where you see a lot of
- 52:17people still using Python 2 and, you know, finance and, you know, other venues like that.
- 52:21Yeah, absolutely. I feel like these the data science exploration stuff and the models,
- 52:25like the underlying technology is changing so quick there, right? Like TensorFlow has come out and
- 52:31pandas and all these things are just changing so quickly that if you're going to come back to it,
- 52:36you may want to just move to something new or shiny or better anyway. And you just it's much easier to
- 52:41stay on Python on the later version of Python, whereas like, that website that that guy that used to
- 52:46work here ran that now we just have to keep running like nobody wants to touch that, right?
- 52:51As soon as you touch it, it's your problem to fix it if it ever has a problem. And nobody wants that
- 52:55puppy, right? Yeah, yeah. So some of the companies that are projects that sign the Python 3 statement,
- 53:00just Python 3 statement, the number three statement.org, TensorFlow, requests, XGBoost,
- 53:06NumPy, IPython, like that kind of stuff, right? Cython, Spider. There's a ton of projects here.
- 53:12Yeah, it's great.
- 53:13A lot of those projects already have. I thought we'd be sort of leading the pack, but we're actually
- 53:17behind the curve. And that's what made it very easy for us to say, okay, you know,
- 53:21Q4, it's going to be really easy for us to drop Python 2 because all these other projects will
- 53:24have already dropped Python 2.
- 53:26Right, right. For example, Tornado is in there and you guys are built on that. So in a sense,
- 53:29they're kind of calling your, not calling your bluff, but making sure you're going to have to
- 53:32follow along anyway if you want to stay in the latest of that, right?
- 53:35Yeah, even NumPy, right? I mean, you know, obviously,
- 53:37we could pin to a lower version of NumPy, but we don't want to do that.
- 53:40Yeah, of course, you wouldn't want to do that. Interesting. So we're just about out of time,
- 53:43but you want to talk about Portland real quick? Sure. Yeah. Yeah. So we were both in Portland,
- 53:48right? You recently, somewhat recently, not super recently, but you're somewhat new here and you're
- 53:54trying to get some stuff going in the data science space in Portland as well, right?
- 53:57Yeah, absolutely. Yeah. So I've been here about a year and a half and it's been a really great
- 54:00experience being here in Portland. I really love it. But I am trying to get a PyData meetup here
- 54:06started. In fact, we have a first meetup scheduled for, I think, August 14th. And we're going to
- 54:11alternate sort of between an east side and a west side, you know, downtown location, hopefully,
- 54:15every other month. But me and a colleague of mine are getting that off the ground. And I'm really
- 54:20excited about it. So PyData is this series of meetups slash conferences, if the meetups get big
- 54:24enough, that is sort of sponsored by NumFocus. And, you know, I've been involved with NumFocus since the
- 54:28beginning. I think it's a terrific, amazing organization. The people that are there are really
- 54:31great. And I think the PyData meetups in particular have been really, really great, you know,
- 54:35both meetups and also the PyData conferences are also really good as well. So really excited to get that
- 54:39started in Portland. I was almost kind of surprised that it wasn't here already. There's a, you know,
- 54:42there's a PyData Seattle meetup and there's PyData meetup. There's like 105 PyData meetups,
- 54:47I think, around the world. So it was by far time that Portland gets one. So I'm really excited to
- 54:51be helping get that off the ground. Yeah, that's awesome. I mean, that only really is interesting
- 54:55to like 5% of the listeners, maybe. But it's still really cool that you're doing that here in
- 54:59Portland. And, you know, other folks, they can create a PyData, their city's airport acronym if
- 55:05they want, right? Absolutely. I think most places don't use the airport acronym,
- 55:08but I'm really fond of PDX. So I invited a PDX on a good.
- 55:11Yeah, it's definitely a good one. All right. Well, you know, Bokeh is a really cool project,
- 55:15and I'm glad you all have been working on it. And it's great to see all this progress and excitement
- 55:21around it. It's a great, great one. So people should definitely check it out.
- 55:24Yeah, yeah. Well, thank you very much for having me. I love to have the opportunity to sort of spread
- 55:27the word and talk about Bokeh. And it's been really great.
- 55:30Yeah, absolutely. Let me ask you the final two questions before you get out of here, though.
- 55:33If you're going to write some code, probably Python code, but maybe JavaScript as well,
- 55:37I guess. What editor do you use?
- 55:39I have been won over by VS Code.
- 55:40Okay.
- 55:41Yeah, I still use VI binding. So I grew up using VI and that's still in my fingers. And so I love
- 55:45VI bindings. But I used to use Sublime Text, but I moved to VS Code and haven't looked back.
- 55:49Yeah, that seems a pretty straightforward choice to go from Sublime to VS Code.
- 55:53Those are, you know, one has so much more energy and they're super similar in their sort of workflow.
- 55:58And then notable PyPI package, I'll go ahead and throw out there Bokeh for you. And what else? If
- 56:04there's something like, hey, I ran across this and people might not know about it, but it's really
- 56:08amazing. What would you say?
- 56:09Yeah, let's see. Well, I'll say PyPI or Konda, right? So don't forget Konda. Very important
- 56:13to remember. But, you know, it's hard to say. I'm so focused on, you know, using and working on Bokeh.
- 56:21That's like my day to day. Honestly, I have a little bit of tunnel vision, maybe to put it one
- 56:25way. But, you know, I think a lot of the tools that are built on top of Bokeh are really interesting to
- 56:29me. And so I like, you know, looking at what is happening with them and seeing what developments
- 56:32are going. Obviously, I think all the tools in the PyData ecosystem are amazing. I think Numba in
- 56:37particular is really interesting. So Numba is a compiler for Python, lets you really accelerate,
- 56:41you know, certain kinds of code. And it was originally created again by Travis, you know,
- 56:45Oliphant, but it's been moved on since then. And it's actually grown really successful in certain
- 56:50kinds of venues. So I think Numba is a pretty interesting use case. And I certainly, of course,
- 56:53think Dask is really fantastic as well. Yeah, those are definitely good ones. All right,
- 56:57Brian, final call to action. People want to get started with Bokeh. What do they do?
- 57:01Yeah, absolutely. Love to get people involved. So if you want to, you know, talk about development or
- 57:06have questions about support, we have this discourse, discourse.bokeh.org. If you want to just
- 57:09get started from a very high level, just bokeh.org is a great one stop to get to a lot of other
- 57:14resources like documentation, like the gallery, like the GitHub page, and just to see what,
- 57:19going on. But in terms of like talking to us, yeah, the discourse is a great spot to make a
- 57:23poster topic there. And of course, GitHub is a great place if you have ideas for suggestions,
- 57:27you know, or want to report problems, of course, you know, GitHub is a great place to contact us.
- 57:31Yeah, for sure. And PRs are accepted.
- 57:32PRs are always accepted. Yes.
- 57:34Yeah, very cool. At least considered.
- 57:36Consider.
- 57:37At least considered for sure.
- 57:38Cool. All right. Well, thanks so much for being on the show. It's good to talk with you.
- 57:41Absolutely. Thank you so much, Michael.
- 57:42Yeah, bye.
- 57:43Bye.
- 57:43This has been another episode of Talk Python To Me. Our guest on this episode was Brian Vandevin,
- 57:50and it's been brought to you by Ting and Linode. Ting is the fast mobile network custom built for
- 57:55technical folks. Use their savings calculator to see exactly what you'd pay. Visit python.ting.com
- 58:01to get a $25 credit and get started without a contract. Linode is your go-to hosting for whatever
- 58:08you're building with Python. Get four months free at talkpython.fm/linode. That's L-I-N-O-D-E.
- 58:14Want to level up your Python? If you're just getting started, try my Python Jumpstart by Building 10 Apps
- 58:21course. Or if you're looking for something more advanced, check out our new async course that digs
- 58:27into all the different types of async programming you can do in Python. And of course, if you're interested
- 58:31in more than one of these, be sure to check out our everything bundle. It's like a subscription
- 58:35that never expires. Be sure to subscribe to the show. Open your favorite podcatcher and search for
- 58:41Python. We should be right at the top. You can also find the iTunes feed at /itunes, the Google
- 58:46Play feed at /play, and the direct RSS feed at /rss on talkpython.fm. This is your host,
- 58:53Michael Kennedy. Thanks so much for listening. I really appreciate it. Now get out there and write
- 58:57some Python code.
- 59:01We'll see you next time.