Ilya I. Lubenets
Ilya I. Lubenets
Explore posts from servers
Mmarimo
Created by Ilya I. Lubenets on 10/1/2024 in #help-support
how to disable “defined by another cell” error?
While experimenting and testing models - I usually reuse some variables from cell to cell. For example, when training models - I can set device variable to cuda for better coding experience. device = torch.device("cuda”) And when I want to use this model later in the same notebook and leave GPU for another processes, I’ll do: device = torch.device(“cpu”) But marimo forbids this type of operations! Same applies to situations with sklearn models, where I train models in cells reusing “model” variable. model = TypeOfModel() model.fit() Of course, it’s not clear or any close to production looking code, but this is what I want from notebooks - fast and simple “proof of concept” code. P.s. forgive me for code blocks here, mobile discord sucks
22 replies
Mmarimo
Created by Ilya I. Lubenets on 9/22/2024 in #help-support
How do I share marimo notebooks as files properly?
So, my situation is simple: 1. I've created a rye project and added some dependencies 2. I've created a some_notebook.marimo.py with using some of those dependencies I've installed 3. Now I want to share only a notebook, without all those rye complications 4. The person who will download and open my marimo nb should be able to easily install those dependencies The only reason why default marimo install helper is not working for me - because of some of the projects I use is available only from git+https://my-private-gitlab.com/... or self-hosted pypi alternatives (so there is a custom pypi index-url) With jupyter I can use %pip install inside nb and that solves my problem, but how to do it inside marimo nb without creating a project or installing deps outside of marimo?
15 replies
MModular
Created by Ilya I. Lubenets on 3/17/2024 in #questions
Kotlin's extension function in Mojo?
Not so long ago, I've discovered that Kotlin have a possibility to extend already defined classes with a new function. For example:
fun String.getWordsList(): List<String> {
return this.split(" ")
}

fun main() {
val text: String = "Hello world!"
val words = text.getWordsList()
println(words)
}
fun String.getWordsList(): List<String> {
return this.split(" ")
}

fun main() {
val text: String = "Hello world!"
val words = text.getWordsList()
println(words)
}
will return [Hello, world!] list. This feature is really useful, as it makes code really cleaner without overriding whole class. I don't asking Modular team to implement it. I'm just curious what others think about that. Is Mojo needs that or static methods is enough? I mean, we can use text.getWordsList() is Kotlin and get_words_list(text) in Mojo and Python. What is better for you?
9 replies