|
8 | 8 |
|
9 | 9 | 00:00:18 Not any longer. |
10 | 10 |
|
11 | | -00:00:20 Joe Chen is here to introduce us to the recently released Shiny for Python, and it looks like a really solid new framework on the block. |
| 11 | +00:00:20 Joe Cheng is here to introduce us to the recently released Shiny for Python, and it looks like a really solid new framework on the block. |
12 | 12 |
|
13 | | -00:00:28 This is Talk Python and Me, episode 424, recorded June 19th, 2023. |
| 13 | +00:00:28 This is Talk Python to Me, episode 424, recorded June 19th, 2023. |
14 | 14 |
|
15 | 15 | 00:00:34 [music] |
16 | 16 |
|
17 | | -00:00:46 Welcome to Talk Python and Me, a weekly podcast on Python. |
| 17 | +00:00:46 Welcome to Talk Python to Me, a weekly podcast on Python. |
18 | 18 |
|
19 | 19 | 00:00:50 This is your host, Michael Kennedy. |
20 | 20 |
|
21 | 21 | 00:00:52 Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython, both on fosstodon.org. Be careful with impersonating accounts on other instances, there are many. Keep up with the show and listen to over seven years of past episodes at talkpython.fm. We've started streaming most of our episodes live on YouTube. |
22 | 22 |
|
23 | | -00:01:12 Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode. I'm really excited to have a new sponsor for For this episode, welcome on board to GlareDB. |
| 23 | +00:01:12 Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode. I'm really excited to have a new sponsor for this episode, welcome on board to GlareDB. |
24 | 24 |
|
25 | 25 | 00:01:27 GlareDB is an open source database for querying distributed and disparate data. |
26 | 26 |
|
|
62 | 62 |
|
63 | 63 | 00:02:45 Of course, I'm sure. |
64 | 64 |
|
65 | | -00:02:46 Shining for Python's gonna be super fun. |
| 65 | +00:02:46 Shiny for Python's gonna be super fun. |
66 | 66 |
|
67 | 67 | 00:02:49 Before we get to that though, let's get started with your story. |
68 | 68 |
|
|
224 | 224 |
|
225 | 225 | 00:10:43 I know the conversations come up around it. |
226 | 226 |
|
227 | | -00:10:46 Other ones that live in a similar orbit, maybe are Streamlet. |
| 227 | +00:10:46 Other ones that live in a similar orbit, maybe are Streamlit. |
228 | 228 |
|
229 | | -00:10:51 I've had Adrian on, the founder of Streamlet on before, and we've got Dash, and Panel, and Pinecone, and others. |
| 229 | +00:10:51 I've had Adrian on, the founder of Streamlit on before, and we've got Dash, and Panel, and Pynecone, and others. |
230 | 230 |
|
231 | 231 | 00:10:58 That sets the stage for what this could be about. |
232 | 232 |
|
|
344 | 344 |
|
345 | 345 | 00:17:08 - Right, absolutely. |
346 | 346 |
|
347 | | -00:17:09 You don't wanna give them the full notebook because the last thing you want is the general public typing Pantos code in there or arbitrary Python code, but you want to give them some interactivity. |
| 347 | +00:17:09 You don't wanna give them the full notebook because the last thing you want is the general public typing Python's code in there or arbitrary Python code, but you want to give them some interactivity. |
348 | 348 |
|
349 | 349 | 00:17:20 Maybe we could look at this little example down here, just to talk through what an app might look like. |
350 | 350 |
|
351 | | -00:17:27 Right on the homepage, shiny.poset.co, you have, I think this is a big statement towards your commitment to Python. |
| 351 | +00:17:27 Right on the homepage, shiny.posit.co, you have, I think this is a big statement towards your commitment to Python. |
352 | 352 |
|
353 | 353 | 00:17:36 It's like right on the homepage, on equal, on par with R, it says, get started with R, get started with Python. |
354 | 354 |
|
|
410 | 410 |
|
411 | 411 | 00:19:49 It says, "Could Shiny be used to do fancy math, say for someone trying to upload their GitHub website for their PhD thesis model?" Like, what can we create? |
412 | 412 |
|
413 | | -00:19:57 Like, could you create a kind of a LaTeX looking integrated thing with interactive math bits in there? |
| 413 | +00:19:57 Like, could you create a kind of a Lots of looking integrated thing with interactive math bits in there? |
414 | 414 |
|
415 | 415 | 00:20:03 Right, right. Yeah, yeah. |
416 | 416 |
|
|
424 | 424 |
|
425 | 425 | 00:20:17 It's just whatever you can express in Python or R for that matter. |
426 | 426 |
|
427 | | -00:20:20 And in terms of putting like LaTeX equations on the screen, Yes, this is a completely built in feature for Shiny for R and for Shiny for Python. |
| 427 | +00:20:20 And in terms of putting like lots equations on the screen, Yes, this is a completely built in feature for Shiny for R and for Shiny for Python. |
428 | 428 |
|
429 | 429 | 00:20:31 It's a little less slick, but we do have an example application that shows how to drop in. |
430 | 430 |
|
|
626 | 626 |
|
627 | 627 | 00:28:29 The link is in your podcast player show notes, and please use the link to let them know that you came from us. |
628 | 628 |
|
629 | | -00:28:35 Thank you to the team at Clarity Bee for sponsoring the show. |
| 629 | +00:28:35 Thank you to the team at GlareDB for sponsoring the show. |
630 | 630 |
|
631 | 631 | 00:28:38 So the first thing that you point out here is, how is Shiny different from some of the things I said that it was like, for example, Streamlit or Dash? |
632 | 632 |
|
|
636 | 636 |
|
637 | 637 | 00:28:52 - Sure, and I think really the one that comes up the most is Streamlit. |
638 | 638 |
|
639 | | -00:28:56 man, Streamlet really has taken the world by storm, it seems like, since they came out in, what was it, 2018, something like that? |
| 639 | +00:28:56 man, Streamlit really has taken the world by storm, it seems like, since they came out in, what was it, 2018, something like that? |
640 | 640 |
|
641 | 641 | 00:29:03 - Yeah, I think it was 2018, yeah. |
642 | 642 |
|
|
648 | 648 |
|
649 | 649 | 00:29:15 And I pay a little bit of attention to new things that come out and purport to be high-level web frameworks. |
650 | 650 |
|
651 | | -00:29:23 And most of the time, they were sort of like, okay, I recognize the trade offs that they're making here, but the Streamlet one was definitely a very bold choice that they made. |
| 651 | +00:29:23 And most of the time, they were sort of like, okay, I recognize the trade offs that they're making here, but the Streamlit one was definitely a very bold choice that they made. |
652 | 652 |
|
653 | | -00:29:32 Streamlet, 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 and I really applaud them for being sort of clear about what their vision is. |
| 653 | +00:29:32 Streamlit, 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 and I really applaud them for being sort of clear about what their vision is. |
654 | 654 |
|
655 | | -00:29:50 So Streamlet 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. |
| 655 | +00:29:50 So 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. |
656 | 656 |
|
657 | 657 | 00:29:58 A little, not a ton, but yeah. |
658 | 658 |
|
659 | 659 | 00:29:59 Yeah. |
660 | 660 |
|
661 | 661 | 00:30:00 Like 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. |
662 | 662 |
|
663 | | -00:30:14 Streamlit lets you take that sort of straight up and down script and sprinkle in some streamlit inputs and outputs and boom, like you have now written an interactive streamlet app, you just say, you know, streamlet run and then the name of the file and it just works in that sense. It's quite incredible. It's very easy to get started with and the cost to spin up a new streamlet app is so low that I was actually talking to another to a YouTuber, Fanilo. I don't remember his last name. I think there's one Fanilo in the streamlet world and 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. The sort of drawback of having this simple of a model is that it really works well for the simplest apps. And then the model is a little bit too simple for even like moderately complex. It's not even complex, but just like you're you sooner or later, will often in a surprising way, smack into some surprising wall. |
| 663 | +00:30:14 Streamlit lets you take that sort of straight up and down script and sprinkle in some streamlit inputs and outputs and boom, like you have now written an interactive streamlit app, you just say, you know, streamlit run and then the name of the file and it just works in that sense. It's quite incredible. It's very easy to get started with and the cost to spin up a new streamlit app is so low that I was actually talking to another to a YouTuber, Fanilo. I don't remember his last name. I think there's one Fanilo in the streamlit world and 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. The sort of drawback of having this simple of a model is that it really works well for the simplest apps. And then the model is a little bit too simple for even like moderately complex. It's not even complex, but just like you're you sooner or later, will often in a surprising way, smack into some surprising wall. |
664 | 664 |
|
665 | 665 | 00:31:16 This is not something that is theoretical. |
666 | 666 |
|
|
672 | 672 |
|
673 | 673 | 00:32:09 But I think 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. You will often, in surprisingly quick ways, run into limitations there. And I do want to say, Streamlit, they recognized this. |
674 | 674 |
|
675 | | -00:32:26 And after some time, they added, "Try to give you ways to work around that top-to-bottom execution model. They introduced the notion of session state and they introduced multiple attempts at nice caching abstractions. And I think they make somewhat more complex apps possible. But I really, I mean, I'm happy to recommend Streamlet for those easy cases. I cannot recommend Streamlet once you start, you know, getting into session state. It really is quite a fragile paradigm to be coding in. |
| 675 | +00:32:26 And after some time, they added, "Try to give you ways to work around that top-to-bottom execution model. They introduced the notion of session state and they introduced multiple attempts at nice caching abstractions. And I think they make somewhat more complex apps possible. But I really, I mean, I'm happy to recommend Streamlet for those easy cases. I cannot recommend Streamlit once you start, you know, getting into session state. It really is quite a fragile paradigm to be coding in. |
676 | 676 |
|
677 | 677 | 00:33:00 And by the way, just to make it clear here, I don't have a huge financial like motivation to lie about this. |
678 | 678 |
|
|
744 | 744 |
|
745 | 745 | 00:35:18 Oh, I forget that, yeah, for your listeners, they won't be able to see it. |
746 | 746 |
|
747 | | -00:35:22 This is an example of a relatively simple set of inputs and one 3D output that I think in this case is being rendered with matplotlib. And you can choose some different parameters about the Earth, Moon, and Sun, and Planet X. And it has arbitrarily complicated calculations happening on the back end by AstroPi to determine how these bodies would move when they're affected by each other's gravity. There'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. So I'd say this is sort of in the simplest category of Shiny apps in terms of what's easy to imagine here. And yeah, there's some other stuff on the left there. Some of the example apps show the use of different widgets. So there's one for Plotly there. You can use the plotly JavaScript based visualization library with Shiny for Python. |
| 747 | +00:35:22 This is an example of a relatively simple set of inputs and one 3D output that I think in this case is being rendered with matplotlib. And you can choose some different parameters about the Earth, Moon, and Sun, and Planet X. And it has arbitrarily complicated calculations happening on the back end by AstroPy to determine how these bodies would move when they're affected by each other's gravity. There'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. So I'd say this is sort of in the simplest category of Shiny apps in terms of what's easy to imagine here. And yeah, there's some other stuff on the left there. Some of the example apps show the use of different widgets. So there's one for Plotly there. You can use the plotly JavaScript based visualization library with Shiny for Python. |
748 | 748 |
|
749 | | -00:36:22 If you want your scatter plots to have, you know, tool tips that show, you know, data, for example. I mean, this particular one seems not to do that much. And, you know, you can use -- yeah, there's a -- there's a Wordle clone. |
| 749 | +00:36:22 If you want your scatter plots to have, you know, tool tips that show, you know, data, for example. I mean, this particular one seems not to do that much. And, you know, you can use -- yeah, there's a -- there's a Wordy clone. |
750 | 750 |
|
751 | 751 | 00:36:35 >> No, it looks like a -- it looks like a mobile phone keyboard. I mean, I have a whole keyboard right here. I was like, now you can type into the mobile phone keyboard. |
752 | 752 |
|
|
922 | 922 |
|
923 | 923 | 00:44:31 So I really do believe there are a lot of different ways people are solving this problem in Python. |
924 | 924 |
|
925 | | -00:44:38 Streamlit and Dash each have their own takes, and Pinecone and Solara are all these different ones. |
| 925 | +00:44:38 Streamlit and Dash each have their own takes, and Pynecone and Solaris are all these different ones. |
926 | 926 |
|
927 | 927 | 00:44:43 And the ones that have thought carefully about this problem of how do you help people programming against what is inherently a dynamic system while staying safe, while making sure that you're getting the right answers every time and doing it in an efficient way. |
928 | 928 |
|
|
970 | 970 |
|
971 | 971 | 00:47:08 Like you're creating a chunk of code, which in Python is a function, and then you are annotating it with an indicator of your intent. |
972 | 972 |
|
973 | | -00:47:16 So in Shiny, you would write, you know, for a plot output, you would say def plot one or whatever you named that plot, you would have your map plot libcode inside, and then as a decorator to that function, you would say, this is an output and the type of the output is a plot. |
| 973 | +00:47:16 So in Shiny, you would write, you know, for a plot output, you would say def plot one or whatever you named that plot, you would have your matplotlib code inside, and then as a decorator to that function, you would say, this is an output and the type of the output is a plot. |
974 | 974 |
|
975 | 975 | 00:47:32 Now, I will say that being said, I have been a little bit surprised how many data scientists in Python I've talked to have not worked with decorators. |
976 | 976 |
|
|
1122 | 1122 |
|
1123 | 1123 | 00:55:37 The libraries and the UIs and all that, yeah. |
1124 | 1124 |
|
1125 | | -00:55:39 Yeah, so 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 and 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 Streamlet or Panel or something like that. |
| 1125 | +00:55:39 Yeah, so 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 and 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. |
1126 | 1126 |
|
1127 | 1127 | 00:56:02 >> Yeah. Another example is you work at a university where R is actually really has a good stronghold, especially in the math and statistics department. |
1128 | 1128 |
|
|
1267 | 1267 | 01:04:02 [Music] |
1268 | 1268 |
|
1269 | 1269 | 01:04:19 (upbeat music) |
1270 | | - |
0 commit comments