Latest / Talk Python To Me / #424: Shiny for Python
Transcript
- 0:00If you want to share your data science results as interactive web apps, you could learn Flask or Django and a bunch of other web technologies.
- 0:06Or you could pick up one of the powerful frameworks for deploying data science specifically.
- 0:11And if you're searching through that space, you're likely to hear about Shiny.
- 0:15But that's just for the R side of data science, right?
- 0:18Not any longer.
- 0:19Joe Chen is here to introduce us to the recently released Shiny for Python.
- 0:24And it looks like a really solid new framework on the block.
- 0:28This is Talk Python To Me, episode 424, recorded June 19th, 2023.
- 0:34Welcome to Talk Python To Me, a weekly podcast on Python.
- 0:50This is your host, Michael Kennedy.
- 0:52Follow me on Mastodon, where I'm @mkennedy and follow the podcast using @talkpython,
- 0:57both on fosstodon.org.
- 0:59Be careful with impersonating accounts on other instances.
- 1:02There are many.
- 1:03Keep up with the show and listen to over seven years of past episodes at talkpython.fm.
- 1:08We've started streaming most of our episodes live on YouTube.
- 1:12Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.
- 1:20I'm really excited to have a new sponsor for this episode.
- 1:23Welcome on board to GlareDB.
- 1:26GlareDB is an open source database for querying distributed and disparate data.
- 1:31Connect your data sources and use the Python tools you already know to ask questions and integrate data across data sources.
- 1:39Get started today at talkpython.fm/GlareDB.
- 1:42And it's brought to you by InfluxDB.
- 1:45InfluxDB is the database purpose built for handling time series data at a massive scale for real-time analytics.
- 1:51Try them for free at talkpython.fm/InfluxDB.
- 1:57Hey, Joe.
- 1:57Welcome to Talk Python To Me.
- 1:59Hi, Michael.
- 1:59It's a pleasure to be here.
- 2:00It's a pleasure to have you here.
- 2:02We're talking Python to an R person.
- 2:04What's going on here?
- 2:05What is happening?
- 2:06I know, right?
- 2:07Cats and dogs living together.
- 2:10Oh, my gosh.
- 2:11No, it's great.
- 2:12Glad to have you here.
- 2:13Yeah, thanks.
- 2:14So we're going to talk about Shiny, which has traditionally been UI framework, a web framework for kind of rad rapid development for R applications that need some interactivity.
- 2:26But you have a big release for the Python people.
- 2:29That's also interesting and worth talking about.
- 2:32So that's the topic of today's show.
- 2:34Yeah, absolutely.
- 2:35I hope you starting out mentioning R that people haven't dropped off already.
- 2:40I promise we'll have lots to say about Python and Shiny for Python.
- 2:44Of course, I'm sure.
- 2:46Shiny for Python is going to be super fun.
- 2:48Before we get to that, though, let's get started with your story.
- 2:51How did you get into programming R and then what brought you over to Python, at least temporarily or partially?
- 2:57Yeah, my background was in web programming really more than anything else.
- 3:01I got into programming actually through desktop publishing and graphic design.
- 3:05That was what I was really excited about.
- 3:08And in college, that turned into web design.
- 3:10I went to college from 1996 through 2000.
- 3:13So that the height of the dot com sort of craziness.
- 3:16And I just found myself.
- 3:18CD Baby and all that stuff.
- 3:19Oh, yeah.
- 3:19Absolutely.
- 3:20Pets.com.
- 3:21Oh, yeah.
- 3:22Pets.com.
- 3:23That's right.
- 3:23And I just found myself sort of pulled into just all the cool things that we could do on the web.
- 3:29And went from sort of front end web development, which meant something very different back then than it does today.
- 3:35I mean, HTML, right?
- 3:37HTML.
- 3:37Yep.
- 3:38Basically, string interpolation as a career.
- 3:41That was what I was all about.
- 3:42And that sort of led me into really falling in love with programming as a discipline.
- 3:47And I got more into the back end, more into sort of closer and closer to the systems level programming.
- 3:54And I just really enjoyed being sort of full stack, both on the website and even spent a few years doing Windows desktop programming, just to kind of see what that world was like.
- 4:05And one of the things that I like, one of the best things that happened to me early in my career was hooking up with JJ Allaire, who's the founder of our studio and the founder of two other companies that I worked for previous to that in Boston.
- 4:19And I kind of got to the point in my career where I was more interested in the people I was working with than the technologies or even the idea.
- 4:28I knew I liked startups and I knew I liked working for JJ and the people that he had around him.
- 4:33And he got excited about R.
- 4:35I think his friend who was like a high school science teacher somehow got turned on to R.
- 4:41And JJ was fascinated by the fact that this is in 2008 or 2009.
- 4:49There was this GPL licensed platform for doing what traditionally people would do in very proprietary platforms like all these statistics packages that you might have been forced to learn in college, you know, back in the 2000s.
- 5:05And here was this pretty rough, pretty raw, but all the pieces were there kind of platform for doing all this stuff with code.
- 5:13And he immediately saw something and I definitely saw nothing.
- 5:16But I believed in JJ and I he had the idea to build an IDE in a web browser for this R language.
- 5:24And I was like, I don't see the chain and thinking that leads you to think that this is a good idea, but also sounds super fun.
- 5:32And I would love to see if it's possible to build an IDE for the web.
- 5:36And so in the beginning, really, I was in R completely by accident.
- 5:42And I didn't even really learn much R as I was building, helping to build the RStudio IDE.
- 5:46That's kind of the irony of those types of platforms, right?
- 5:49100%.
- 5:50When I talk to people about Jupyter Notebooks, they're enabling Python people, but they're writing TypeScript.
- 5:55That's exactly right.
- 5:57That's right.
- 5:57What's the story for RStudio's side?
- 6:00Yeah, yeah.
- 6:01Oh, it's a crazy story technology wise.
- 6:04Well, the part that's not crazy, the sort of hardcore server bits are written in C++.
- 6:08But the front end, the front end is written in Java, which is then transpiled to JavaScript using a package called Google Web Toolkit.
- 6:17Oh, yeah.
- 6:17Okay, sure.
- 6:18Oh, okay.
- 6:18So you've heard of GWT.
- 6:20I haven't written anything with it, but yeah, I know it.
- 6:21Sure.
- 6:22Yeah.
- 6:22I mean, in a world before TypeScript and before React, this really was a godsend.
- 6:29Like to be able to have static typing and the right sort of abstractions to be able to really build large scale.
- 6:37I mean, RStudio is a giant piece of software, hundreds and hundreds of thousands of lines of code.
- 6:41And I think the very best JavaScript developers can write code bases at large of pure JavaScript, but not me.
- 6:48Like I definitely needed the crutch of, you know, static type checking.
- 6:53And anyway, working on RStudio ID was a blast.
- 6:57And the best thing about it was I got to meet so many data scientists.
- 7:00And at the time, we call them statisticians.
- 7:02Now they call data scientists.
- 7:04But learning what they do, what the problems they were solving was so interesting.
- 7:08And that eventually led to Shiny.
- 7:11And that's when I really started getting serious about actually writing R code in my day to day, which was a fascinating journey in and of itself.
- 7:18Yeah.
- 7:19Well, I would say that your faith was well placed, right?
- 7:23Even if you're like, I'm not sure about this RStudio thing.
- 7:25I think it's, I think some people have heard of it.
- 7:27Yeah.
- 7:29Yeah.
- 7:29It really has been such an incredible, such incredible ride.
- 7:33And there were many steps along the way where I was like, this does not really make a ton of sense to me.
- 7:39But JJ has proven out time and time again that things that he cares about, it turns out that there are other people that care about it.
- 7:47So he was really super into reproducible research before it was on everybody's lips.
- 7:53And he really spent a lot of time trying to make that world better for R.
- 7:57And by then I'd certainly learned to sort of trust in his instincts.
- 8:02And, you know, just time after time, there have been many bets like that that have paid off really well.
- 8:06It must have been pretty gratifying to work on this project and then talk to these data scientists and say, you know, here, oh, we're doing this work at the Large Hadron Collider.
- 8:16Or we're doing this work to solve cancer.
- 8:18And let me, you got to, can you help me with this?
- 8:22I'm trying to like work on this protein folding or, you know, something like that, right?
- 8:25Yeah.
- 8:26Probably with some really cool experiences you had like that.
- 8:28100%.
- 8:29Yeah.
- 8:29I think the first time I ever demoed Shiny in particular at a user group meeting and I was super nervous and went a little overboard on having like lots of demos.
- 8:40And one of them, this is back in 2012, was charting the spread of AIDS throughout the world and showing the sort of levels rise and fall as time went on.
- 8:50And it was interesting at the time because AIDS was sort of receding as education and drugs were getting better.
- 8:57Except in South Africa, it was getting much, much worse before finally starting to get better because, well, because of many reasons.
- 9:04And so I showed this demo and then afterwards, a friend of mine who I didn't know what he worked on, I just knew him through these user group meetings, came up and said, oh yeah, I'm working at, I think he was at Fred Hutch at the time, working on, you know, an AIDS vaccine.
- 9:16And we're using Shiny to basically be the bridge between the biostatisticians and the biologists and looking at the results of these, you know, assays or whatever it was that they were analyzing.
- 9:26And that was just blew me away.
- 9:27And absolutely, every conference I go to, you know, many times a year between then and now, I've just been humbled by the kind of things that people are doing with Shiny.
- 9:37You know, I can really, I hear some stories like that as well.
- 9:39And I imagine it's just 10x when you're building developer tools like that.
- 9:43So how about now?
- 9:44What are you doing day to day?
- 9:45Yeah.
- 9:46Well, my title is CTO.
- 9:47That is an honorary title that I think reflects that I was the first employee, but I don't do traditional CTO type activities most of the time.
- 9:56My day to day, I help lead the Shiny team specifically, which is a team of maybe 10 or 11 right now, mostly engineers.
- 10:04And we split our time between Shiny for R and Shiny for Python.
- 10:09Right now, probably more on the Shiny for Python side, given that there's so much more to do.
- 10:12And right now, I am in the thick of it, writing features for the next release of Shiny for Python, really getting to lean into React.
- 10:22I've been working with some really fun, like headless table libraries to build data grids with, you know, fast virtualized scrolling.
- 10:29That should be a really nice addition to Shiny for Python for the next release.
- 10:33Okay. Yeah, that sounds really cool.
- 10:35Well, let's talk about Shiny itself.
- 10:37I suspect a lot of people on the data science side have heard of Shiny, even though it's in the R space.
- 10:43I know the conversations come up around it.
- 10:46Other ones that kind of live in a similar orbit, maybe, are, you know, Streamlit.
- 10:51I've had Adrian on, the founder of Streamlit on before, and we've got Dash and Panel and Pinecone and others.
- 10:57So, you know, that sort of sets the stage for what this could be about.
- 11:01Maybe give folks a sense of just what is Shiny and it's, you know, maybe even in its R form originally.
- 11:08And then we can talk about the Python side.
- 11:11Yeah, absolutely.
- 11:12So, Shiny is a way to create web applications easily without having to learn a lot of web development technologies like HTML, CSS, and JavaScript.
- 11:22Especially JavaScript.
- 11:24Especially JavaScript.
- 11:25100%.
- 11:26The interactive part of all these, like this callback hits that.
- 11:30Yeah.
- 11:31100%.
- 11:31Yeah.
- 11:32It was conceived primarily for data science.
- 11:35It is, I think a lot of the ideas behind Shiny are quite general and we'll, I'm sure we'll delve more into that.
- 11:42But we, in the creation design of this, we really are laser focused on data science and the kinds of problems that people want to solve by creating interactive visualizations, interactive reports, and even like workflow applications.
- 11:57But all of it around the analyzing of data.
- 12:00This was, in 2012, this was like a pretty radical notion.
- 12:06And I think there was a little bit of skepticism from some people close to us who were thinking, like, you're going to make data science, you know, like, why would data science scientists want to become web developers?
- 12:17And I think this was, the answer was like, there are really a lot of problems that they can solve using interactive artifacts.
- 12:24But the whole point is that they do not have to become web developers.
- 12:27Yeah, I was going to say, like, you should turn that on its head and say, they don't want to become web developers, which is exactly the value proposition, right?
- 12:36They want to share their work, and they want to make it interactive and collaborative.
- 12:39But the last thing they want, generally speaking, is to like, and I'm diving into Vue and React and all that stuff, right?
- 12:48Yeah, absolutely.
- 12:49Absolutely.
- 12:49Yeah.
- 12:50Yeah.
- 12:50And that being said, I think I personally am, you know, I've been doing web development since basically 1996.
- 12:59And the idea of working day in and day out on a project that was really sort of like my first website type, you know, like something that had a lot of guardrails, something that really limited you to whatever few tools were in its toolbox, that wouldn't be really satisfying or interesting for me.
- 13:17So even though Shiny is designed to be very easy to get started and for you not to have to know JavaScript or anything like that, if you do know JavaScript, if you do know HTML and CSS, if you, you know, live and breathe that stuff, but you want to create a convenient way to create data science related applications, Shiny really lets you lean into those skills as well and use HTML, CSS, and JavaScript to enhance or customize or extend Shiny for your own purposes.
- 13:41It's really important to us to capture sort of both ends of that spectrum.
- 13:47This portion of Talk Python To Me is brought to you by InfluxData, the makers of InfluxDB.
- 13:52InfluxDB is a database purpose built for handling time series data at a massive scale for real-time analytics.
- 14:00Developers can ingest, store, and analyze all types of time series data, metrics, events, and traces in a single platform.
- 14:07So, dear listener, let me ask you a question.
- 14:10How would boundless cardinality and lightning-fast SQL queries impact the way that you develop real-time applications?
- 14:17InfluxDB processes large time series data sets and provides low-latency SQL queries,
- 14:22making it the go-to choice for developers building real-time applications and seeking crucial insights.
- 14:27For developer efficiency, InfluxDB helps you create IoT, analytics, and cloud applications using timestamped data rapidly and at scale.
- 14:36It's designed to ingest billions of data points in real-time with unlimited cardinality.
- 14:42InfluxDB streamlines building once and deploying across various products and environments from the edge, on-premise, and to the cloud.
- 14:50Try it for free at talkpython.fm/InfluxDB.
- 14:55The link is in your podcast player show notes.
- 14:57Thanks to Influx Data for supporting the show.
- 15:02We'll talk about the programming model and how it works, but I think maybe the first big contrast that I'd like you to set up for us is thinking of the Python side now.
- 15:11Like, why not just Jupyter Notebooks?
- 15:13Why not Jupyter Notebooks or Jupyter Lab?
- 15:16And just, we have that.
- 15:17That's on the web, sort of, kind of sometimes.
- 15:20It depends how we want to put it up there or share it or let it be executable.
- 15:24But, you know, compared to that, I think it's pretty different.
- 15:27But, you know, I think it's something that people maybe want to get their head around.
- 15:29Yeah, no, totally.
- 15:30You're right.
- 15:31I mean, you hear a lot of the same words being used, right?
- 15:33Like, you know, it's browser-based applications that do interactive things.
- 15:37And I think the difference is that Jupyter and Jupyter Lab, those are sort of the places where data scientists can do work, right?
- 15:44Where you can ask unbounded kinds of questions from your data.
- 15:47And that's where you iterate, where you do exploratory data analysis, where you, you know, write functions and things like that.
- 15:53And, yeah, you do have this beautiful immediacy to the results that you get, right?
- 15:58That's why everybody really loves working in notebooks.
- 16:01And Shiny and frameworks like it are really for communicating outwards.
- 16:06It's really not for the data scientists to write code for their own understanding most of the time.
- 16:12It's really about creating a web application to show somebody else.
- 16:16Let's say that you, you know, are collaborating with some people that are, don't have the programming chops that you do, that have never launched a REPL in their life or installed Python.
- 16:25And you want to give them the ability to ask questions of your data and of your analysis.
- 16:31Maybe what if scenarios or in the simplest case, think like a BI dashboard or something like that.
- 16:37Like nobody's asking why, you know, execs need to look at a BI dashboard instead of running SQL queries on their own, you know, inside of a console.
- 16:46And this is similar.
- 16:47So if you want to create an interactive artifact for other people to consume, then Shiny and frameworks like it come into play.
- 16:55And Jupyter, not as much.
- 16:56I mean, you can certainly save Jupyter notebooks and then sort of share, you know, a link to the published notebook.
- 17:02But the interactivity is either non-existent or more limited when you do things that way.
- 17:08Absolutely.
- 17:08You don't want to give them the full notebook because the last thing you want is the general public typing Pantos code in there or arbitrary Python code.
- 17:18But you want to give them some interactivity.
- 17:20You know, maybe we could look at this little example down here just to, you know, just talk through like what an app might look like.
- 17:27Right on the homepage, shiny.posit.co, you have, you know, I think this is kind of a big statement towards your commitment to Python.
- 17:36It's like right on the homepage on equal, on par with R.
- 17:39It says get started with R, get started with Python.
- 17:41And you scroll down, it has the R in the Python code, right?
- 17:43Like they're not like, hey, we also will make an attempt at this Python thing.
- 17:46But you've got this example.
- 17:48Do you want to give us a quick talk to what this app is?
- 17:50It looks like it evaluates things about ducks and that's all I can tell about it.
- 17:54Yeah.
- 17:55Stuff about ducks.
- 17:56This is using the Palmer's Penguins dataset.
- 17:59Penguins rather, okay.
- 18:00Yeah, yeah.
- 18:01So on the left, we have a sidebar with a number of controls.
- 18:05There's two select boxes.
- 18:07There's some check boxes.
- 18:08And then there's a couple of toggle switches.
- 18:10And on the right, you have a matplotlib generated scatterplot with some marginal plots added on.
- 18:17And this is sort of the hello world of Shiny, where you have one or more outputs and some inputs that when you change them, the output automatically updates.
- 18:31In this case, you can decide what variables do you want to apply to the X and Y axes.
- 18:37And then you can filter it by the species of penguin.
- 18:40And then there are a couple of toggles to just decide whether you want coloring by species and whether you want the marginal plots or not.
- 18:48And it sort of does everything that you would expect it to do when you select and deselect those values.
- 18:53Yeah, so for example, you have filter by species and Gen 2 is checked.
- 18:57But if I uncheck it, the whole UI redraws with just showing the other two species of penguin.
- 19:04And you can turn the species on and off and terms on whether or not like it highlights based on that.
- 19:11Yeah.
- 19:12You've got to drop down for different things you might compare.
- 19:14And you can just toggle those.
- 19:16And the UI changes kind of like you wrote a fancy front-end JavaScript framework where that's happening behind the scenes, right?
- 19:23That's right.
- 19:23That's right.
- 19:24Yeah, sorry, I didn't mean to cut you off there.
- 19:25Yeah.
- 19:26And just to be clear, when you say the UI redraws, we're not talking about a whole page reload.
- 19:29I mean, it's not 1998.
- 19:31It is, you know, the things that need to update, update on the page.
- 19:35Yeah.
- 19:36It's a really interesting way to create programs.
- 19:39And there's a couple other things I've seen that are like this, but I really, I think it's a super slick framework.
- 19:46Before we get into it, Diego's got a question.
- 19:49It says, could China be used to do fancy math, say, for someone trying to upload their GitHub website for their PhD thesis model?
- 19:55Like, what can we create?
- 19:57Like, could you create a kind of a LaTeX-looking integrated thing with interactive math bits in there?
- 20:02Right, right.
- 20:03Yeah, yeah.
- 20:04So, yes, you do have the ability to do, well, I could interpret that question one or two.
- 20:09One is, yeah, can you do the computation for this PhD thesis model?
- 20:15And in that case, absolutely.
- 20:17It's just whatever you can express in Python or R, for that matter.
- 20:20And in terms of putting, like, LaTeX equations on the screen, yes, this is a completely built-in feature for Shiny for R.
- 20:29And for Shiny for Python, it's a little less slick, but we do have an example application that shows how to drop in.
- 20:35It's based on MathJax, basically.
- 20:37So you can include the resources for MathJax and then write your equation in LaTeX format.
- 20:45And, yeah, it'll render.
- 20:46Diego, I hope that answers your question.
- 20:48Hope so as well.
- 20:50Yep.
- 20:50Seems like it.
- 20:51All right.
- 20:52So let's jump over to the GitHub page for a minute here and talk through some of the things that you all call out right at the top.
- 20:59So it's open source for one, right?
- 21:01That's a big deal.
- 21:03It's under the MIT license right here on GitHub under PyGash Shiny.
- 21:07Yeah.
- 21:07I should add, you know, full disclosure, we are a for-profit company.
- 21:11We are a B Corp.
- 21:12Actually, we're a benefit corp, but we are for-profit.
- 21:15And Shiny for Python is completely open source, MIT license, no sort of gotchas there.
- 21:22When it comes to deploy your Shiny app, we have a variety of different ways you can do that that we offer as a company.
- 21:28We have an open source on-prem solution called Shiny Server.
- 21:32We have hosted cloud hosting that we manage that you can easily deploy to.
- 21:38And we have free and paid tiers.
- 21:40And we also have Posit Connect, which is a sort of a more comprehensive platform for enterprises to allow their data scientists to communicate with the rest of the organization.
- 21:51And that has, like, very robust enterprise-grade Shiny for Python hosting built in, and that is a paid product.
- 21:58Okay.
- 21:58Does it have, like, special ways to access, like, your SQL server on your enterprise, you know, like, access more authenticated access to data or auth to the thing itself to protect it and so on?
- 22:11Yeah.
- 22:12For sure, auth to the thing itself.
- 22:14And it integrates with your, you know, LDAP or SSO-type systems.
- 22:18And it helps with scaling your application, so it will sort of monitor how much load each of your Python processes is getting and then spawn, you know, automatically scale up.
- 22:29It can, you know, hook up to Kubernetes in the back end so that your Shiny apps, the Python computation is happening, you know, in pods on the back end.
- 22:37So lots and lots of different ways that it sort of tries to make things easier.
- 22:41Sure.
- 22:42Okay.
- 22:42Cool.
- 22:43Very cool.
- 22:43So basically, short story is Shiny for Python's open source.
- 22:47I could take the on-prem open source thing and just host it myself if I wanted.
- 22:51I presume that means I could also fire up a virtual machine in the server, in the cloud, and install it up there and kind of, that's my on-prem if I wish.
- 23:00Yeah, absolutely.
- 23:01And this is also, Shiny for Python is built on top of Starlet, which is the same underlying framework that FastAPI uses.
- 23:09So it's almost true that anywhere you can host FastAPI, you can host Shiny for Python.
- 23:14Oh, interesting.
- 23:14Just put some Gunicorn, uvicorn workers in front of it.
- 23:18Except Gunicorn.
- 23:20Yeah, the only exception is that because Shiny for Python is stateful and we can talk more about that as we, I'm assuming we're going to talk a little bit about how we compare to some of the other things out there.
- 23:30We do need, if you're going to load balance across multiple processes, it does have to be a stateful load balancer, which is normally quite easy to do.
- 23:38But Gunicorn is not stateless.
- 23:39It's not sticky.
- 23:41It's stateless, yeah.
- 23:41Sorry, yeah.
- 23:42So you need a sticky load balancer.
- 23:44And, oh, I should also mention that Hugging Face is another place that you can deploy Shiny for Python apps these days.
- 23:50Yeah, excellent.
- 23:51Okay, well, I think that that's certainly a fair trade-off to the commercial side of your story, which we started talking about by a new company and going to work on that.
- 24:01And it's really about sort of Shiny as a service and a Shiny cloud, so it's easy to not worry about the deployment side, right?
- 24:08The app itself, the framework itself is about not worrying about writing web stuff.
- 24:12The deployment thing is still a deal, right?
- 24:15If you just say, and then you just get dear data scientists, you fire up your Linux machines and you keep them up to date and secure.
- 24:21And that doesn't feel great to a lot of data scientists either, I'm sure.
- 24:24Yeah, yeah, that's right.
- 24:26So I think with our open source on-prem hosting, it's like that.
- 24:32It's just a piece of software that you install on Linux.
- 24:35And with Connect, it's more like your IT department sets this up for you.
- 24:40And then you straight from your local machine, once you have your Shiny app working, you just type in a command like RS Connect deploy and point it at your server and everything gets taken care of for you,
- 24:52including, you know, getting all the right Python dependencies installed on the server and using the right version of Python.
- 24:58And hopefully the act of, you know, we have customers that are writing multiple new Shiny apps a day and deploying multiple new Shiny apps a day.
- 25:07And, you know, the usefulness of that app might be a day or it might be, you know, five years.
- 25:14And we want to serve both sides of that spectrum.
- 25:17I suspect that does make a lot of sense.
- 25:19If you're a data scientist exploring something, you can be like, hey, look, I came up with this today.
- 25:24What did you think?
- 25:25And maybe the next day, based on feedback, you do something completely different and it's become irrelevant, right?
- 25:29Yeah.
- 25:30And, you know, one interesting thing about this is, you know, you hear about something like Shiny for Python, like, you know, Streamlit or Dash.
- 25:37And you think that this is really about displacing, say, Power BI and Tableau, right?
- 25:43But actually, in our experience with Shiny for R, the first thing it displaced were gigantic PDFs that people were sending around.
- 25:50You know, like, I have generated all of this data for my analysis.
- 25:54I don't know what you want.
- 25:56So here is like a 500-page PDF filled with tables for you to go explore.
- 26:00And with Shiny, you can present something that's much more interactive.
- 26:04That makes it much easier for some domain expert on the other side to find a needle in the haystack that you happen to be working together.
- 26:10Well, you know, you completely removed that cycle, that iteration cycle of what if we used a different number for this, you know, constraint here?
- 26:17What if we only filtered?
- 26:19It's like that's part of the UI.
- 26:20That's part of what you deliver is that interactivity.
- 26:22And as far as displacing things, it sounds like you're displacing SharePoint.
- 26:26If that could just be completely erased from the world, that would be awesome.
- 26:31Because every interaction I have with that software of sharing, like corporate doc sharing, is just like, oh, boy, here you go.
- 26:37Okay.
- 26:38Let's take it top to bottom maybe for here in this.
- 26:41Although I do have to point out, I could tell you still have that love for R because it's still 0.2% R.
- 26:47I love it.
- 26:49It's 47% Python, 47% Java Script.
- 26:52Yeah.
- 26:530.2% R.
- 26:54I just want to make it clear.
- 26:56You do not have to install R to run Shiny for Python.
- 26:58I think that R is there's a couple of scripts that we use that we grab resources from the Shiny for RP repo.
- 27:05And I think, you know, that was one of the first things that one of our programmers did.
- 27:10And they didn't know Python yet.
- 27:11So they wrote it in R.
- 27:13That's fine.
- 27:14It's fine.
- 27:15I just thought it was funny.
- 27:15It's there, but just a shade of it.
- 27:18Okay.
- 27:20This portion of Talk Python To Me is brought to you by GlareDB.
- 27:23GlareDB is an open source database for querying distributed data.
- 27:28Here's how it works.
- 27:29First, you connect your data sources.
- 27:31GlareDB makes it easy to connect to your data, no matter where it's stored, with integrations into many popular databases, data warehouses, and more.
- 27:39This includes Snowflake, Postgres, MongoDB, BigQuery, and object storage.
- 27:44Now you can query everything.
- 27:46You use the full power of SQL to query your data across these many different data sources.
- 27:51Join data across production databases and analytical warehouses without limits.
- 27:56Finally, you can use the tools you already know and love.
- 27:59Visualize and query your data using tools you know from Python's data science stack.
- 28:04With just a single import, you can query Pandas and Polars data frames using just SQL.
- 28:09You'll be asking questions, extracting insights, and driving decisions with your data without waiting for an ETL pipeline to move data around.
- 28:18So if you have distributed data and disparate data sources, and you love open source, you owe it to yourself to give GlareDB a try.
- 28:25Visit talkpython.fm/GlareDB to get started.
- 28:29The link is in your podcast player show notes.
- 28:31And please use the link to let them know that you came from us.
- 28:34Thank you to the team at GlareDB for sponsoring the show.
- 28:37So the first thing that you point out here is how is Shiny different from some of the things I said that it was like.
- 28:47For example, Streamlit or Dash.
- 28:49Yeah, absolutely.
- 28:50Maybe touch on that a little.
- 28:51Sure.
- 28:52And I think really the one that comes up the most is Streamlit.
- 28:56Man, Streamlit really has taken the world by storm, it seems like, since they came out in, what was it, 2018?
- 29:02Something like that?
- 29:03Yeah, I think it's 2018.
- 29:04Yeah, it's only been a few years.
- 29:06It clearly really resonated with the Python world.
- 29:09I do have to say, I was very taken aback by the simplicity of their programming model when it first came out.
- 29:15And I pay a little bit of attention to, you know, new things that come out and purport to be high level web frameworks.
- 29:22And most of the time they were sort of like, okay, I recognize the tradeoffs that they're making here.
- 29:28But the Streamlit one was definitely a very bold choice that they made.
- 29:32Streamlit, I think it feels to me that they really prioritized ease of getting started and having the simplest possible mental model in a much higher level of priority than everything else, which is a bold stance.
- 29:47And I really applaud them for being sort of clear about what their vision is.
- 29:50So Streamlit is unbelievably easy to get started with, I think primarily because, I don't know if you've done a lot of Streamlit, but it has this top to bottom execution model.
- 29:58A little, not a ton, but yeah.
- 29:59Yeah.
- 29:59Like if you were to start out with, not a Jupyter notebook, but like a regular Python script that was doing a bunch of data analysis stuff, you know, reading data, maybe doing some transformations and then outputting some, you know, tables and plots.
- 30:14Streamlit lets you take that sort of straight up and down script and sprinkle in some Streamlit inputs and outputs.
- 30:21And boom, like you have now written an interactive Streamlit app.
- 30:25You just say, you know, Streamlit run and then the name of the file and it just works.
- 30:29In that sense, it's quite incredible.
- 30:32It's very easy to get started with.
- 30:34And the cost to spin up a new Streamlit app is so low that I was actually talking to another, to a YouTuber, Fanilo.
- 30:41I don't remember his last name.
- 30:43I think there's one Fanilo in the Streamlit world.
- 30:45And he was saying that he actually uses this instead of Jupyter notebooks to do interactive, you know, exploratory data analysis, which I thought was interesting.
- 30:53The sort of drawback of having this simple of a model is that it really works well for the simplest apps.
- 31:01And then the model is a little bit too simple for even like moderately complex.
- 31:08It's not even complex.
- 31:10But just like you're you sooner or later will often in a surprising way smack into some surprising wall.
- 31:16This is not something that is theoretical.
- 31:19We definitely have talked to a lot of Streamlit users.
- 31:22And even the happy ones will say, we really this is just for prototypes.
- 31:27And then we throw them out because you just cannot you can't think of Streamlit apps as something that can grow with you as your as your needs grow.
- 31:35So I think the sort of time from zero to value for Streamlit is almost zero.
- 31:41That's incredibly quick.
- 31:43But the time from value to the time of, OK, now we're going to throw this thing out and the last 20 percent.
- 31:50Yeah.
- 31:51And it's actually not the last 20 percent.
- 31:53I think it's more like the last 60 percent.
- 31:55And I mean, that might be uncharitable and unbiased.
- 31:58But but honestly, like in my using this framework, which is it's not to take away from their achievements.
- 32:03It's in it clearly has resonated incredibly strongly with a lot of people in the Python world.
- 32:09But I think, you know, no one who uses Streamlit seriously will tell you that you can do most of the things that you want in this sort of top to bottom execution model.
- 32:17You will often in surprisingly quick ways run into limitations there.
- 32:23And I do want to say, like Streamlit, they recognize this.
- 32:26And after some time they added, try to give you ways to work around that top to bottom execution model.
- 32:33They introduced the notion of session state and they introduced multiple attempts at nice caching abstractions.
- 32:39And I think they make somewhat more complex apps possible.
- 32:45But I really I mean, I'm happy to recommend Streamlit for those easy cases.
- 32:51I cannot recommend Streamlit once you start, you know, getting into session state.
- 32:56It really is quite a fragile paradigm to be coding in.
- 32:59And and by the way, just to make it clear here, I don't have a huge financial like motivation to lie about this.
- 33:07Posit Connect, which is the way, you know, we make money in this area.
- 33:11It is designed to host Streamlit as well.
- 33:13And we have custom like a lot of customers that do that.
- 33:16So it doesn't matter to us whether you use Shiny or Streamlit.
- 33:19I mean, it matters to me personally.
- 33:21Like it makes me feel good when people use Shiny.
- 33:24But as a business, we 100% love when our customers use a Streamlit.
- 33:28But it really is.
- 33:30I think we'll talk more about reactive programming later.
- 33:32I hope what it doesn't give you is a nice model for the complicated stuff.
- 33:36It only gives you a nice model for the very, very simplest stuff.
- 33:39Which serves an important role.
- 33:40But, you know, also means that Shiny might serve an important role, too.
- 33:43Another question from the audience, I think maybe worth the diversion is got real world examples of Shiny for Python that you could talk about.
- 33:50And let me take a step back since it's so brand new.
- 33:52Just Shiny, right?
- 33:54You got that.
- 33:54Because I feel like the feature set is pretty similar.
- 33:57It's just like the R people have been at it for a lot longer, you know?
- 34:00Yeah, absolutely.
- 34:01And just to make clear, so Shiny for R has been around since 2012.
- 34:05Shiny for Python has been in alpha since last year.
- 34:09And we just took the alpha tag off in the last, I don't know, six weeks or maybe less than that.
- 34:13Yeah.
- 34:14So I think, and I'm sorry, I didn't come prepared with any more links than what's on the website.
- 34:19Yeah, no worries.
- 34:19We have a Discord where people are starting to gather and talk about some of the things that they're doing with Shiny for Python.
- 34:25So, yeah, I think on the left here, if you select, say, orbit simulation.
- 34:30Yeah, the orbit simulation is cool.
- 34:32This is a demo written by one of our engineers.
- 34:35But this is using, well, first of all, we haven't talked about this, but this is actually using Wasm.
- 34:40So there is no Python running on the background here.
- 34:42Okay.
- 34:43This is using a feature of Shiny called Shiny Live.
- 34:48So this is using Pyodide, which is the same sort of Python in the browser technology that PyScript is currently using.
- 34:55And you still write your Shiny app using Python.
- 34:58You still don't have to write any HTML, CSS, and JavaScript.
- 35:01But when you run it, you can run it, you know, straight out of a web browser, as you can see here.
- 35:06So that's why it took a little bit longer to get started is because it's installing Python into your browser and, you know, installing AstroPy.
- 35:14Well, we say a while, it took like two seconds the first time.
- 35:16Sure.
- 35:17Yeah.
- 35:18Oh, I forget that.
- 35:19Yeah.
- 35:19For your listeners, they won't be able to see it.
- 35:21Yeah, exactly.
- 35:22Yeah.
- 35:22This is an example of like a relatively simple set of inputs and one 3D output that I think in this case is being rendered with Matplotlib.
- 35:32And you can choose some different parameters about the Earth, Moon, and Sun, and Planet X.
- 35:39And it has, you know, arbitrarily complicated calculations happening on the back end by AstroPy to determine like how these bodies would move when they're affected by each other's gravity.
- 35:49There's a lot of Shiny apps that are like this, that there is one particular algorithm, one particular model that it's demonstrating, and then wanting to show what happens when you try different parameters.
- 36:01So I'd say this is sort of in the simplest category of Shiny apps in terms of, you know, what's easy to imagine here.
- 36:08And yeah, there's some other stuff on the left there.
- 36:11Some example apps show the use of different widgets.
- 36:14So there's one for Plotly there.
- 36:16You can use the Plotly JavaScript-based visualization library with Shiny for Python if you want your scatter plots to have, you know, tooltips that show, you know, data, for example.
- 36:28I mean, this particular one seems not to do that much.
- 36:31And, you know, you can use...
- 36:32The Wordle?
- 36:32Yeah, there's a Wordle clone.
- 36:34I don't know.
- 36:35It looks like a...
- 36:36It looks like a mobile phone keyboard.
- 36:39I mean, I have a whole keyboard right here.
- 36:41But it's like, now you can type into the mobile phone keyboard.
- 36:45Yeah.
- 36:45Yeah.
- 36:46Wordy?
- 36:46No, it didn't take it.
- 36:48Come on.
- 36:49No.
- 36:49Yeah.
- 36:49That's pretty funny.
- 36:53Yeah.
- 36:53Yeah.
- 36:53Those are just the beginning ones, right?
- 36:55You even have camera input.
- 36:57I don't know what that's going to do.
- 36:58Oh, this is designed for a phone.
- 37:00Yeah, yeah, yeah.
- 37:01We have another example that's not on here that will use your webcam.
- 37:04But...
- 37:05Yeah, it's okay.
- 37:05But it doesn't...
- 37:06I don't think it works on the WASM mode.
- 37:08Yeah, there's probably security limitations or other differences.
- 37:12Yeah.
- 37:13Yeah.
- 37:13I will say one thing that you won't see as much here that you do see on Shiny for R is
- 37:19like interactive dashboards or even non-interactive real-time streaming dashboards.
- 37:24Not because the sort of underlying technology is not there, but because the actual like UI
- 37:29widgets for making something that looks like a dashboard is in Shiny for R, but not in Shiny
- 37:36for Python.
- 37:36But that is coming within the next, I don't know, hopefully week or two weeks.
- 37:40So we have a new release coming that adds a lot more UI stuff.
- 37:43And that is a very, very common use of Shiny is for people that are creating dashboards that
- 37:48show key performance indicators and time series plots and geographic data plotted on the
- 37:54on an interactive leaflet map.
- 37:56That's bread and butter for a lot of data scientists out there who are using Shiny.
- 38:00Okay.
- 38:00That sounds very exciting.
- 38:02And the kind of stuff that no one wants to do on the web.
- 38:05Very few people want to do directly on the web.
- 38:09You want to be able to just grab a library.
- 38:10Yeah.
- 38:10All right.
- 38:11So I sent us a little bit on this diversion here over those, but maybe the next thing would
- 38:16be reactive programming.
- 38:17Tell us about that.
- 38:19Yeah.
- 38:19So Shiny was really born out of this idea of reactive programming.
- 38:24That was the motivating concept.
- 38:26And for people who haven't heard that term before, maybe heard it, but never really were
- 38:30clear on what it means.
- 38:31Reactive programming is a programming paradigm that can be applied to many different programming
- 38:37languages where it's about making it easy to program against values that are changing over
- 38:43time.
- 38:44In a normal programming paradigm, if you have a value X, say X equals one, and then you have
- 38:52Y equals X plus one, and then you change the value of X, the value of Y does not change,
- 38:58right?
- 38:58It's not reactive in that way.
- 38:59Whereas if you were in Excel and you had one cell using another cell plus one, then you
- 39:07would expect that to change.
- 39:08So Excel is sort of the most common example of a reactive model that I'm familiar with.
- 39:14And so you wire up the data to say, this number depends on these other numbers, and this one
- 39:19depends on that formula.
- 39:20And it's the underlying reactive system just says, we're going to do the minimum amount of
- 39:25recompute to keep them up to date.
- 39:27That's exactly right.
- 39:28That's exactly right.
- 39:29So in this case, the values that are changing might be a slider that is in your user interface,
- 39:35right?
- 39:36And when the user drags that slider from zero to five, there might be all sorts of downstream
- 39:42calculations that need to recompute now because you've changed that value.
- 39:46And in a world prior to reactive programming, the dominant model was, and maybe in a lot of places
- 39:54still is callback based programming or event handling is the other name for it.
- 39:59And that's, if you've ever used a framework that had like something called an on click or
- 40:04something like that, you're doing event handling, right?
- 40:06This button is pressed.
- 40:07I am going to execute this exact, you know, code in response to a button click.
- 40:12And in that world, which is a world that I inhabited for many years, doing full-time, very complicated
- 40:18UI programming using that model.
- 40:20Sounds like some desktop programming, maybe some C-sharp or Windows Form, something like
- 40:24that.
- 40:25That's right.
- 40:25That's right.
- 40:26Exactly.
- 40:26I worked at Microsoft working on Windows Forms apps that we shipped.
- 40:30And RStudio was created in that paradigm as well.
- 40:34It's actually quite difficult to do that kind of programming well.
- 40:38It's very easy to understand how to code in an event-driven sort of way or using callbacks.
- 40:44But to get your callback logic right as the number of events, the number of outputs, and
- 40:51the number of intermediate sort of calculations as they increase, it's really hard to, number
- 40:58one, keep it performant, and number two, keep it correct.
- 41:01And the idea for doing a web framework for data scientists actually predates me finding
- 41:06out about reactive programming.
- 41:07And I actually said no.
- 41:09Like, I actually, JJ and I talked about it, and I was like, we could do it and we should
- 41:13not unless we come up with some way that is better than event handling.
- 41:17Because what I didn't want to do was make it easy to come up with answers that were incorrect,
- 41:23which is what I think callback-based programming makes it very easy for you to forget to update
- 41:28some aspect of your calculation.
- 41:29And now you have an answer, it's just not the right answer.
- 41:32Right.
- 41:32Maybe you update two graphs, but there's some number that has like a total in it.
- 41:36And you forget in your event handler, you've got to update all three.
- 41:39And so then...
- 41:40And not just update all three.
- 41:42Yeah.
- 41:42Yeah.
- 41:43You'd have to update all three in the correct order, potentially, right?
- 41:46Because one of those subcalculations might depend on the other.
- 41:48So the whole thing, it is certainly possible to create very complex or even simple, too complex
- 41:55interactive stuff using callbacks.
- 41:58But I never felt like this was a great way to work.
- 42:01And when I was building these desktop apps, I often felt at the end of the day, like I had
- 42:07been operating at the very edges of my mental capacity.
- 42:10And it's even worse when you go to modify existing code or, God forbid, have to help debug somebody
- 42:17else's UI code.
- 42:19I mean, it really is very, very difficult.
- 42:21And I heard about reactive programming via this JavaScript framework called Meteor.
- 42:27And I don't know if you've heard of Meteor.
- 42:29Heard of it, but I haven't ever used it.
- 42:31Yeah.
- 42:32Not a lot of people have.
- 42:33I think it was very influential in terms of its ideas, but it didn't catch on anything
- 42:37like React.
- 42:38But Meteor, I heard about it in 2012.
- 42:42And I can't really convey how awe-inspiring it was to see.
- 42:47I think I saw like a five-minute demo that was on the front page of Hacker News.
- 42:51And, you know, I was just flabbergasted at what they were doing in this demo.
- 42:57And there were like no event handlers anywhere.
- 42:59And yet everything was just completely snappily updating.
- 43:02I was like so taken aback by this that it's stuck in my brain for weeks.
- 43:06Like I was like, how do they do that?
- 43:08Like that doesn't make any sense to me.
- 43:09And I finally like did some Googling around and there was a Stack Overflow answer that indicated
- 43:16like this is sort of more or less how it works.
- 43:19You know, with that clue, I downloaded their source code and sort of found my way to how exactly
- 43:25it was implemented.
- 43:26And I actually was getting on a plane and I downloaded the repo before I got on the plane.
- 43:30I was like, by the time this plane lands, I'm going to figure this out.
- 43:33And it actually is a beautifully elegant mechanism that, you know, I'll probably talk about someday.
- 43:39I mean, we could talk about it now, but I think it would probably be the rest of this rest of our
- 43:43time.
- 43:44But it's a beautifully elegant and ultimately quite simple mechanism that underlies all this magic.
- 43:50When I saw that and eventually took me a couple of weeks to connect the dots, but when I realized,
- 43:55wait a minute, this could be how data scientists could create highly interactive things without
- 44:00fear, without worrying that they're going to forget to update some intermediate thing and
- 44:05get the wrong answer.
- 44:06Or worse, they wouldn't worry about it.
- 44:07They just get the wrong answer and then be angry after the fact, right?
- 44:10We're going to retract that paper.
- 44:12I'm sorry.
- 44:13Yeah.
- 44:13Yeah.
- 44:14On the R side, it really has, these ideas have proven themselves out year after year after
- 44:20year.
- 44:21I think people are building incredibly cool things in reactive programming with no background
- 44:25in software engineering, much less hardcore front-end web development.
- 44:31So I really do believe, you know, there are a lot of different ways people are solving this
- 44:36problem in Python.
- 44:37You know, Streamlit and Dash each have their own takes and Pinecone and Solara, all these
- 44:41different ones.
- 44:43And the ones that sort of have thought carefully about this problem of how do you help people
- 44:49programming against what is inherently a dynamic system while staying safe, while making sure
- 44:55that you're getting the right answers every time and doing it in an efficient way.
- 44:58Those are the ones that I think are closest to the spirit of Shiny.
- 45:02And that's really why I think Shiny for Python needed to exist.
- 45:06Because I mean, I looked at Dash and Streamlit and I just felt like, you know, I'm glad that
- 45:11people are really getting a lot of value out of these, especially out of Streamlit.
- 45:15But I really feel like this needs to exist as well.
- 45:19We really need like an industrial strength reactive framework for things that are not just
- 45:24top to bottom execution.
- 45:25One thing that's standing out to me on the page here is you talk about there are a few utility
- 45:29functions to help manage or utility things to help manage reactivity.
- 45:34And one is context blocks, you know, with isolate and other ones are decorators for functions.
- 45:41And, you know, just those two things are pretty, pretty solid Pythonic constructs of the language.
- 45:48Right.
- 45:49And so it looks like you put some thought into not just writing our code in Python, but trying
- 45:54to embrace some of the Pythonic language capabilities.
- 45:57Yeah, that's absolutely right.
- 45:59It was really important to us when we were talking about the design philosophy for Shiny
- 46:04for Python to really make it a Python first experience.
- 46:09That's not necessarily like, I think the other choice is defensible too, which is let's make
- 46:14these two frameworks look as similar as possible so that you can seamlessly move from one to the
- 46:18other.
- 46:19And I was just not convinced that anyone would really enjoy writing our style code in Python.
- 46:25Like I wouldn't.
- 46:27I mean, that just feels something feels hacky about that.
- 46:30Yeah.
- 46:30So yeah, we definitely spent some time and I'm not new to Python.
- 46:33I think I learned Python originally in 2003, something like that.
- 46:36And I've spent some time with the language.
- 46:38So yeah, it felt to me like so much of Shiny is this reactive programming is about creating
- 46:44independent units of either this is code that generates a plot or this is code that calculates
- 46:51a data frame.
- 46:53And taking those little bits of code and deciding when is the right time for each of them to run
- 46:58because there are like dependencies between these different blocks.
- 47:00And the notion of these being functions that have decorators on them felt to me like a pretty spot
- 47:07on analogy, right?
- 47:08Like you're creating a chunk of code, which in Python is a function, and then you are annotating
- 47:14it with an indicator of your intent.
- 47:17So in Shiny, you would write, you know, for a plot output, you would say def plot one or
- 47:21whatever you named that plot.
- 47:23You would have your matplotlib code inside.
- 47:25And then as a decorator to that function, you would say, this is an output.
- 47:30And the type of the output is a plot.
- 47:32Now, I will say that being said, I have been a little bit surprised how many data scientists
- 47:37in Python I've talked to have not worked with decorators.
- 47:40I mean, most of them are familiar enough, but like a non-zero amount of people have told me,
- 47:45like, I haven't done decorators before, and this is a little bit scary.
- 47:48So that was not something that I was anticipating going into this.
- 47:51So yeah, so I got a couple of thoughts.
- 47:53One is, if you went with your alternate reality, where you said, let's make them as identical
- 47:58as possible, there's certainly a case to be made for that, I agree.
- 48:01But that would sort of say the primary audience is the people that flows between R and Python.
- 48:08Which is certainly non-zero, but it's not like, let's try to resonate most deeply with
- 48:13just the Python community full stop rather than the transit folks, you know?
- 48:19Yeah, that's right.
- 48:20So I would say, I mean, looking in from the outside, that this looks like a good choice.
- 48:24Second, the with concepts and the decorators and data scientists is, I think one of the powers
- 48:31of Python, the reason a lot of data scientists use it is you can be really effective with a
- 48:36partial understanding, a highly partial understanding of what Python is and how it works, right?
- 48:42Like you might not know how to create a class.
- 48:43You might not even know how to create a function, but you can still pip install a few cool libraries
- 48:48or condo install them and then run top to bottom five lines that generate an amazing output,
- 48:52right?
- 48:52And so I think there's a, not talking about all data science, but I think there's a slice
- 48:58of kind of pretty new to Python data science who are like, came from somewhere else.
- 49:03Like I heard this is awesome and I'm starting to get some traction with it, but even they
- 49:06haven't gone into, you know, crazy concepts of decorators that take functions and star arg
- 49:12wraps them and returns other functions.
- 49:13You know, like that said, from a syntactical perspective, I think it's pretty, he's like,
- 49:18oh, this function, it has to be reactive.
- 49:20So I put at reactive event on it.
- 49:22Yeah, that's right.
- 49:24Yeah.
- 49:24Yeah.
- 49:24you're asked if there's, any examples, with user authentication.
- 49:29I know there's, you guys have a, your gallery, which is what I skipped before, but the gallery,
- 49:34I think is maybe easier to quickly browse, but there's more in the examples.
- 49:37Yeah.
- 49:38And honestly, we are a little behind on the examples.
- 49:41we spent a lot of the last, six months working on features and not on examples.
- 49:46You've been busy building the thing, not talking about what you could.
- 49:50Yeah.
- 49:50Yeah.
- 49:51Yeah.
- 49:51so I think we need our examples to catch up a little bit.
- 49:53I will say that user authentication is something that we have as part of both hosted platform
- 50:01and for Posit Connect.
- 50:03So I think a lot of companies that are trying to sort of have a similar business model as
- 50:09us and have a open source framework and also some kind of enterprise hosting often draw the
- 50:17line that way, that, that authentication is one of the things that isn't in the framework.
- 50:21It wraps the framework.
- 50:22That being said in shiny for R people definitely went ahead and wrote their own packages that
- 50:28put authentication into the framework and made it open source.
- 50:30And I'm sure those things are going to happen in a shiny for Python very quickly as well.
- 50:35Yeah.
- 50:35How similar is the execution model?
- 50:37Like the internals, what's happening conceptually on the server stuff or even on the website across
- 50:44those?
- 50:44Yeah.
- 50:44There's a couple of ways to answer that.
- 50:46I would say right now it is surprisingly close, which is not really what we were anticipating.
- 50:52Shiny for Python is written in asyncio and that async framework is quite different than how async works
- 51:00in R. And I think we, after, you know, spending a lot of time on this implementation, the mental model for the shiny app author is actually quite similar.
- 51:10So where we ended up, I think it does for all intents and purposes as an app author, it's a very similar execution model.
- 51:16So each user, if you were to launch a shiny for Python app right now from your, not from Wasm, but like using a regular shiny for Python, running it out of Python, and you connected three web browsers, they would all be running in the same process.
- 51:29Each one gets their own copy of their, their own session, basically.
- 51:35So there's no confusing whose inputs are applying to whose outputs.
- 51:38Everybody has their own copies of inputs and outputs and they're wired together, but it's all running on the same process and it's all running.
- 51:45Currently, they all run on the same thread.
- 51:47We do that on purpose because you can also have shared reactives.
- 51:51So, you know, you could have global variables that essentially when one browser updates them, everybody gets an update and you could have some kind of shared scoreboard or a chat room or whatever.
- 52:02That being said, if you want, you can also do async.
- 52:06So your outputs and calculations can also be async functions.
- 52:10And therefore your session, if it's doing some kind of long running async calculation, can give up its control of the thread to some other session that can execute.
- 52:19Right, or it's doing some database thing where it's pulling a bunch of data, can say, we're waiting on the database.
- 52:25You guys keep going.
- 52:26Yeah, that's right.
- 52:27Okay.
- 52:27So we're getting short on time here.
- 52:29Let me ask you two more questions.
- 52:32The first one is, I think from a community perspective, like what opens up now, right?
- 52:38So we have R and we have Python and there are similarities between these, but there's really smart people doing creative and powerful stuff on both sides.
- 52:45Because of the chronology, I guess, mostly I imagine that there's more Shiny work that's happened on the R side than on the Python side.
- 52:53But how much does this make it possible for people who maybe wrote a book with Shiny for R and they might want a Python version, right?
- 53:03It seems to me that having this as an option, if the whole UI is now kind of almost equivalent, if not syntactically identical, like, oh, all of a sudden we could have these two versions or we could move from one side of that fence to the other and still stick with Shiny in the same reactive programming model.
- 53:21Yeah.
- 53:21I want to make sure I get your question right.
- 53:23Are you talking about people who are sort of in the Shiny ecosystem who have like extension packages and things like that?
- 53:30Or are you talking about people who write Shiny apps?
- 53:32People who write Shiny apps.
- 53:33People who are like users creating these Shiny apps.
- 53:36Maybe they created them in Shiny for R and they're like, I've always wanted to do a Python one, but I really like Shiny, so I'm not going anywhere.
- 53:42You know, but now there's Shiny for Python, you're like, oh, maybe this is a way to have that as an option, right?
- 53:47Or I'm a teacher teaching a class at a college and I did it with Shiny in R and they're telling me I have to move to Python.
- 53:53I thought I'd use Streamlit, but maybe now I can move over.
- 53:56Like, how much do you see that scenario coming into play now?
- 54:00We absolutely are.
- 54:01Yeah.
- 54:01And I think I underestimated this a little bit.
- 54:04I think what I was anticipating is that people who are very comfortable with Shiny for R and comfortable with R in general might see Shiny for Python as sort of a threat as, you know, the Shiny team has given up on R and all they care about is Python now and they're selling out to the Python, you know, crowd or whatever.
- 54:20And that really has not been the case at all.
- 54:24And then, Joe, you come on this podcast and oh my goodness.
- 54:26Yeah, that's right.
- 54:29Just kidding.
- 54:30In fact, it's almost been a sense of relief.
- 54:33And that applies as well to, you know, our company name was RStudio.
- 54:37We rebranded Deposit.
- 54:38And similarly, we announced both things at the same conference that we were going from RStudio Deposit in terms of our company name.
- 54:46And Shiny for Python is now going to be a thing in addition to Shiny for R.
- 54:49And I almost feel like the predominant emotion that we got from our community was relief.
- 54:57Because I think unless you're in very specific fields, there's nobody that doesn't have some Python around them, right?
- 55:04That maybe your team does R, but then you have this sibling team that, you know, maybe is more ML model heavy, and they definitely use Python.
- 55:13Or your IT department really is a lot more comfortable deploying Python.
- 55:16And I think as much as people love R, knowing that they have the option, knowing that they can take these ideas that they really like from R and be able to reuse them in Python.
- 55:30I mean, yes, there will be some syntax to learn, but that's never the hard part, right?
- 55:34I mean, the hard part is everything that you express using syntax.
- 55:37The libraries and the UIs and all that, yeah.
- 55:39Yeah.
- 55:39So that's really what we've heard is that people, even if they're like totally happy with Shiny for R, they're happy that Shiny for Python exists because they know that if the time comes where they have to add that to their toolkit, that it's an option.
- 55:53And they don't have to now try to map everything that they know and take for granted from Shiny to have to map that to Dash or to Streamlit or Panel or something like that.
- 56:02Yeah. You know, another example is you work at a university where R is actually really has a good stronghold, right?
- 56:09It has a, especially in the math and statistics department.
- 56:11But maybe you were working with some astronomers and that their whole research group does Python and you want to work with them.
- 56:18But, you know, like you also want to bring Shiny, right?
- 56:21So that's what, like that, all that conversation right there kind of encapsulates why I thought this would be a really cool topic to have you on the show is, you know,
- 56:30it kind of opens up this bridge for a lot of people in a lot of directions.
- 56:34Yeah. And speaking of bridges, a member of my team pointed out that, you know, he's someone who in his previous job went from an R organization to like a more Python heavy organization.
- 56:45And as someone who's coming from an R world, it can be a little bit intimidating, you know, to sort of start at the, of the ladder again, especially if you're in some kind of, you know, a team situation where you expect to be productive and to contribute to the team.
- 57:00And Shiny for Python, especially being new, the people are coming from the R world and sort of find themselves, whether by choice or involuntarily, you know, needing to do Python, that Shiny for Python might be an interesting, like you said, bridge for them to go from one ecosystem to the other,
- 57:18while maintaining a certain level of familiarity and to be able to deliver a lot of value.
- 57:23Because I mean, one of the reasons I think Shiny resonated on the R side is because the things that you build with Shiny, if they have value, they are extremely visible.
- 57:32They're extremely visible to your coworkers inside your organization.
- 57:36And it really, you're talking about how, you know, people coming up and saying how they've built impactful things with, with Shiny.
- 57:42Another common theme I heard was how much Shiny helped their careers going from doing work in a REPL or a notebook and instead being able to deliver very dramatic interactive applications.
- 57:56It's a really powerful way to, to, to have an impact in your organization.
- 58:00It is.
- 58:01And I think data scientists, and especially this kind of like visual, let me turn the knobs and see what happens type of experience, is the type of person that has the ear of pretty high up folks.
- 58:12And if you've got powerful tools like this to make a good impression, you're like, they asked me, I asked them if they could give us predictions of this, or if they could rethink this.
- 58:20And they came back with a new web app the next day.
- 58:23Are you kidding me?
- 58:23It took us six months to redesign our stupid website for the homepage.
- 58:27You know what I mean?
- 58:27Something like this, right?
- 58:28And so it lets you look good, right?
- 58:30To the right people.
- 58:31That's right.
- 58:32100%.
- 58:32Yeah.
- 58:33Cool.
- 58:33Joe, I'd say you're making a big impact here.
- 58:36We got Alan out there saying, I just started using Shiny during this live stream.
- 58:39Yes.
- 58:40How hard is it to deploy this into an AWS EC2 instance, for example?
- 58:44Yeah, you totally can.
- 58:45The easiest thing to do is to look up Shiny server.
- 58:48Most of the documentation talks about, you might find it on the R side of the website, but it's actually all the same.
- 58:54So if you're using Ubuntu, it's a simple install of a Debian package.
- 59:01If you're using Fedora, it's an RPM.
- 59:04And it should be pretty easy to get started with.
- 59:08But also don't forget that you can also just sling it into our free hosting, especially if you're just getting started.
- 59:14Yeah.
- 59:14Excellent.
- 59:15Excellent.
- 59:15Roadmap.
- 59:16Let's close it out with Roadmap.
- 59:17Yeah.
- 59:18So in the upcoming release, we have been focused a lot on UI components.
- 59:24And that's something that we're going to continue to focus on for a while.
- 59:28We definitely want to make the more dashboard-y type applications very easy to write.
- 59:35And we also are wanting to beef up on the output side of some of our widgets.
- 59:41So we don't have a great table widget right now.
- 59:43It just kind of takes a Pandas table and renders it to HTML using Pandas styler.
- 59:49But we want to have fast, scalable virtual grid, basically.
- 59:53And also for more interactive type outputs like that, I should mention that we support IPy widgets natively.
- 1:00:01So most IPy widgets will just drop right in, including Plotly and PyDeck.
- 1:00:06And well, most of them work just fine.
- 1:00:10And we'll be doing more to sort of make some of those feel a little bit more native.
- 1:00:14And the IPy widget stuff works great.
- 1:00:17But I think we also want to make it feel a little bit more functional in some cases than object-oriented.
- 1:00:23Yeah.
- 1:00:23And we have a lot of examples to write, a lot of documentation to write.
- 1:00:27And there are also quite a few features to port over from Shiny4R.
- 1:00:31And the last thing I'll say is that automated testing is something that we are working on as well, making it easier for you to write automated tests for your Shiny4Python apps.
- 1:00:40It's an approach that's based on PlayWrite that we use internally right now.
- 1:00:44But we're going to have helper classes and functions to make it a little less boilerplate-y to write these kinds of tests for Shiny4Python apps.
- 1:00:53Nice.
- 1:00:54PlayWrite's really cool.
- 1:00:55Yeah.
- 1:00:55Yeah.
- 1:00:55Very, very, yeah.
- 1:00:58Very, very cool.
- 1:00:58Like Selenium, but more Pythonic.
- 1:01:00So pretty neat.
- 1:01:01Yeah.
- 1:01:01Yeah.
- 1:01:02Well, it's a cool roadmap.
- 1:01:03People want, they've got ideas.
- 1:01:05They want to reach out to you.
- 1:01:07Is GitHub an option?
- 1:01:09Like, do they open an issue?
- 1:01:10Do they email you?
- 1:01:11How do they reach you guys?
- 1:01:12Yeah.
- 1:01:12So we have a GitHub issue is always appreciated and we will absolutely read those and engage.
- 1:01:19We also have a Discord for things that are a little more, you know, if you want a little bit more of a back and forth and, or do you just want to meet us?
- 1:01:28Do you just want to talk about, you know, any of the design decisions we've made or how we might be different than, you know, XYZ framework?
- 1:01:34We're happy to talk to anyone and everyone.
- 1:01:36And I think to get to the Discord is on our GitHub homepage, I believe.
- 1:01:41Excellent.
- 1:01:41Excellent.
- 1:01:41Let's see if I can find a Discord.
- 1:01:44There you have it.
- 1:01:44Join us on Discord right on the homepage and the read me of the GitHub.
- 1:01:48Yeah.
- 1:01:48All right, Joe.
- 1:01:49Thanks for being here.
- 1:01:49Thanks for creating this.
- 1:01:50Thank you.
- 1:01:50This is cool.
- 1:01:51I think it's a nice contribution and really, like I said, it's a cool bridge between the R and Python communities.
- 1:01:57Thank you.
- 1:01:58If you don't mind me saying so, I really enjoy your podcast.
- 1:02:01And I think that you are, you're quite good at this.
- 1:02:05And I just really appreciate all the conversations that you've had.
- 1:02:09You seem like just a really generous interviewer and you do a really great job of sort of helping people really feel three-dimensional, even when we're talking about like very technical stuff.
- 1:02:19So I appreciate that.
- 1:02:20I really appreciate that.
- 1:02:21That's super kind.
- 1:02:22Thank you for saying that.
- 1:02:23And thank you for being on the show.
- 1:02:24Yeah, my pleasure.
- 1:02:25We'll do all the links in the show notes for all these things.
- 1:02:28People can check them out there.
- 1:02:29And yeah, see you next time.
- 1:02:30All right.
- 1:02:31Thanks so much.
- 1:02:31This has been another episode of Talk Python To Me.
- 1:02:35Thank you to our sponsors.
- 1:02:37Be sure to check out what they're offering.
- 1:02:39It really helps support the show.
- 1:02:40Influx Data encourages you to try InfluxDB.
- 1:02:44InfluxDB is a database purpose built for handling time series data at a massive scale for real-time analytics.
- 1:02:51Try it for free at talkpython.fm/InfluxDB.
- 1:02:54GlareDB is an open source database for querying distributed and disparate data.
- 1:03:01Connect your data sources and use the Python tools you already know to ask questions and integrate data across data sources.
- 1:03:08Get started today at talkpython.fm/GlareDB.
- 1:03:11Want to level up your Python?
- 1:03:13We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:03:17Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:03:22And best of all, there's not a subscription in sight.
- 1:03:25Check it out for yourself at training.talkpython.fm.
- 1:03:28Be sure to subscribe to the show.
- 1:03:30Open your favorite podcast app and search for Python.
- 1:03:32We should be right at the top.
- 1:03:34You can also find the iTunes feed at /itunes,
- 1:03:37the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 1:03:43We're live streaming most of our recordings these days.
- 1:03:47If you want to be part of the show and have your comments featured on the air,
- 1:03:50be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:03:54This is your host, Michael Kennedy.
- 1:03:56Thanks so much for listening.
- 1:03:58I really appreciate it.
- 1:03:59Now get out there and write some Python code.
- 1:04:01Thank you.
- 1:04:01Bye.
- 1:04:02Bye.
- 1:04:02Bye.
- 1:04:02Bye.
- 1:04:02Bye.
- 1:04:03Bye.
- 1:04:04Bye.
- 1:04:05Bye.
- 1:04:06Bye.
- 1:04:07Bye.
- 1:04:08Bye.
- 1:04:09Bye.
- 1:04:10Bye.
- 1:04:11Bye.
- 1:04:12Bye.
- 1:04:13Bye.
- 1:04:14Bye.
- 1:04:15Bye.
- 1:04:16Bye.
- 1:04:17Bye.
- 1:04:18you
- 1:04:18you
- 1:04:19you
- 1:04:19Thank you.