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

Little bugs / Nix compatibility #992

Closed
1 of 2 tasks
dmadisetti opened this issue Mar 22, 2024 · 3 comments
Closed
1 of 2 tasks

Little bugs / Nix compatibility #992

dmadisetti opened this issue Mar 22, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@dmadisetti
Copy link
Contributor

dmadisetti commented Mar 22, 2024

Describe the bug

Just a few things using marimo under nix that seem to be broken, these are more general code health things- so not dedicated nix specific fixes.

Rest assured that if marimo works under the pathological env that is nix, it will probably work pretty much everywhere!

Environment

nixpkgs 0.3.4

Code to reproduce

  • marimo env crashes because pip is not guaranteed to be installed
    def _get_pip_list() -> dict[str, str]:
    allowlist = [
    "click",
    "importlib_resources",
    "jedi",
    "markdown",
    "pymdown-extensions",
    "pygments",
    "tomlkit",
    "uvicorn",
    "starlette",
    "websocket",
    "typing_extensions",
    "black",
    ]
    try:
    result = subprocess.run(
    [
    sys.executable,
    "-m",
    "pip",
    "list",
    "--format=json",
    "--disable-pip-version-check",
    ],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    )
    packages = json.loads(result.stdout)
    return {
    package["name"]: package["version"]
    for package in packages
    if package["name"] in allowlist
    }
    except FileNotFoundError:
    return {}

proposal, tell user that there's nothing you can do OR extract from import sys; sys.modules

relevant nix stack trace
  Traceback (most recent call last):
  File "/nix/store/nr79v4j901yhlz29pwklbpxgz54jxzpn-python3.11-marimo-0.3.4/bin/.marimo-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_cli/cli.py", line 475, in env
    print(json.dumps(get_system_info(), indent=2))
                     ^^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_cli/envinfo.py", line 28, in get_system_info
    requirements = _get_pip_list()
                   ^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_cli/envinfo.py", line 77, in _get_pip_list
    packages = json.loads(result.stdout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

  • Missing edit: Certain packages crash the kernel loop

image

blows up from invocation with the following stack trace
Process Process-1:
Traceback (most recent call last):
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/runtime.py", line 1364, in launch_kernel
    asyncio.run(control_loop())
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7wz6hm9i8wljz0hgwz1wqmn2zlbgavrq-python3-3.11.8/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/runtime.py", line 1358, in control_loop
    await kernel.handle_message(request)
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/runtime.py", line 1224, in handle_message
    await self.instantiate(request)
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/runtime.py", line 1166, in instantiate
    await self.run(request.execution_requests)
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/runtime.py", line 927, in run
    await self._run_cells(
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/runtime.py", line 671, in _run_cells
    while cells_with_stale_state := await self._run_cells_internal(
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/runtime.py", line 879, in _run_cells_internal
    for mod in self.module_registry.missing_modules()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/packages/module_registry.py", line 38, in missing_modules
    set(
  File "/nix/store/hza59ra675z8m5dc7kvms4j798h91i3f-python3-3.11.8-env/lib/python3.11/site-packages/marimo/_runtime/packages/module_registry.py", line 41, in <genexpr>
    if importlib.util.find_spec(mod) is None
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 114, in find_spec
ValueError: manim_slides.__spec__ is None

proposal, fail gracefully and / or display that it is a non-standard environment


That's all I've noticed. Still love the project!

@dmadisetti dmadisetti added the bug Something isn't working label Mar 22, 2024
@dmadisetti
Copy link
Contributor Author

dmadisetti commented Mar 22, 2024

Ohh, it's not the package management that's breaking the loop.
It's specifically manim_slides without the __spec__ attribute, nothing to do with my fake package "bleh"

The install package dialog shows after I remove the manim_slides line.

  • but attempting to install without uv rye pip does break the loop though

Restarting the kernel and things seem fine

@akshayka
Copy link
Contributor

Thanks for reporting these issues!

Missing edit: Certain packages crash the kernel loop

I can fix this.

but attempting to install without uv rye pip does break the loop though

Oops! I'm surprised actually. But I can look at this as well.

@dmadisetti
Copy link
Contributor Author

Closing issue since most of it is addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants