image: thumbnail.jpg
How marimo adds reactivity to your Quarto documents
Links:
- https://quarto.org
- https://marimo.io/
- https://docs.marimo.io/
- https://github.com/marimo-team/quarto-marimo
- https://github.com/koaning/wigglystuff
- https://anywidget.dev/
00:00 Introduction
01:19 Getting started with marimo
35:34 ScatterWidget
42:45 Data sources
53:24 Marimo plugin for Quarto
Transcript#
This transcript was generated automatically and may contain errors.
Hey everybody Thanks for joining me today, my name is Jeroen, I do DevRel at Posit and we're joined here today by Vincent Warmerdam Vincent. Hiya. Hi
Yeah, nice to be here. It's um, like I've always been an RStudio fan back in the day So it's nice to sort of see the evolution and you know, we're calling it Posit now But yeah, it's nice to be here
yeah, so Vincent you're a you're an engineer at marimo and That's actually what we're going to talk about today about marimo and also this this cool plug-in that yeah We we tend to ship. Yeah, we ship a lot of things and recently we ship the thing for Quarto as well Believe it or not. It was actually if you look on YouTube It was the number one feature for months like people wanted to have marimo support inside of Quarto So we were too busy hiring to be able to work on it. We then Got the guy hired as they did the work for it and it's out now people can go ahead and start playing with it
It does help if you can appreciate what marimo does under the hood and that's also kind of the point of today we're gonna talk a bit about marimo and then also use that as a staging point for moving on to the plug-in, but yeah We're super like the first feedback we've gotten so far has been extremely positive. So we're definitely keen to talk more about that
I'm very excited. So why don't we dive straight into it? I Have my terminal so I'm typing and yep. It's up to you what we can go anywhere. We we want and So I have my my terminal open right now, but that's not where we need to start Why don't you tell us a little bit about marimo?
Getting started with marimo
Yeah, so what I think will be the easiest that you've got UV installed. I'm assuming right? Yes, that's correct So what one thing you could do is you could start a virtual environment here and immediately call and like we can install marimo what you can also do is just type UVX and then marimo that should also work and Then do dash dash help at the end
Yeah, the benefit of it. Yes, so that that should work, right? So this allows you to run marimo without a virtual environment because you can just immediately call marimo It goes to see that there's like a bunch of commands there
Yeah, right at the bottom so You can convert Jupyter notebooks or mockdown files into the format that we like to use over a marimo. There's config There's all sorts of things But there are two verbs that are going to be important for us right now One of them is the edit command and one of them is the run command The idea here is that when you can run a notebook in edit mode Which means that you can edit it kind of similar to what you would do with a Jupyter notebook But once you're done editing you can also deploy it as a web app in that case you want to run it in run mode Well run mode. I think we call it app mode internally actually But those are the two modes that I think would be fun to maybe explore first
And while we're at it, what we're also going to do is we're gonna build a Python notebook first where everything is nicely sandboxed So we're gonna go with UVX marimo edit all right, and so I Heard the word notebook in there, right? So marimo is all about notebooks marimo is a Python notebook That's the the best way to describe it and Python is the first-class citizen. We do also support SQL and markdown we'll get to that in a bit, but it's definitely a Python notebook
So what you can do is you can type edit indeed then you have to do dash dash sandbox I'm gonna come back to that why that's relevant. Mm-hmm and Then we can give a name to the file we want to store the notebook in Everything in marimo is stored in a Python file. So you could just type notebook that pie We don't do the thing that Jupyter does with the JSON. We do everything in a Python file basically So just notebook that pie will be good here. All right
So a bunch of stuff is installing and we see The marimo notebook has spun up and it's opened the browser for us and it was really fast It was I just want to say that thanks to UV and everything is installed very fast It's UV is definitely doing the heavy lifting on the speed there. That is definitely true But yes, this is a notebook and it's in a lot of ways similar to Jupyter because we've got cells and stuff But it's also very different in a lot of ways, too
So what you'll notice is there's a lot of buttons. There's like a side panel on the left But I think the easiest way for me to explain just what makes marimo different is to just immediately start typing in a cell All right, we'll get to all the fancy buttons in a bit But let's also maybe zoom in a bit because people might be seeing this on their mobile phone
All right. Yeah, something like that feels appropriate What you can do now is you can hit tab and that first line will autocomplete This will load all the marimo utilities And if you can now hit like shift enter you're gonna run that cell a new cell below should appear And you can also move the mouse cursor in there and just as a base example Let's just type a is equal to one
Yep, and then the new cell below that So you can run it and then B is equal to two and that's also like we're just gonna do basic Python variables here Right, nothing overly scary. And then let's do one more cell below that and we can do a plus B
Keyboard shortcut to run the cell and open a new cell immediately after that isn't that like Yes, I have a fancy keyboard where all the keyboard shortcuts are super custom You have like keyboards Yeah Collection at this point what you can also do now is just can you hit command K? So that'll bring up the command palette and if you type shortcut in here Then you're gonna be able to see all the keyboard shortcuts that we've got if you hit enter now You are gonna see all the shortcuts so we can look in here. But most of all is also edit buttons
Yeah, so shift enter there you go, but you can also change all of these so if you wanted to make a change here That's also something you could do. Yeah, so if you do shift enter now, yeah, there you go I think it's the same in Jupiter, but now you can type a plus B
Yep, and nothing scary is happening here, but there are like a few notable differences of Jupiter, right? So one thing that's different is that we render on top instead of below Yes, so notice how the three is rendering on top of instead of below it that's a setting you could change But there's a reason why we do this
So just for fun if you hover your mouse over the cell that has a is equal to one and If you now look at the right-hand side of the cell, you're gonna see zero milliseconds and you're gonna see those six dots Yes, can you grab that and scroll it down? Down here and you can yep, and you can do the same thing with B is equal to 2 and you can do the same thing with the import statement Like in marimo the order of the cells doesn't necessarily matter Marimo will figure out in what order the cells have to run in order for them to actually go ahead and run So what you could do now is just refresh the notebook
So hit command R on top of my mind It's like the browser refresh window thing Yep, and then you can hit restart on the right-hand side of that little no no on the blue cell There's a restart I can on the right hand. Yep that one that's gonna restart the entire notebook we start and You're gonna notice this thing just still runs without you having to do anything and without even without having to do like shift enter through All the cells and again, that's because marimo can figure out in what order things have to run. Yeah, that's very nice
I mean, that's something that I believe a lot of notebook users run into is that at a certain point? What you have on the screen is not really what is going on under the hood, right? So what's in memory or what's on screen tends to be like you don't have that guarantee in Jupiter But what we can do now just for shits and giggles. Could you just remove that line? It says a is equal to one just have a blank cell there
Yep Now hit enter like run that cell OOP, it's immediately in your face telling you like oh, there's a variable missing in Jupiter this would have been different right because Even if you remove that statement a is equal to 1 a is equal to 1 is still in memory And if you remove the cell, I mean someone else might would not be able to run the notebook But we can kind of be in your face about it
And the reason why this works is because marimo under the hood is actually doing a forward pass over all the code It is looking at all the different cells And it's in this case saying oh, there's a cell a that contains a plus B we need to look for a cell that defines a and we're looking for a cell that defines B and We're able to sort of build a DAG of operations in a way So if you go back and like add a is equal to 1 to that cell again
Yeah, so this Pop as a cell below. That's the one so the yeah, that's the one though The second cell. Oh, yes, that's right. That's the one more yet. Yeah, so this is An entirely new pop-up so to speak Yeah, so it's popping up in the cell where we detect that a is missing. Yeah, so but if I not say a is 1 again I'll run it the error goes away and
now we can do something interesting like if you go to the to the side panel on the left and then 1 2 3 4th icon from the top the one of the graph Yes Yeah, you can click that and then click vertical tree So then you can you can actually see the DAG like this is something that people always find kind of interesting So you can actually see what cells depend on each other so you can actually see that marimo has figured out Oh, there's a cell zero that has a plus B in it and it depends on these two other cells and in this case is like Crazy simple if you have a more complex notebook, you can actually see really complex DAGs appear over here. Yeah
Oh, wow, but but I'd like to emphasize this is actually what's happening under the hood So in a like one way of describing what's happening here is marimo is like almost a compiler it looks at all the cells and then And depending on what it sees in the cells that determines the order of in which operations actually happen. So there's like a It's not the same as compilation obviously, but it's like almost a compilation step Like there's a thing that we do before we actually run anything. Mm-hmm. Yeah. Yeah
So in a like one way of describing what's happening here is marimo is like almost a compiler it looks at all the cells and then And depending on what it sees in the cells that determines the order of in which operations actually happen.
very refreshing Um So, I think I mean I Have to think of the term reactive here. Yep What would happen now if we were to change the value of either A or B So let's let's just show it. So the yeah, it's sort of pick whatever value 42 or think of seven Good. Why do it 42, of course? Or 41 so that the answer now in the first cell it's 42
Yes, and if you look back at the DAG that we've got right? Mm-hmm Marimo can actually do something kind of clever here because we noticed Oh B is equal to 41 now. Oh, so then there's a child that needs to update But I don't have to update the cell that has A is equal to 1 So it can be very picky about what parts of the DAG have to actually update. So oh, there's one cell changed over here Okay, let's look at all the children in the graph and those need an update and that's like Pretty convenient also from like a oh, I don't want to rerun code. That doesn't have to be run Like I don't want to read the whole CSV file again like that that kind of stuff is also nicely Captured by having it in a DAG form sunset. Yes
Wow and Like a lot of stuff in Marimo might feel a bit strange if you use the Jupiter But as long as you understand this phenomenon Like oh, it's reactive and this is the thing that's happening under the hood. A lot of things do fall into place
And there's a few things we could do at this point like we could explore the UIs But one thing I kind of want to do now is also just show you a consequence of this because if you're a Python user There is this one aspect of having a reactive framework like this. That is a constraint So could you write down A is equal to A plus 1 for example? Plus one. Yeah. So what would you expect to happen when you run this? By the way, you're introducing it. It sounds like this Yields an error Yeah, so feel free to run it
It definitely does an error and the DAG is actually kind of giving you a hint. So if you look at the DAG visualization you can kind of see that You kind of have to make an assumption that A equals A plus 1 but that has to happen before A plus B Yeah, but we totally have to make an assumption in order for that to work and we don't like assumptions We want you to be quite explicit And so, you know the DAG does show it in this particular case But there's a mechanism inside of Marimo that says okay We don't want you to do this because the moment that we have a lot of this mutable state Then it's very hard for us to understand in what order things have to actually run You lose that benefit of oh the order of the cells doesn't matter anymore and we value that more than being able to overwrite globals
Yeah. Yeah, that makes a lot of sense. I mean there would also be It would redirect to itself, right? You would get into an infinite loop. Otherwise You could also do some gnarly things with that Actually, if you're not careful and like if you know your way around Python, there are ways around this But none of those would be things I would recommend just to be Explicit like if you know what you're doing, you can't still muff around but
In a lot of data analysis There's a reason why in place is true is sort of being phased out in pandas, right? Like there's a reason why all these in place operations. They kind of turn out to be a bad idea for data pipelines If you're used to writing Python scripts, though, there is this one thing you can do so if you copy that line a is Equal to a plus one if you copy that one line and then feel free to just remove the cell
Yeah, what you can do within the same cell you can you can definitely exactly right exactly so if you Yeah So what we care about is that a variable is defined and created in one cell and only in one cell And you are totally allowed to do that. That's totally fine by us
What you're also able to do is if you'll make variables that you only use Like you have a for loop Let's say like for I in range 10 or something like that and technically I would be Declared in that for loop. Mm-hmm So what you can do for moments like that is you can add a prefix so you can do something like underscore for underscore I in range hmm It's like Two or something as and then like prints I guess or whatever. Yep So technically underscore I is now a variable and like theoretically you could say, okay, you can't use it anymore
But because you add an underscore in front of it there's a convention inside of marimo that we know like, okay, that variable should only for all intents and purposes only exists in that one cell and if it's redefined elsewhere it'll always be constrained within that one cell. That's the assumption. Oh good. Yeah. I mean this is related to the convention that variables that start with an underscore considered private.
Yeah, well, I think double underscore is like properly private on the single underscore is hidden. I think in I think invention could so like if you if you have on an object, right? You've got a method that starts with underscore you have completion won't work, but you are still able to call it if you do double underscore then there's an extra safety mechanism that prevents you from calling it. It's not the same as like private stuff in Java. No, but yeah.
We don't but anyway like as far as marimo is concerned like we do have things like that that do allow you to play around a little bit with mutables. We just really don't like them like if you wanted to have mutable states, that's something you can declare explicitly but for data analysis, you should probably not go there. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah.
Markdown and UI cells
So these are all code cells. Yeah, we also have other kinds of cells and we move totally so if you let's make a new cell. So let's let's close that pane on the left hand side, by the way. Like we don't really need it at this point. And then in the new cell you see at the bottom by the way you can see that we've got Python markdown or sequel, right? We support mark. Let's make a markdown cell for now because we don't have a data set just yet but like you can start typing in markdown there, so headers and yeah, this is a header.
And you can also add code cells there so like stuff with Python and you should see autocompletion stuff happen there as well. But it wouldn't execute this oh this is just static. Yeah, so it's not being executed. Yeah. Oh nice good code syntax highlighting nice.
Here I see like oh, yeah, I guess that you're used to from from markdown basically. Yeah. What was the reason again? Why the output is being rendered above the code, right? So well, so to be explicit you can't change that right? So if you if you're really more comfortable that it's showing below then that's also totally fine. I think where it came from is partially the convention that observable does it the other way around so observable is this JavaScript notebook. The thing that is kind of nice is if you're dealing with stuff that's highly visual then the code actually matters less than the cell output.
So for example, oh, I want to show a slider. Well, the sliders like the important bit. But the way like it becomes a little bit more clear if you were now to sort of press command H that's the shortcut for hiding the code. In the case of markdown. Oh, it's it's really clear that the code doesn't matter. I just want to see the markdown itself. Absolutely and you will have a similar thing. We haven't shown that yet. But marimo also comes with a bunch of user interface elements. If you render those and it also kind of becomes clear that I'm declaring a UI element over here well, then the UI element matters not the code. So the UI element should go first.
We have a look at those UI less so that's also why at the top we imported that marimo library, by the way. So the mo module that also contains all the UI elements and one thing that's also just good to mention it is actually kind of normal in a marimo notebook to move all of those library imports to the bottom. Because all right, let's do that. Yeah, so and again, it's like people have might have different conventions but like it's not the most like the import is usually not the important part of the analysis so say so why start with that? You can also just move it down especially because we understand the order of the cells in execution.
Sliders and reactivity
Having said that what we can do now is we can add another cell. Add one anywhere. All right. Yeah, and then if you go to marimo's module mo dot UI we get to the user interface module and a slider. I think is the easiest example to go for so let's just go with slider.
Pressing tab, but I'm not seeing any. You have to go the autocompletion is a thing that needs to be configured because it requires an extra dependency if you go to the cog on the upper right-hand corner. Yes, and then there's user settings the cog so at the bottom there's a yeah that one. So if you go if you scroll now down on the right pane, I think you have to the language server setting. Yes, so that one is installed.
Could it be because I'm using them? but my that might be let's disable those for now because yeah, let's and now if you type no s
What might be causing this I mean so one thing we can do actually could you go to would it be in a would you have do you need to import this sub module separately because I am getting our mission yeah, but that's the but that's it's it's not picking up the marimo I just all the stuff you see here is basic Python stuff. So this is nothing related to marimo. Oh, yeah.
Can we just double-check that we ran that cell so just hit play on that guy it's important. Yeah, so that that shouldn't be it one thing we can do just for a good measure so if you go to the left-hand side panel, you'll see that there's this icon of a oh it does work now now it does work. But is that because I just press play or because I'm in a cell below the imports easy to try. Let's try a cell that's above the import statement. Okay matter I
mean oh really? Okay, that's a bug we're gonna I'm gonna file a bug after I've never seen that before well, that's that's the way it goes that's it's all part of a no worries. Okay. Well, let's let's do the autocompletion for now though because the autocompletion is definitely nice, but okay. Yeah, I'm just gonna move this to the top. No worries. I mean, this is uh this is why we do is somewhat live right like to figure out exactly. I'm happy. This is also a way to contribute back to marimo. Shouldn't be too difficult to fix.
All right, so we have mo UI yeah slider. Slider a whole bunch of options here. Oh, there's a ton. But let's let's go for a basic slider now like 1 comma 10 comma 1 is a good input. So the slider starts at 1 it ends at 10 and there's steps of 1. Yeah, yeah. If you were to run this now, you should already see a slider up here and you can already move it around.
Yeah, so this generates a slider. However, that slider has some state and we'd like to store that state into something. So let's maybe come up with a variable name for it. X. X sure, why not? If you were to run the cell now, the slider is going to disappear by the way, that's because we're not returning the slider itself so I have to like end with X at the bottom. Yes. Yeah need. Yeah now when you hit play.
Okay, so we have a variable that's all well and good and one thing we could now do is you could go to that yeah, so that will be a place to put it and you can do something like plus X dot value. Right, you have to be you you cannot you you cannot just do a plus X well, because you cannot add an integer to a slider objects just like you cannot add one to a data frame objects in Python. Yeah, it makes sense. But if the value property of that slider that I do think is an integer in this case and now if you move the slider around again, because everything is reactive we detect. Oh, there's one cell has updated therefore all the children have to update. Yeah, etc, etc, etc.
Super super smooth and the thing that is really interesting here is this is just a slider, right? But we can really start dreaming a little bit about different widgets and different user interface elements that we can add. There is a standard called any widget and that like that deserves a podcast on its own that whole library. Yeah, but there is now a standard between notebook environments when it comes to making widgets. So if you follow the any widget spec, it'll work in marimo it'll work in Jupyter. It'll work in colab. It'll work in VS code. There is now a standard way to write a widget once and it should work in all the notebook environments.
There is now a standard way to write a widget once and it should work in all the notebook environments.
That's nice. Um, so one thing I think will be fun to do here because I also want to start talking about data friends at some point. Mm-hmm is let's actually show what it's like to have a widget that can live update a whole data frame and just sort of see how that way is and we can go a step further than just the slider so let's just start a new one thing we yeah, so let's just start a new cell.
All we can just import there. It's fine. So there's a library called draw data. So from the from draw data I would do in this case import and there's this widget called the scatter widget scatter with a capital S and widget with a capital W. Yep, and what before running this? What do you think should happen when you run this?
I'm guessing again that it's gonna error because we haven't installed raw data into our virtual environment. You're warm, but actually no, that's not what's gonna happen. Hit play. All right, let's do it. So it's the it's indeed throwing an error but marimo is picking up at oh the reason is because there's this library that's missing so in this case marimo can say like hey, would you like to install this and it brings you a pop-up? Oh, and you can also you can also decide what version and it auto detects that we're in UV. We are in UV. Yes, please keep it there. And you could now go ahead and install.
Marimo notebooks as Python files
So, okay, this is this is quite nice, right but before moving on could you go back to the terminal because I want to have a look at the Python file. Sure. Yeah, so feel free to yeah, so just yeah, there's a notebook in there. Let's have a look. Notice at the top there. Oh, yeah, it says it's a Python script. It has a Python version attached, but there are also dependencies. This is a thing that's made popular by UV, but it's a Python pep that I think is general. I think pip could also deal with it. You're able to just declare the dependencies of a Python file in the Python file itself and that also means as a side effect marimo notebooks are really reproducible.
And that also means as a side effect marimo notebooks are really reproducible.
This is super nice. This is 723 and because I recently gave a tutorial on creating command-line tools there. Oh, yeah self-contained, right? Yeah, it's amazing for that use case too. Yeah, we can also if you want to create a command-line app from marimo in a bit by the way.
But goosebumps right now, yeah, it's a fun trick. But anyway, like the main thing that's important to understand here is okay. Yes, it is it is a Python file that comes with a benefit that if UV does something cover for Python it automatically translates to marimo. Another thing that's also just good to just briefly show is if you scroll down you'll see that the cells that we defined are actually Python functions under the hood. Yeah, and oh, there's that markdown cell that we've made it's actually still a Python cell. It's just that we we've wrapped marimo's markdown utility around it. Hmm and what you can also spot if you go to the top you can actually see that the first cell it imports marimo and notice how it returns it.
Yes, then if you go to the cell below, you'll notice that that cell actually takes marimo's input and it emits X. Oh is that because we're using the marimo? Yes. So library here. So yeah, so this is the mechanism. So what you're seeing at work here is kind of a mechanism that detects what are the inputs of the cell and what are the outputs that children use the later children will use. So it's also reactive in the sense on on the modules that you use.
How could you rephrase that? Well, so a common common issue that I run into when using Jupyter notebook is when I'm working on a notebook and a module that I'm creating myself or some external script that is being imported into the notebook. And when I update module, yeah, is that is that what's yeah, well that it sort of so what you're seeing here is so what you're seeing here in scope is a little bit more how does marimo deal with it internally but a very similar mechanism if we now go back to the notebook by the way.
So if you look at the bottom bar the footer you're gonna notice that there's a couple of buttons on the left-hand side so are you gonna? Yeah, so we've an errors pane we've got a terminal as well, but then there's the on startup then on cell change and then on module change. Oh so yes, so what you can determine here like, okay when the notebook starts do I auto run? Yes, no, or do I want to do it in a lazy way? The lazy way is there such that if you have this one cell that is importing like gigabytes of data you don't want that to automatically rerun every single time. So we offer a setting that says okay auto run or don't run at all or do it in a lazy way.
Yeah. Lazy means manual control kind of Jupyter style, but you'll notice that you're able to do that on cell changes but also on module changes so the pattern that you've described you have a separate Python file that's your let's say that you're importing that yeah, we can actually watch for changes in that file. Wow, that is really nice like I use a pattern all over the place. I will say you can actually go a step further because what you can also do from a marimo notebook again because it's a Python file you can also declare functions that then other Python files import that is also something you can do.
Hmm so I've got a couple of these web apps that are doing something super machine learning specific. There's like this one part of the app that is really doing the app is called like remember dot cards. It is for like making flashcards, and there's like there's a mechanism on like okay, you just practice this card you got it right and how many days do I have to? Sort of bring back the card for you to practice it again. Like the rest of the app is like a normal web app but this is one function that I need it does a lot of machine learning that I've defined in a marimo notebook and because it's a Python file I can just add it to the web app natively and I can import it when I need it but I can still debug it with charts around if I need that to I guess also like a very interesting secret use case for marimo because it's a Python file. You can have it be part of your normal Python, whatever. Yeah, yeah, yeah, yeah, I
want to go back to the Python file? Just sure just a moment. Yeah. I was curious. How is the the markdown cell?
that's Okay. Yeah, so it that's also a Python function and It returns a markdown Yeah, you'll notice that the deck the decorator it says hide code equals true like because the code was hidden We specified that what you could do though is you could kind of just copy that it says mo.md So there's a markdown function on the marimo sub module and you can also call that from inside of marimo Yeah in a Python cell and it will run on the same thing So technically the markdown cell is more a little bit of UI sugar under the hood. It's still a Python exactly cell and this Returns I guess a markdown Object that has a display method or something a wrapper
yeah, so the the sort of we we kind of reuse the Jupiter convention so a lot of objects that have Underscore wrapper underscore HTML underscore like that's a function that the Jupiter really likes to use However, there are these moments When maybe you want to be marimo specific, so there's also the underscore display method that you can implement as well Yeah, as far as marimo is concerned the if the display thing is implemented We will go ahead and use that because that's a signal that someone took the effort of doing something very marimo specific And because what you could do is you could return marimo objects that we know how to render right so that that's the thing that You could do However, we will also pick up on the Jupiter standard if there's a library that implemented pretty Visualization things for Jupiter then that's a very easy way for us to also make sure it works in marimo. Yeah. Yeah, very nice
One thing that of course is a downside of Jupiter notebooks Is that when you whenever you change something and you you commit it you get these huge diffs? Because it's all yeah, I mean so it There are like I don't want to be like in fairness to Jupiter, right? I mean there are tools to help you with that situation and a lot of those tools come with some pretty good ideas like okay Let's remove the outputs and there are these like pre commit hooks that you could use And you know those are not bad ideas. They're actually quite great Yeah, however, the the one thing that you should also shouldn't forget is that Jupiter was designed not just to do Python So Jew pie turn like Julia Python and are those kind of the design inception thing? Yeah And with that you also have to make some some choices and like a really convenient thing for us is that we were able to Say no like pythons gonna be the primary citizen and I'm sure we'll do sequel and we'll do markdown But it's gonna be Python and that allows us to just do everything from Python files Jupiter couldn't ever really do because that's not what it was designed to do. That's that's a very that's a fair statement. Yeah. Yeah
Say no like pythons gonna be the primary citizen and I'm sure we'll do sequel and we'll do markdown But it's gonna be Python and that allows us to just do everything from Python files Jupiter couldn't ever really do because that's not what it was designed to do. That's that's a very that's a fair statement. Yeah. Yeah
Two-dimensional notebook layout
Alright, I think there's like an extra thing I don't want to I want to show now though because Just to sort of expand the mind. So we were So if we could go back to the marimo notebook, I think there's like two things. I want to show Because we were working on the scatter widget and that's kind of cool But I think we're the notebook is kind of getting a little bit crowded. So let's do a party trick Could you go to the? hamburger icon on the upper right hand side Yeah, sorry the cog I mean the cog that's next to it. Yeah. Yeah, so there's a display part of the menu there Yeah, could you yeah click it and could you go to columns instead?
So a thing that we can do because again the order of oh you actually that's that's the yeah I thought that yeah, right. No worries. No worries. Could you zoom out a bit now, I guess In the browser Yes, so you notice there's a plus icon there now, right So you can add a column So you can do left right swiping and like this is also the thing that it takes a while to get used to but your notebook Can't actually be two-dimensional So something I really like to do in teaching is I have like one column that has all the imports and setting stuff up Then there's a column with like boilerplate then there's a column with helper functions and then there's this other column where all the action is like all the widgets and like the Final output and it's up to you to decide where do you want to you want to move that left or right? But you can start thinking about a notebook more in a two-dimensional fashion if that makes sense
So in this case, we just imported the scatter widget. Let's now make a column That's all about doing something with a scatter widget So what you can do now is you can just yeah, so loads the scatter widget just to clarify. It's still the same notebook Yep, right. It's not like I have two notebooks open next to each other All right, same same same same notebook and the same mechanism we again Holistically look at all the different cells one thing you can do if you zoom out it one more time again all right, there's you have to hover over the right spot, but like if you yeah, so under yeah, so between This is actually this is also a bug it ticket I'm gonna fix because it's unclear where to where to grab it if you move the cursor straight to the left now just inch Oh, no, you're being too fast. So move the cursor. Yeah. No move it very slowly to the left and at some point you're gonna Yes, I See, yeah, you can make the the width smaller or bigger and I think in this case Yes, it might make sense to have a smaller one because then more fits on this little screen And you have it on the right side as well Yeah, so you're like yeah where you're grabbing that you're modifying you have to know where it is in order to yeah So the downside here is you have to yeah, so you have to know where it is in order to grab it That's still a UI thing. Okay, we'll make
Yeah But anyway, what we can do now is like use the scatter widget in that cell on the right. Yeah Yeah, tell me what to type Scatter widget so ST and then tab completion should take over. Yeah, and we can run this now And lo and behold now we might need to make it wider actually for this thing to properly fit But this is this is the widget that we want All right. So The idea behind the widget is you can draw around Yeah, okay this is good enough so you can draw around you can draw data points and the idea here is that these data points Can actually then be turned into a data frame. So you've got that famous I could learn image of all the different classifiers We're thinking what this widget was. Oh, you might want to be able to draw that widget yourself And this is the way to do it. However, this is now in any widget and we would like to Do something such that any widget can really deal with it in a nice way. So what you would do if you would go to the code at this point and where we declare scatter widget and we're gonna Actually assign the scatter widget on here. Yes. Yeah, so we got to assign it to a variable. That's like the first thing we got to do Yep, and then also show the variable at the bottom because otherwise it won't render exactly. Yeah, right
Okay, so that's that's step one step two is we got to wrap that scatter widget with a marimo function so mo dot ui dot any widget I think Yep Let's move scatter widget in there and Visually, it will all look the same. But now when you run this What you can do? Yeah, you should be able to access the value If I'm not mistaken And Run that and then you can see there's a couple of items here It's empty because I rerun renders and now I should put some data in here. Yes So you can actually see that data attribute grows a bit bigger one thing you can also do is there's a property on that scatter widget data Yes, so if you yeah SW dots data underscore as polars Yep, I know you know, it's a property another method All right, but but it first explains about that polar Yeah, so that's fine. I mean you can hit install and it's gonna do the thing that it needs to do
Interactive data frame widget
It should be installed through rerun it yep, okay And like a nice thing about this is we have a data frame widget as well that people Sometimes miss out on so a data frame that we see which it could also be a table from a SQL database It could be polars. It could be pandas. We we use narwhals under the hood But the thing that we really like is having giving you something that's a bit more interactive than just like a static HTML table element so There's pagination you can move left and right Maybe it's good to add another column because our faces are kind of in front of the buttons now Yeah, I guess I can also drag this to the left oh, yeah, that also works that also works
There's one feature I kind of really want to brag about that was added recently for a scroll down so You'll notice that there's buttons on that widget so you can paginate you can go left and right you can set the the size You will also notice there's a download button there So if this widget was used in a web app and this was for a business user The business user can just copy this to clipboard to get it into Excel for example if that's something they're interested in or they can Download it and open it up in whatever thing that they like to use But if you now scroll to the right on the same height you're gonna see a magnifying glass Let me see if I'm gonna scroll to the right oh, so it's a left sorry to the low over here Yes, yeah, yeah, this brings up a search pane so now if you were to type in a number at 2 8 2 for example There it is. It's up here. Yeah. Yeah Which number I think 2 8 2 actually I'm not sure if it does numbers But yeah, so any road that has the number 2 8 2 appear anywhere We are now filtering life. That's basically what's happening here nice
So that's definitely kind of a nice thing what you can also do is just remove the filter You can also select the columns if you want to do filtering by the way that's also something that you can do so you can see the types for example, but you can like do all sorts of sorting and Copy the names and The stuff you would like to have around that's definitely there one of the coolest features that's almost kind of hidden is if you go to the right of the magnifying glass Right. Yeah. Yeah So that's the rove. That's yeah that one you want if when you click a little column X Yes, so this shows summaries of columns So if you were interested in I don't know checking the distribution of X you can click it Oh, we need all tear in order to render the charts. So you can just get Just clean your summary. Yep. Oh, wow. That's a nice feeling right and now if I were to Yep, if you were I think if you were to draw now, it should update Or am I filtering? Oh
Think so the moment you click that's when we I think the the column viewer does assume that it's immutable actually Well, it does what I do see changing here is the number of rows Yeah, but the chart doesn't update if you were to close that X thing and then open it up again Yeah. Yeah, then it does Yeah. Yeah. Yeah. All right That's I'm gonna make a note of that one, too. Good Very useful video
Yeah, I mean so there's a concern here because it might be a very large data sets, right? So this data frame is of course very small But we also deal with data sets to have like 50 million rows at some point in which case by the way that chart Will detect that it needs Vega fusion instead of something we do pick up Yeah, because I can't imagine like if you haven't every time we add like a row to that data frame All the charts get an update like that's that's something also like a burden on the compute exactly so Vega fusion would work right because Altair by default handles up to what 5,000 rows You can increase it the more you can throw a warning. They throw a warning. Yeah, it will be get yeah it needs a lot of a lot of RAM for that as well and But I guess you could also do the aggregation Using Yeah, so if and also like if you have a time series for example, we also don't show every millisecond We do bucket it at some point. Yeah. Yeah. Yeah
This is super nice. So yeah, I like the thing so it's especially nice also because oh, I just want to have an What are all the columns and there's a nice overview here We have some visual cues that tell you what kind of column it is, right? So we try to make a notebook that's kind of like rich and interactive to work with another thing I want to mention about this data frame that I think is also good to show is if you go to the Left-hand panel one more time like all the the buttons you're gonna see this database icon Yep, so our data sources. Yeah
Data sources panel
Yes, let's now assign that data frame to a variable so we can do something DF equals data as polars. Oh Now the data frame is Special citizen. It's we've only yeah. Yes. It's a data source. So It's we already keep track of all the functions and variables that you've got. So Right above the database icon on the left sidebar. You're gonna see this thing with F Those are all the variables that are around. Those are all the objects Kind of like I think RStudio always had that MATLAB always had that so like that pain is definitely there No, but a data source is special Because what you can do is you can go there and one thing you could do is you could hit the plus icon so if you hover over the data frame itself and no, yeah, and then hit plus you can add the table to the notebook and so like You can immediately get like a view Started and in the case of the data frame that we made ourselves is not that relevant But and that is the plus I can you just hit and you can also add a data source as in Oh, I've got a database of lots of tables or I've got a patchy iceberg or something like that So if you now go back to the to the panel and you hit the plus icon on top Then you can add a connection to whatever Thing where your data is Redshift got added this week, by the way, so we tend to add a lot of these things now
So one thing you could do for example just for fun, let's have sequel light if you go to the top I think we have a sequel light thing. Yeah, let's just add a random database path. I Think sequel lights dot DB Well, it doesn't exist. It will just make an empty file. I think so that that's that's usually why I see. Yeah. Okay, okay So TV that's what yeah test to be the sequel light I think is a standard Or dot DBI doesn't that's the name of a file No, it generates the code to generates the code. But the main thing that's important is that variable engine? So it's going to detect that that's a sequel alchemy Type of variable and now if you run that cell It detects that we need sequel alchemy. Yeah worries Yep. Okay, and then you can close that with pain, but you do see there's a database that's now been added and
You can also see that there's no tables in it But what you can do is like if you had a large database with lots of tables You can you can still do the plus icon and get like tables moved in very quickly
You can also talk sequel to these tables if you wanted to But the real cherry on top here if you go to the to this left sidebar one more time You're gonna see that there's a little robot icon. So it's kind of in the middle. Yeah chat with AI
So you need to edit AI settings here, which we're not gonna do Once you've once you've configured your keys and all of that What you can do is you can write at and then name of data frame or name of data source And then we will add the schema information to the prompt for you So you can do things like oh, I want to have this table I want you to generate the sequel for this table that does this and then
Chat TPT or whatever LLM you've got is going to be made aware of like, okay And that table has these columns with these types. Here's examples of it that are going to help it write the right query for you
Wow It can also generate the Altair and Polar's stuff for you, by the way, but this is why I want to emphasize We are got we are working on extra features for like good prompt engineering within this notebook as well
Schemas really matter also for like LLMs basically, so that's also why You want to be aware of the data frames that you've got and it's also why marimo has like a special case citizen situation for them
Wow, I must say Vincent, I'm Very impressed and also a little bit overwhelmed already
Resources and getting started with marimo
Now before we dive into The Quarto plug-in. Yeah, we should move to that. You've been creating before we go into that What are some good ways for people to find out more about marimo? If they want to get started with this
Revisit the different features that we've just discussed So I mean, I think this video is already a pretty good starting point. It's like we are going over all the Is there some documentation? Yeah. Yeah. So if you if you go to marimo.io, you're gonna see the big website
Few things and like this is a little bit of marketing material, right? But there's a docs page that you can go to on top. We also have a blog We also have a discord link up there if you're interested But this doc this doc really contains a whole lot. There's tons of examples. There's tons of guides There's even a guide for like hey, I'm used to Jupiter How do I like acquaint myself with marimo as quickly as possible without hitting my head too much Because you know a few things are definitely different
So like the docs are big is what I what I can say on that one Yeah, besides that some people like to watch videos instead of looking at docs all day So we've also got like a pretty big YouTube channel at this point We tend to release between 8 and 10 videos a week. Most of them are YouTube shorts like just clear on that
Ones that are relevant Yeah, so the thing that we do like we use the YouTube shorts to have like a daily It's the thing that's working out surprisingly well for us So we have so many features that like making a video that has all of them is gonna end up being super long So what we have with the shorts if you follow us on YouTube You're basically gonna get this one video a day of like a feature in marimo And half of those features will be new and the other half will just be stuff that people keep on asking us questions about So that can also be a nice way to get like a little trickle of oh, here's a feature Here's a feature without it being like overly overwhelming. Basically nice. We'll add a link in the description
How the Quarto plugin works under the hood
Okay, all right, so we're gonna move to the quarto thing there's one thing I want to mention Before getting there that's important to understand perhaps Could you go to a github repository But github repository is going to help explain what we're doing on the quarto side of thing because we're doing something as a bit unconventional
One no one that I've got in my mind, so could you go to github slash coning, which is my Coning with ko a n ing. That's my username and then slash and I think mo talk would be a good one Mo mo talk. Yeah
Right, right try we're gonna do something so this contains a widget that you can use in marimo But the thing that's interesting here is not so much the code. It's actually the github pages. Could you go there?
Because let's for a moment observe that we are running marimo here and there's a demo of a Widget by the way, which you can actually just for fun. Could could you use it? Could you hit the start listening button and then start talking?
Hey, we're recording a video about quarto a marimo. Oh, yeah, you have to start listening. Oh, yeah, of course. I just Hey there. How's it going? We're just recording a video here. I think yeah, so I think it's not Yeah, so I think it's not working because we're talking over zoom. Okay, it doesn't matter doesn't matter. We'll we'll try it out After the video, yeah, and also you're using Vivaldi instead of Chrome I think that might also not be because I'm using a browser But the fact that we're recording might be interfering here. Yeah, I think it's definitely the zoom thing. Anyway, so
The transcript would appear there and this widget would also expose what you're saying as a string in Python like that Just like what we saw with the draw data. You can talk string. It's basically what's happening here Wow
Streaming in a streaming fashion or once I get up once I press stop listening well, I need to add settings for that, but the way it works is You trigger it it starts listening, but the web API does notice like okay the guy stopped talking at this point So I'm gonna stop writing and then if you start talking again, it's gonna assume it's a new conversation Mm-hmm, but it's mainly meant for you to be able to dictate
But all that stuff is possible well one thing I want to mention notice how we are on get up pages Yes, so no Python back end. There's no server run There's no all everything is happening in the front end. That's kind of the interesting thing So we have this thing called pie died that allows you to run Python in the front end basically and you know It's a it's a it's a heavy thing to run in the front end You wouldn't put this up on every website But the fact that we can host marimo notebooks statically without having to having you to demand that you install anything Also means that for a lot of plugins that I write I can just host that on get up pages And if this mechanism of running marimo with Python inside a pie died that we also use for the quarter plug-in so the whole the whole idea here is that we do have this way for us to run Python in the front end and
Marimo allows you to still have the reactive nature of it appear, but that's Like there are constraints there because not every Python package Let's say you've got one that uses rust but isn't compiled doesn't compile to pie died that won't work You're also not going to run pie torch or anything like that because there's a it's actually a two gigabyte Upper limit of how big the memory allocation to be for pie died apps So there's definitely constraints, but if you want to do interactive stuff on your blog Let's say and you're not interested in doing any JavaScript whatsoever. This is a path towards that
so we wrote a couple of plugins to make this easy to add this to your docs, but Quarto is also using the same mechanism. So that's what the plug-in does under the hood We're basically leveraging the wasm engine to make sure that you can also run Python cells on your blog effectively, right? There are lots of moving parts here to make this all work
We're basically leveraging the wasm engine to make sure that you can also run Python cells on your blog effectively, right?
buttery smooth Yes, yeah, and I can I can imagine it's a bit overwhelming But I do want to put this nature of hey you're able to run this on a static page that is important to appreciate because if you ever were to hit like an install bug on Quarto and You weren't aware of the fact that oh, it's pie died Some packages won't work actually like that is gonna get you into a gnarly world of hurt if you're not aware
Good to know Good to know. All right, so you're saying that this is the technology that makes the Quarto plug-in possible. Yes How about we now yeah, yeah, yeah, let's actually dive into the Quarto plug-in I'm very excited I'm already overwhelmed with all the features that Marimo offers, but I Guess we can do one more and that is this Quarto plug-in, right? Yes. So tell me what do I need to do to? Let's let's go to your terminal
Installing the Quarto plugin
And I'm gonna leverage your your Quarto knowledge on this one so we can close down the the notebook And we don't necessarily need it anymore. All right, I'm gonna stop here to Kind of stop the Marimo server. Yeah
Cool, and let's make a new folder just to keep it clean as well. So we're not doing anything with this Let's just do call it demo. I think that will be fine
Let's start a new Quarto project. I think you might notice better than I do the command for that is something like Quarto new Quarto create. Oh create. That's the one right here. Very good Yes, let's run that one. Let's start a new blog
It's always a good place to start some directory some title that is always good Name we can open up into that. We can open it up. We don't have to
There we go and What we're gonna do now is we are gonna just look at this and say like, okay This is a normal Quarto project. And in this case, we're gonna make a change to one of the posts So if you go to the posts folder, right, there's like we can pick either one But yeah, let's let's say that's the one that we are going to want to make a change to
So, how about we preview this before we actually? Exactly. They can just think along the same lines as well. We have a terminal in yeah, we let's use this Yeah, and I guess there's also I see this preview button over here Yeah, that's running Quarto preview under the hood. Yeah. Okay. That's actually kind of nice So this is the okay. This is actually kind of a nice way to work. So that's great we have a post with code thing that renders there automatically and we're gonna make some changes here, but We want to add marimo stuff to it Which means that we do have to install the plug-in to get started with
All right, and that and that we do have to do from the terminal I think Yeah, so this terminal is There's of course the terminal inside positron and I could add additional terminals over here But I'm gonna I'm gonna switch back to my own. Yeah, sure. Yeah. Yeah, and
Then I think wasn't a quarto install like this again. This is what your memory might be better than mine I can know the computer's memory. Let's leverage that one Quarto works install. Oh, yeah extension marimo dash team quarto Dash Quarto-marimo. Yes. Yeah, this is pointing to a get a repository marimo dash team is the name of our organization and quarter dash marimo Is the name of the repository that contains the plug-in in there? Yeah, we trust authors. Yeah, you're sure. Yeah, I do Yeah, I do it. Yeah, I do. It's a shout out to Dylan by the way He's the main author of this work. He definitely did most of the work on this one
Yeah, this all looks good. We don't watch the documentation. But okay, like we installed the plug-in now the next thing we got to do is make That one page we want to edit aware of a new filter I think is what it's called in quarter land so and they're yeah in the filters and then Yeah, marimo dash team slash It was a quarter dash marimo
Yeah, so it's the same thing as what we just installed. I would assume it So our docs I'm looking at the docs page right now and it shows something different But let's try this see if it doesn't work. We know how to change it
Adding an interactive slider to a Quarto post
But let's let's now add a slider here And basically just like we had before in the because we're interested in showing off the interactive bit So let's add a slider. So a new Python cell will be appropriate here So I think three backticks and then Python curly brackets dot marimo
Yeah, and I think so it has to be not quarto dash marimo But marimo because that's curly bracket marimo stuff. That is a filter that we're using and The name of the filter is marimo. Therefore the filter we got to declare in the Foot. Yeah, it needs to be also dead just marimo. I think that's the reason. All right
Yeah, so long as you don't have any without any error, so We can also just saw it install some packages for this. So this looks like it's working Of course, we don't yet see anything on the right
But we're going to change that's not a surprise. So let's import marimo as mo just like before
Yep, and then let's do the slider thing. So mo dot UI dot slider 1 comma 10 comma 1 Yep Doesn't time that to a variable as well as and show the variable at the end and then if you now save this it should show
Cool okay, and then That looks good and now we can add some text there. So something like look ma a slider or something something witty
Yep, very good and then we can have a new Python cell down below over there and it also uses the marimo filter That then shows the value of X you have to add You have to add the marimo again, right? Because otherwise marimo doesn't pick up on this cell or I would I would assume so Yeah Because again like marimo needs to be aware of all the cells that we have in order to know in what order they have to Run, right?
Ah, yes, but you're multiplying a slider here to use the value. Yeah. Yeah. Yeah. Yeah, that's a good one to remember
And now if you scroll around Yep, there you go So nice iodized stuff is happening in the front end here Like what we could do to make this and I think that's like a good final demo to make people aware like what we could Theoretically do now is show you the scatter widget That's the thing that we could also import here if we want to do something fancy. So let's make a radical practical
Normally this is how you would declare a Python cell, right? This is something that yeah post prompt picks up on right it becomes interactive now.
I'm just curious what the syntax will be in this case with that in order to also turn this into a marimo cell. Oh, I mean I don't oh I would have to know more about I I mean we can try it doesn't necessarily hurt to try but like
So the thing with so positron at this point right and this is where you have to be kind of careful so positron at some point is saying Oh Python cell gotta run Python. Oh and if I want to run a Python, I'm not using WebAssembly Python. No, I'm going to use local Python something you know, so there's a split. There's a split brain right there. Yes. Yeah. No, you're absolutely right and so what we're doing right here is we're using regular markdown cells, yes, so they're not interactive or being run by Quarto, but they will be by Quarto by marimo if you have this is a good that is a really good comment because that can cause a lot of confusion because especially if you're used to like the normal way of writing Python in Quarto that is actually substantially different again because of the whole wasm thing
Yeah the beauty of Quarto done right is because this is that this can still be exported to a variety of formats right be it HTML page or a PDF. PDF doesn't really make sense because there's no interactivity yes, that's the main thing like the marimo stuff that we're offering is if you want to use the reactive items we only got some static things, right? if that's the thing you're interested in you could do static stuff but the real benefit and power comes from the ability to wire together widgets and having the whole reactive experience which doesn't really translate well into PDFs or word documents or stuff like that. Yeah
the real benefit and power comes from the ability to wire together widgets and having the whole reactive experience which doesn't really translate well into PDFs or word documents or stuff like that.
All right, so we're gonna forget about these kind of cells and we're going to stick through the regular markdown kind of cells
Scatter widget right? Yeah, so from draw data import scatter widget Oh
And you gotta wrap it with mo dot UI dot any widget, yeah like this and also yeah, and then show the variable. Yeah, let's run this now just to confirm what this looks like because I think you're gonna see something right, so it doesn't detect the module. Oh, that's a bummer. But then if we wait it loads so what's happening here is is actually installing it live and there will be a bit of delay like it has to actually be installing it right now we don't have a nice way to offer a pyodide environment that comes with a predefined virtual environment just the way that we like so this is installing it live so you will have that little bit of lag if you're gonna depend on other packages that is good to be aware of
Yeah, yeah, yeah we might find a nice way to fix that by the way, like it is sort of in the back of our minds it's just that right now. This is the easiest way to get this to work. Yeah, exactly. Yeah, we'd be cool if you could create a create a virtual environment or a virtual machine because that's basically what's what this is, right? can we can we treat this conceptually like? like a docker container
Not really well, so like docker container would have access to a file system and a network and like it's able to make you know so you are able to write Python code that's able to make requests but you can't launch a server for example, because you cannot open up a port so in that so be yeah, our analogy holds except for the fact that it's actually not the docker container it's it's not a perfect analogy, but uh, right it's as if you're starting with a clean docker image that just has the operating system, but no other packages installed and that's something that you would have to do every time
Well, it's actually a bit more subtle. So it's actually not an operating system. It's the front end so it's an operating system of sorts, but it's wasm, right? so there are a couple of API's at your disposal, but you if you do we want to give access to your file system from a browser? no, no, no, that's not no that's not what I'm saying it's more mostly like I mean, I guess I was kind of hoping that's what you were hinting at is that you can pre-bake yeah, so we cannot pre-bake the packages. Yeah, I think that's I wouldn't not be surprised that people are working on that but my impression right now at least is that that is something that is not on the table and it does get complex as well if you consider that some packages have Python code that needs to be built at runtime and other packages have stuff that's pre compiled but only for certain versions like you get into a messy territory quite quickly and the short story is we don't have UV for wasm just yet
It's cold we could do what is it complaining about? another directory, but help there's probably some some API and point it's expecting or something that where is this error coming from? Is it coming from? positron or is it coming from no, it's taking a health endpoint, right? So it's I've never seen this before I'm gonna blame marimo. I don't know. So you could oh, right. Yeah, so marimo does usually ping for a health endpoint we'll also make a note of that it's probably because it does feel like as requests that we are making. Mm-hmm
Showing the marimo data frame
Okay could be one thing that is I think good to show maybe at the end over here is if we can make like one final cell that shows the marimo data frame that might be fun so what we could do is we could do something like have a new cell as W data as pandas in this case
pandas well, so data that there has to be an answer so I think Polars would also work the there's a thing though that okay. There's a bit of a technical thing. I talked to Richie about it so Polars depends on a couple of libraries. I believe Tokio is one of them and that well, it's one of those upstream libraries doesn't compile to wasm at the moment so it's an upstream thing there is some light support for Polars inside of wasm pyodide for marimo at the moment but it's behind like 10 versions at this point so you're gonna be forced to use an old version of Polars that still has the old compilation that works and you're not able to sort of use the latest and greatest stuff pandas will just use all the numpy things and should also work. Yeah. Yeah again like wasm is a different beast and installing pandas takes a bit more time
but oh and yeah, you've not drawn data yet. So let's do that as well yeah, but it's complaining about pandas I was oh it it took a bit longer because pandas is a bigger because you have to install numpy which is you know megabytes so that takes a bit longer. Yeah, I just want to that should work. I wouldn't be surprised if it works, but the one thing that's gonna be I'm careful with advertising for it. Like I love Polars I want more people to use it but the unfortunate thing is that if you are on the Polars docs and you see a new method and then you go oh, I want to use that in wasm marimo and then the method doesn't work because because wasm that demands that you use an old version of Polars. It becomes kind of a hard story to pitch so for now, I still recommend people to use pandas if they are interested in doing this sort of thing in the wasm side
All right all right it does work you can do and you can also do chart stuff from here, right? you can build Altair charts. You can add sliders to the mix. So like you're pretty flexible and stuff that you can do and which includes like the any widgets this is one any widget but I've made it well, we'll do marketing around that next week but I've made it a widget now that also allows you to I know I don't take data with a gamepad that is also something that just totally works instead of marimo and it will also work on your blog now like that's you can get gamepad things to work on your blog quite easily with these things
That's fantastic so just to make this crystal clear is that we're looking at a static HTML file. Yes, right so yes, I can open this in the browser again takes a moment for things to come back to get to be imported but it's static. I can have this on my Quarto blog yep, you can send it. It'll just work they don't they won't have to install anything and also again like there's a download button on that data frame thing so like if you could theoretically put your own authentication in front of this just see this as an artifact that you deploy somewhere and s3 and put authentication in front of it and then I've got these library. I've got these GitHub packages that are basically like a cron job and they just generate a new wasm thing like this every day like for my solar panels on my house. I download new weather information and every day there's like a new marimo wasm generated thing that just allows me to look at the predictions and it tells me when to turn on the dishwasher like that's a little demo. I've got for example, and you can do that with this too. Nice
but it's static. I can have this on my Quarto blog yep, you can send it. It'll just work they don't they won't have to install anything.
very nice now okay, so I guess the order of cells what does that matter matter? I mean, let's try it. Let's try it. I think it shouldn't matter but let's try it cuz the important marimo thing we let's move that to the bottom and yeah, so that you got a slide is also going to move to the bottom now, yeah and save it like the slider will move obviously, right? Mm-hmm but the slider is there and the rest is now also showing up and that scatter widget needs marimo the library to be around that is around. So there you go the order doesn't matter same thing. It's like the same story
Yeah, and if we again if we go back to my browser and it would reload this one same story yeah, same story. Yeah
Yeah, wow, this is this is great stuff yeah, and like like the one thing we haven't shown but it is something that because you can also combine as of Quarto in some way. So right now for example, we're not showing the code, right? you could also do this echo is true thing inside of like if you wanted to show the person who's reading this like oh, this is the code you need to run like you can it like it also lends itself nicely for like okay, this is part of the tutorial. This isn't so like that sort of thing is also quite easy to declare
Right, I think it has it doesn't have to be capital true could this also work? okay, like I remember from like the R days. It always had to be capitals but those are R markdown documents about R markdown. Yeah distant past how many is not that distant? I still I still use RStudio. Now. I think it's a cool. It's a cool tool GG plot definitely is it definitely is but but Quarto, you know definitely superseded R markdown. Yeah, I know like positrons the way forward. I'm aware no, well positrons as well. But nope, but I meant Quarto. Oh and that's R markdown. Yeah that's true the the QA the QMD is definitely more general in it and if I'm not mistaken I think the fast AI people they're like all over this as well, right? like they they use this Quarto all over the place on their blogs and like I think fast AI the course nowadays as well is fully in Quarto if I'm not mistaken. Yeah. Yeah
all the Python packages that posit creates are Quarto websites yeah, yeah R packages as well. I think right. No, that's for most I would say that they use pkgdown we grow their own things. Okay, which has been around for a bit longer similar some more ideas do you remember this still the distill blog that RStudio used to have I don't actually my blog was actually a distill blog for like a really long time but then but then they started moving sort of a bit away from the still a little bit more towards Quarto and at some point I decided to write my own thing, but I I actually used the Quarto predecessor for like two years
Good stuff. Give me R markdown or yeah, so my blog was fully R markdown like also the Python stuff was just a lot of markdown documents. Yeah, my my book data science at the command line entirely which is available online entirely lends itself very well for books too. Yeah true. Yeah
Wrapping up
But nowadays there's Quarto and then there is a marimo plug-in and I think I think that you've given us a really good overview of not just the plug-in but also marimo itself if I could if I could plug like one final thing and also like one more yeah, I have to wrap up. I know no, but
now so like the one thing that is also going to be really cool for blogs and I do think it's also kind of like if I think about the future of data science I do think it's going to be a bit more in this direction could you go to Google and like type there's a GitHub repository on my end it's called wiggly stuff so github.com slash koaning slash wiggly stuff all right, let me see if I can get this koaning koaning wigglystuff. Yeah
so this like I have many packages that offer a widget and I also have this one package is like a collection of widgets basically and if you go to the GitHub pages on this thing you're actually going to see a pretty good impression of just the kinds of widgets that exist and a lot of these widgets are super relevant for I'm working in a notebook. I need to do something clever but they're also super relevant for blogs and the first thing you're looking at right now like that's a 2d slider so you can move that peg around and you can see the chart update depending on where that peg is you're simulating different data. All right yes, great the gray one is that the previous one or is that a separate class the original one that's the original one and it's mainly there to show that like oh, it started at the center and now it's no longer at the center it uses Altair. Yeah uses Altair under the hood again. You can see the reactive thing. So thing updates other thing responds
Below there's a different weird little widget. This one's the matrix thing So you can't have a matrix where you can click and drag and then also have charts that sort of move around
That's nice. Another fun thing. We've got tangle objects below as well. It's also like a fancy little demo. So objects Yeah, so that's a Brett Victor thing So you can have sliders, but why not hide them in plain sight in your markdown? so everything that's blue there you can click and drag and Then once you let go the text will update and you can also mix and match that with charts So if you scroll down you can also see like oh by the way There's this thing called Ambel's law and if you change one of the percentages the line will update as well. That's crazy
Stuff like this will also work on your blog and you can also make presentations differently and this whole idea of oh We've got widgets at our disposal and we have that as a first-class citizen in a notebook I'm not trying to Suggest that what we should think about is. Oh, we have a we're upgrading our notebook The thing that I would really like to upgrade is your imagination So there was an old way of thinking about notebooks where code would run and we'd have charts interactively and that's like super great But we're gonna go to a world pretty soon where the widgets that are being generated can be generated on the fly thanks to LLMs and can also on the fly interact with your Python code and back again and Something about that is going to be the future but you need to be mentally aware that you have to get a little bit more creative in order to benefit most from it and
Yes, like for sure all of these things are like super cool to have on blogs and Quarto is a great plug-in and Definitely celebrate that But the real feeling that you should have when you expose yourself to this is like oh I can rethink the way I work a little Bit just because of this reactivity and that that I think is more something that people should Try to focus on it's not just ooh shiny widget. It's Oh new shiny widget allows me to work differently that that's I think the most important aspect I think
It's Oh new shiny widget allows me to work differently that that's I think the most important aspect I think
Work differently and learn differently because I am I mean When So, I mean there have been situations where I looked at an equation and I'm like What is going on? But if I were to turn that equation into code and make it interactive and then visualize the output That to me and I've seen others do this others do this as well is that then you can Get us, you know a grasp of of how things work together within that equation, right? You can there's something about the ability to play that makes it much easier to grok Like if you if you make it more fun and more easy to sort of play around with an idea It becomes much easier to acquaint yourself with it But it's definitely a theory that I've got when it comes to learning. Yeah, and these things totally helps
Like the the matrix widget that you see like I'm actually making a sort of a small video course in linear algebra and I think having these widgets were actually able to sort of Click and drag around the matrix is gonna be freaking helpful Definitely. I can remember the times that I was trying to come up with a covariance matrix myself and then visualize it in MATLAB and then figure out that it didn't work and this this was I Mean this was a long time ago, but this is definitely I mean when you want to understand, okay What does the covariance matrix do? this having something like this, you know being interactive definitely helps there and Especially when you're when you're writing a blog that's more educational Having these interactive things are Very nice very helpful
Widgets, the future of data science, and closing thoughts
Indeed so so these widgets that's kind of the thing that the joke I like to make at the office I have a colleague who started the any widget project and the joke I like to make is he built any widget so that Vincent can Make the widgets like I think I've got almost more widget that's widgets than he does now But I'm really big on these widgets. So if people have a good idea for a widget that needs to be out there But isn't yet ping me on socials I will gladly consider making them because I do think a lot of the future for data science is with this stuff
Yeah, and then combined with using a gamepad The the possibilities are endless yeah, I might see like like You would definitely be like looking for the limits of response times in the marimo notebook But like can we play doom in marimo like that is a question that you can maybe start I will eventually I will sort of figure that out, but not yet I I was just thinking like data science is just gonna converge to game design it's We're all we all stick to it secretly want to design games That's what we actually want and we package it up as you know You wrote a book this one time data science from the command line like I want to do data science from the PlayStation It's just to see how that might go. Yeah. Yeah. Yeah, I Would be up for that
Yeah, this is marimo Thanks for having me We are definitely also interested in adding a like a little bit of extra support for the Quarto plug-in So if there's any feedback definitely let us know The feedback so far has been great. And yeah, it's it's definitely exciting for us Also, see like more people blog using these marimo widgets. So we're really really looking forward to what people do with it
Yeah, it's been this has been fantastic Like I said, it's a lot to take in but we're gonna make sure that everything that we've mentioned And there is there is a resource available to learn more about this And of course and how to get started in the first place because that is the best way to learn about this is to Open up marimo yourself We'll make sure that all the links are in the description
Vincent thank you so much for showing us marimo and the Quarto plug-in. It's it's been a pleasure Done. Yeah, fantastic all the way from the Netherlands All the way from Ireland It's like a train ride away from me, but thank you so much My pleasure. Have a good one. Yeah, you too. Bye. Bye
