Workflow Demo Live Q&A - February 28th
videoimage: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
Hey everybody, we're going to go ahead and just give folks a few more seconds to trickle in. But as you're joining, feel free to post any questions here and we will do our best to tackle them.
Alrighty. Well, let's go ahead and get started here. So first off, I want to say a big thank you to Winston for that really amazing demo. I think Shiny Express is going to be a really awesome tool and it's really just going to kind of propel folks into the Shiny ecosystem.
For me personally, you know, I'm an R developer, I have been for a long time. I started to dabble with Shiny for Python and I found it as like a good kind of gateway into the Python ecosystem. And I think this is going to make it even easier. So I'm really excited about it.
For those that I have not met before, my name is Ryan Johnson. I'm a data science advisor here at Posit. You've probably seen my face on all these sessions kind of leading up to today. As a reminder, we do these on the last Wednesday of every month. And for today's demo, we brought in Winston, who is the Shiny guru.
So let me give a few seconds here to have Winston introduce himself. And as we like to typically do, I'm going to give Winston a little icebreaker here. And Winston, my question to you is when you're not developing Shiny or developing Shiny applications, what do you like to do in your free time?
Hey, thanks, Ryan. All right. What do I like to do in my free time? Well, I have three kids. So I'm spending a lot of time doing kids stuff. That's pretty much it. In the past, I've, you know, had various hobbies, like I like doing woodworking quite a bit. I like making things. But these days, you know, I don't get a lot of time to do.
So before we start diving into the various questions and really appreciate you all chiming in either on the YouTube chat or here within kind of our platform for this Q&A session, I would first like to bring your attention to a quick survey that we're going to flash on the screen down here at the very bottom. This survey is just a way for us to collect some information about your interest using Shiny Express and also Positeam. It's insanely short. It'll only take a couple seconds, but it really does help us get some feedback from all of you all in the data science community about your interest in Shiny Express, Shiny for Python, Positeam.
Performance and hosting questions
So the first question we actually got during the live demo, and it came from Adam here asking, are there any performance benefits to using Shiny Core over Shiny Express?
So there's a couple of levels to this question. So in terms of the overhead for using Shiny Express or Shiny Core, there's a trivial amount like when it parses the code, where it has to evaluate each line and decide whether or not to use the return value of that and put that into the UI for the application. So that's really, really, really trivial.
There is one thing that people should be aware of. But if you are developing locally, when you load a Shiny Express app, it runs the code one time to generate the user interface components, and then it saves that. And then for each session that connects, so the first web browser that connects, it'll run that code again to set up all the reactive stuff and the outputs. So and then for each, and that part is the same as for a Shiny Core app, and it runs the code.
So it runs the code twice when you're developing locally for when you visit the app. So that could be noticeable for local development for when you're deployed on a remote server. But we're working on ways to make it easier to sort of split up the code that needs to just run once for UI and the code that needs to run for the server. So we'll be writing more about that in depth in the future.
So is it possible to set up a standalone Shiny server that supports hosting both Python and our Shiny apps on the same instance? Or would one need to build two servers, one for each language?
So here at Posit, we do have a few solutions for taking your applications that are built in either R or Python and hosting them so you can easily share them with whoever. It could be your coworker, your boss, friends and family, whoever you want.
So in terms of Shiny server, which is a tool some folks have probably heard of in the past, one of the first tools that we ever developed here at Posit allows you to take a Linux server and essentially convert it into like a hosting platform. And the open source version of Shiny server does allow you to have both Shiny applications built in R or Python. So it's a really great tool.
Now, converting a Linux server into a kind of a hosting environment does require a little bit of IT and admin overhead. And you are just limited to Shiny application, that's pretty much about it. So we would certainly advocate for the use of one of our professional tools called Posit Connect. So Posit Connect is what we call our professional publishing platform because you can host multiple Shiny applications, both R, Python, you can host your Quarto documents, which we talked about in previous sessions, APIs and FastAPI, Flask apps, Bokeh, Streamlit, we have a ton of different support for various content types. And again, they can all be hosted on the same server.
And as the developer or the owner of the various content, you have a lot more control over it, say with Shiny server. You have control over who has access to it, how it runs on the server, so you can allocate more processes to it. You can really fine tune it to ensure a good user experience.
Well, actually, one other thing, you know, with Connect, every app that you deploy gets its own set of like, you know, Python version and Shiny version and all the packages. That's true for R and Python. Whereas with Shiny server, it's, you know, all the apps, they're deployed under just like one user and they don't have that sort of isolation. So it's harder to manage, you know, versions and dependencies and stuff. So if that's important to you, Connect is a better tool for that.
AI, VS Code, and Shiny Live
So this person is looking for a framework to build generative AI applications. Are there any plans to make Shiny Python Core or Express work well for this beyond chat stream?
So this is actually a really great timing. So we've actually been working on doing some planning for the upcoming six months or so. And we are, one of our big things is that we want to do a lot of exploration in sort of the ML and AI areas. And we will be working on tools for, well, for generative AI and for just for machine learning applications. How exactly that's, you know, what exactly is going to come out of that? We don't know yet. That's something we're still trying to figure out. But we know that that's an area that's really important to a lot of people. So we are going to be putting some effort there.
So can you talk a little bit about how to use this Shiny extension on Visual Studio Code? They said that looked pretty interesting in your demo.
You know, it's funny because I've just been using that for so long that I sort of forget like what can you not do when, if you don't have that. I believe you can just, you know, go to the Visual Studio Code extensions and you can just install this Shiny for Python extension. Again, I forget the details since I've had it for such a long time, but then, you know, you can then to test out your app, to run it, you can just hit the play button and then it will pop up in another panel in the VS Code editor. Again, I've gotten so used to using it, but you might as well just install it and use it. It'll make your life easier.
And I think for a lot of the folks on the call here that may be, you know, Shiny for our developers and have really gotten used to the integration within the RStudio IDE, they may be a little scared, so to speak, to start developing Shiny applications in a different environment. But I do think that Shiny extension and some of the cool features that it builds into, specifically Visual Studio Code, really makes the development quite a joy.
So you mentioned that there are limitations on saving data when using the web app. How about when using a server-based app like SQL Alchemy?
So, Shiny Live is a way of running Shiny where Python is not running on the server. There's a special version of Python that's compiled to WebAssembly, which runs in your browser. So when you deploy an application that way, there are some benefits to it. But there are also some limitations to it, like you can't... There's no server that it's running on. The server is just a dumb web server, and it sends you these... It's like a static website, essentially, and all the Python code runs in your browser. So there's nowhere to save data to.
Now, for a traditional Shiny deployment, I think that's what's meant here by a server-based app. You can do anything. So if you're running Python code on the server, and so if you want to, if you've got a SQL database or if you want to just write files to disk as a CSV or whatever format, you can do that. It's just running Python code. So that's a big difference between Shiny live and regular Shiny deployment.
Posit Connect, R vs Python, and dark mode
So is it possible to run Posit Connect on-premise? If so, is there a cost? So Posit Connect is a tool, again, that we've built here at Posit, one of our professional tools within that Posit team ecosystem. And Posit Connect is meant to be installed on a Linux server that you maintain. And where that Linux server is, is completely up to you. If you want to have a physical server right next to your computer and install Posit Connect on it, you can do that. If you want to have it hosted in the cloud in a virtual machine, you can absolutely do that as well.
So that's one of the benefits of Posit Connect, is it gives your team the flexibility to install it on a Linux server, wherever that server may be. And it could be a single server. It could be a compute cluster using something like Kubernetes or Slurm. And yes, there is a cost with Posit Connect. So if you're curious to know a little bit about the cost, we'd encourage you to reach out to us here at Posit.
So I'm going to move on to another question here, which I really like this question. So the question is, you seem to be doing a lot with Python. What is happening with R development in Shiny?
So it's true, we are doing a lot with Python and Shiny for Python. And more of our energy is focused there than on Shiny for R. And there's a bunch of reasons for this. One of them is that Shiny for R has been around for close to 12 years now. And Shiny for Python has not been around for two years, hasn't been around for two years. So for R, Shiny is pretty mature, pretty well established.
There's not a whole lot right now that we're doing the Shiny for R, except for there's various UI stuff. So there's like a lot of the UI stuff, like in BSLib, like for sidebar styling and cards and all that sort of stuff, that is actually happening in R first. And then we bring that code over to Python, because a lot of that is, the reason we can bring that code over is because a lot of it's JavaScript and CSS stuff. And then we port the R code to Python code.
Now there's actually, there's stuff that happens in the other direction as well, where we have been implementing stuff in Python and we have ideas that sort of feel natural or that come up from Python that then we brought over to R. So a recent example of that is being able to run asynchronous extended tasks. So to be able to launch something in the background in a Shiny app, and then keep using your Shiny app while some computation happens in the background. That's something that Joe Chang implemented. And we did that first in Python and we brought it over to R as well. So there is sort of this exchange that's still going back and forth.
Yeah, and that's Shiny, actually, I should mention, so Shiny Express, that's another thing that we were able to do in Python and sort of looked around and we saw, oh, okay, it's possible to do things this way here. Let's try that. And then, so, and we may, I'm not sure, well, it depends on what people ask for, but like I have a sketch, I have a basic version of that working for R as well, but in order to get that fully baked, there's a lot of work in terms of documentation and a lot of details that need to be done. But we might, we could bring that over to R as well. So there is an exchange of things that are going in both directions.
Does Shiny have a dark mode? That's a great question. We, our team, we merged a PR pull request yesterday to add a dark mode widget to Shiny. So it's actually, well, gosh, I don't know if I can show you here, but it's really cool. You click on it and there's this really cool animation where it's like, there's like a sun thing and it just turns into like a moon. So yes, that is there. That's in the development version of Shiny. Oh, and I think it's already in Shiny for R or BSLib on the R side.
Shiny vs Streamlit and modularization
Can you compare and contrast Shiny Express and Streamlit?
So you know, one of the things that Shiny does really well, I think in comparison to Streamlit is the execution model can let you do a lot more stuff. So like when you change, when you change an input on a Shiny application, you know, that sends a message to the server and the server knows like, Hey, I just, I need to recompute everything that uses this input value and nothing else. And then, you know, it does a computation and it sends the updated outputs back to the web browser. And that's, that can be quite efficient.
And contrast that with the, you know, the Streamlit model where you do anything, you change any inputs and it reruns the whole script over and over again. And then they have, you know, they have tools to try to try to reduce the amount of computation and data that's sent over to the, to the browser, like caching. But that's sort of like, that stuff is sort of a, it's sort of an add on. And it's like, it makes things more complicated, whereas that's just sort of the basic part of Shiny.
But for Shiny core, there's more code you have to write compared to a Streamlit app. So, and so that, you know, that I think was a hurdle for people to get over. So, so, you know, we're hoping that, Hey, with Shiny express, there's, there's so there's, we've removed a lot of the boilerplate code. You can, you can keep things a lot more concise. And so hopefully, you know, hopefully that'll resonate with people and they'll be like, okay, I'm just, just going to just go ahead and just get started writing this app with just this minimal amount of code.
But for Shiny core, there's more code you have to write compared to a Streamlit app. we've removed a lot of the boilerplate code. You can, you can keep things a lot more concise.
How to modularize the Shiny express app like the traditional Shiny core?
So for those that aren't familiar with this, there's a thing that we have in Shiny called Shiny modules. This was originally an R and it's not. So in the Python world, there's already, you know, modules already mean something else in Python, but we're talking about Shiny modules. We specifically mean like components, Shiny components that you can use on a page and reuse and they're sort of encapsulated.
So in a Shiny express app, you can use module, you can use modules that are written with the Shiny core syntax. You can already do that. Now if you want to be able to write a module using the Shiny express syntax, that's something that we're working on right now. And yeah, that, you know, that's, there's some details about that that make it a little bit challenging. Like how should, you know, how do we want people to be able to write this code and, you know, express what they want to do. But we're going to do it. So yeah, we'll get there.
IDE choice and Jupyter integration
And this question is asking if there are any advantages to using Visual Studio Code instead of the RStudio IDE for developing Shiny applications?
Yeah, I would say, you know, for the, if you're developing Shiny for R applications, the RStudio IDE is definitely the way to go. It's there's, there's a lot, there's a lot of stuff, a lot of work that's gone into that to make it, to improve the experience of writing Shiny applications for R.
If you're writing Shiny for Python applications, I think, you know, it's, I would, well, and I do use the VS, I do use VS Code instead of RStudio IDE because, because it's really, it's really good for Python stuff. So, and, and there's, you know, this extension, this Shiny, the Shiny for Python extension for VS Code. And it, and it understands, you know, like Python syntax highlighting and type checking and all sorts of stuff that, that can be really useful. Whereas, whereas I know RStudio does, the RStudio IDE does some of those things, but it's not, it's, there hasn't been as much effort put into that on the RStudio IDE side.
And I can also just kind of one plug for one of our other professional tools, Posit Workbench. One of the IDEs within Posit Workbench is Visual Studio Code, and we've actually incorporated a Posit Workbench extension, which allows you to run applications, interactive applications as like a proxied server from within your development environment. So it's a great way to develop Shiny applications within VS Code and then run them kind of within your development environment, see those changes kind of live as you're developing.
Would it be possible to call a Shiny app or to call a Shiny app from Jupyter Notebook? If not, is there an integration planned?
It is definitely possible. I had at some point in the past, I had made it possible to launch a Shiny app from a Jupyter Notebook. It was a little bit hacky. You know, there's actually, I think there's a couple of different ways somebody might want to go about it. So one of them is like, hey, I'm in a Jupyter Notebook. I want to launch this Shiny app. And they could write the code in the Jupyter Notebook and then launch it. That is, sorry, launch it and then view that from a different web browser window. That is possible. It's like I said, that part is a little hacky.
There was actually something where Joe Chang, he had created, he actually had some Jupyter integration for Shiny. So you could write code that was sort of like Shiny Express. And then the stuff would just show up in the Jupyter Notebook, like the inputs and outputs. So we actually, you know, I don't know, there's maybe like a month or so of work that was put into that. And it's not clear, well, we weren't sure where to go with that. Like if that's really where we're going to keep putting more effort. So we ended up focusing on Shiny Express instead of continuing on that Jupyter path. But you know, I mean, if that sounds like something that a lot of people would be interested in, then we might re-revisit that decision. Because I mean, it was actually kind of cool to be able to just like put in the stuff, you know, like inputs and outputs in the Jupyter Notebook and just be able to have that show up.
Closing thoughts
But Winston, actually, I just have a question for you in general, as a good kind of wrap-up question. So you've been working on Shiny for a while, and you know, Shiny is going to be around for a long time. But what would you say is your most personally most excited about for Shiny in terms of like what's coming, what your team's working on, anything you can share in terms of like, what's the latest and greatest coming to Shiny that you're excited about?
You know, I am actually really excited about this exploration that we're going to do for ML and AI stuff. So you know, last year, we put some energy into that, into some, you know, making it work with like LLNs. So that's, you know, chat streams, chat stream came out of that. But that was kind of a side project. And so now we're going to really, we're actually going to focus some energy on that. And so hopefully something, you know, some really cool stuff will come out of it. And like I said, it's still in the exploratory phase. But that's the kind of stuff that I really like is learning about new stuff and just like and building new things. So yeah, so that's, I don't know, that's what I'm excited about.
But that's the kind of stuff that I really like is learning about new stuff and just like and building new things.
Yeah, I think everyone here is equally as excited. So that's awesome. Well, with that, we can wrap up a little early. So really appreciate Winston for the great demo, and also for sticking around for the Q&A. A lot of great questions from the audience. So thank you all. And then just one last little plug here. If you don't mind taking two minutes, just fill out the little survey, just to get some feedback from you all regarding Shiny Express, Shiny, Posit Team, what you like, what you don't like. That just helps us internally to improve our tools, improve sessions like we're hosting today into the future.
And again, if you have any other questions, there's also a link in the chat to set up a call directly with us. We'd love to chat about all things Shiny, all things Posit. We're open up to the entire audience and data science community. So thank you all. Thank you, Winston. And we'll see you again on the last Wednesday of next month for our next Posit Team demo. Thanks, everybody.
