marimo
marimo copied to clipboard
Something like iPython profile_default/startup?
Description
I guess this may be completely contrary to the spirit of marimo, but I really miss having things automatically run/imported the way jupyter runs the files in ~/.ipython/profile_default.
Suggested solution
If running some startup script is too obscure (i.e. someone else with the marimo file can't see this hidden set of imports, etc.), maybe there could be a templates or some way to have every new marimo notebook create a new cell based on some other .py file? (maybe even have this cell be hidden somehow if possible, but visible to version control.)
I have a lot of boilerplate code in my environment and I handle this usually with the ipython startup file, I'd rather not have to manually copy /paste it into every marimo notebook.
Alternative
No response
Additional context
No response
I have a lot of boilerplate code in my environment and I handle this usually with the ipython startup file, I'd rather not have to manually copy /paste it into every marimo notebook.
What kind of code is in your environment? Perhaps a naive question, but why can't you refactor this boilerplate code into a module or library that you import at the beginning of your notebook?
I have a lot of boilerplate code in my environment and I handle this usually with the ipython startup file, I'd rather not have to manually copy /paste it into every marimo notebook.
What kind of code is in your environment? Perhaps a naive question, but why can't you refactor this boilerplate code into a module or library that you import at the beginning of your notebook?
At work it's all sorts of things; database connections, basic things like import pandas as pd, creating instances of helper classes I made, etc.
Consolidating into one helper file / module and then importing might work? I'll test it out, but I don't think I can get an instance of a class by just importing? I think I need to run the file? (much like the startup in ipython)
You could define your imports in a function and then wrap it
from project import boilerplate
app = marimo.App()
app.cell(hide_code=True)(boilerplate)
and in boilerplate instantiate your classes etc. This might break on saving in the editor though?
I'm going to close this in favor of being explicit and importing a module/library at the top of your notebook. That helps with reproducibility/portability of notebooks too.