Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something like iPython profile_default/startup? #1149

Open
astrowonk opened this issue Apr 17, 2024 · 4 comments
Open

Something like iPython profile_default/startup? #1149

astrowonk opened this issue Apr 17, 2024 · 4 comments

Comments

@astrowonk
Copy link

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

@astrowonk astrowonk changed the title Something like profile_default/startup? Something like ipyton profile_default/startup? Apr 17, 2024
@astrowonk astrowonk changed the title Something like ipyton profile_default/startup? Something like iPyton profile_default/startup? Apr 17, 2024
@astrowonk astrowonk changed the title Something like iPyton profile_default/startup? Something like iPython profile_default/startup? Apr 17, 2024
@akshayka
Copy link
Contributor

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?

@astrowonk
Copy link
Author

astrowonk commented Apr 17, 2024

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)

@dmadisetti
Copy link
Contributor

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?

@akshayka
Copy link
Contributor

akshayka commented May 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants