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

Update marimo run instructions; introduce package dependency inlining through uv #14

Closed
wants to merge 3 commits into from

Conversation

Haleshot
Copy link

@Haleshot Haleshot commented Oct 8, 2024

Resolve #12

Copy link
Author

@Haleshot Haleshot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that a fair bit of return statements and mo.md commands have been changed; it seems this notebook was built with 0.5.0 and the latest release is 0.9.0; there have been changes made to marimo which are causing these changes. You can verify that notebook runs as intended.

@fletchapin
Copy link
Contributor

fletchapin commented Oct 11, 2024

I just reviewed the PR and I don't see any issues with the code. Launching the notebook the old way (marimo run lvof.py) works as expected. However, when I tested it I ran into an error:

(marimo-lvof) valuing-flexibility-from-water/marimonotebook$ uvx marimo run --sandbox lvof.py
Running in a sandbox: uv run --isolated --no-project --with-requirements /tmp/tmpo3d14tc5.txt marimo run lvof.py

        Running lvof.py ⚡

        URL: http://localhost:2725

Traceback (most recent call last):
  File "/home/fletch/.cache/uv/archive-v0/VDQ8DUT_h_Lhwd4Qnv8KP/lib/python3.12/site-packages/marimo/_runtime/executor.py", line 157, in execute_cell
    exec(cell.body, glbls)
  File "/tmp/marimo_3924777/__marimo__cell_vblA_.py", line 2, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

However, as I said the regular marimo run lvof.py command works, so clearly these dependencies are installed. To double check, this is the output of pip list:

(marimo-lvof) valuing-flexibility-from-water/marimonotebook$ pip list
Package            Version
------------------ ------------
anyio              4.6.0
asttokens          2.4.1
black              23.12.1
click              8.1.7
comm               0.2.1
contourpy          1.2.0
cycler             0.12.1
debugpy            1.8.0
decorator          5.1.1
docutils           0.21.2
exceptiongroup     1.2.0
executing          2.0.1
fonttools          4.47.2
h11                0.14.0
idna               3.10
importlib-metadata 7.0.1
ipykernel          6.29.0
ipython            8.20.0
itsdangerous       2.2.0
jedi               0.19.1
jupyter_client     8.6.0
jupyter_core       5.7.1
kiwisolver         1.4.5
marimo             0.9.1
Markdown           3.5.2
matplotlib         3.8.2
matplotlib-inline  0.1.6
mypy-extensions    1.0.0
nest_asyncio       1.5.9
numpy              1.26.3
packaging          23.2
pandas             2.1.4
parso              0.8.3
pathspec           0.12.1
pexpect            4.8.0
pickleshare        0.7.5
pillow             10.2.0
pip                23.3.2
platformdirs       4.1.0
prompt-toolkit     3.0.42
psutil             5.9.7
ptyprocess         0.7.0
pure-eval          0.2.2
Pygments           2.17.2
pymdown-extensions 10.7
pyparsing          3.1.1
python-dateutil    2.8.2
pytz               2023.3.post1
PyYAML             6.0.1
pyzmq              25.1.2
ruff               0.6.9
setuptools         69.0.3
six                1.16.0
sniffio            1.3.1
stack-data         0.6.2
starlette          0.39.2
tomlkit            0.12.3
tornado            6.3.3
traitlets          5.14.1
typing_extensions  4.9.0
tzdata             2023.4
uv                 0.4.20
uvicorn            0.31.1
wcwidth            0.2.13
websockets         12.0
wheel              0.42.0
zipp               3.17.0

I have no experience with uv, but it seems that is the source of this error. @Haleshot do you have an idea what might be going on here?

@fletchapin
Copy link
Contributor

As a note, all this is being done inside marimo-lvof conda environment. I updated the dependencies in environment.yml to marimo==0.9.1 and uv==0.4.20 and left the rest of the environment as it was.

@Haleshot
Copy link
Author

I just reviewed the PR and I don't see any issues with the code. Launching the notebook the old way (marimo run lvof.py) works as expected. However, when I tested it I ran into an error:

(marimo-lvof) valuing-flexibility-from-water/marimonotebook$ uvx marimo run --sandbox lvof.py
Running in a sandbox: uv run --isolated --no-project --with-requirements /tmp/tmpo3d14tc5.txt marimo run lvof.py

        Running lvof.py ⚡

        URL: http://localhost:2725

Traceback (most recent call last):
  File "/home/fletch/.cache/uv/archive-v0/VDQ8DUT_h_Lhwd4Qnv8KP/lib/python3.12/site-packages/marimo/_runtime/executor.py", line 157, in execute_cell
    exec(cell.body, glbls)
  File "/tmp/marimo_3924777/__marimo__cell_vblA_.py", line 2, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

I think the issue exists with running the uv command while the conda environment is activated? Can you try it without the conda environment activated? One of the main advantages of of using uvx (when uv is installed) is that marimo will automatically install its dependencies in an isolated virtual environment.

I just recreated the installation steps; created a new conda environment, activated it; used the conda env create -f environment.yml to install packages inside the new environment (ran into some resolvepackagenotfound issues) and ran the uvx marimo run --sandbox lvof.py after cd'ing to marimonotebook folder. It ran for me.

@fletchapin
Copy link
Contributor

Ah I see. I attempted to run pip install uv and then uvx marimo run --sandbox lvof.py in a fresh terminal, but I ran into a permissions error:

Screenshot 2024-10-14 at 3 56 33 PM

After some googling, it seems uv is not set up to work well with global Python installations that each use their own virtual environment: astral-sh/uv#2059

This is a common set up in academia, such as our lab server. Until this issue is fixed by uv (which it seems they don't view it as worthwhile, so that may be never) I don't think we'll be using it. That's unfortunate because it does seem like it could be useful for package management!

If you feel strongly we should use uv I'm happy to reconsider, but it just seems that if the installation is difficult for me it will cause lots of trouble to our novice users who are more accustomed to conda environments.

@fletchapin fletchapin closed this Oct 14, 2024
@Haleshot
Copy link
Author

Sure; understandable.

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

Successfully merging this pull request may close these issues.

Improve marimo notebook run commands
2 participants