eugene
eugene•2w ago

How to distinguish marimo notebooks from any other python files robustly and efficiently?

If I want to get all marimo notebooks recursively inside a directory, what algorithm can be both robust and efficient?
4 Replies
Akshay
Akshay•2w ago
GitHub
marimo/marimo/_server/files/os_file_system.py at 9668948b34ca156a3e...
A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git. - marimo-team/marimo
eugene
eugeneOP•2w ago
I think this can't be a robust algorithm to test whether a python file is a marimo notebook. For example, run _is_marimo_file on this file exactly will return True 🤔
Myles Scolnick
Myles Scolnick•2w ago
There are more checks that could be done. It’s not perfect, but I think the downstream use case of it, it doesn’t need to be perfect
Akshay
Akshay•2w ago
We thought about saving marimo notebooks with a custom extension for this reason (.mo.py), but such files can't be imported by Python's import statement.