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

Working with external surrounding project deps (with sandbox?) #3008

Open
1 of 4 tasks
gabrielgrant opened this issue Nov 29, 2024 · 8 comments
Open
1 of 4 tasks

Working with external surrounding project deps (with sandbox?) #3008

gabrielgrant opened this issue Nov 29, 2024 · 8 comments
Labels
documentation Improvements or additions to documentation

Comments

@gabrielgrant
Copy link
Contributor

gabrielgrant commented Nov 29, 2024

Documentation is

  • Missing
  • Outdated
  • Confusing
  • Not sure?

Explain in Detail

We work with notebooks within a larger project. Marimo is ideal for this, since it doesn't cause the horrendous diffs we get from Jupyter.

The outer project is managed with poetry. We don't want marimo in the general project deps, and sometimes want additional tools in a notebook for testing/analysis that aren't in project deps. Not finding docs on a good workflow for this

So far been trying out the VSCode extension and pointing it at a separate python venv with marimo installed, then manually adding the project dir to the path within the notebook. This kinda works for simple things, but is fragile and doesn't have project-specific deps. Would be ideal if a workflow/solution would work with the VSCode extension, but not a requirement

Your Suggestion for Changes

It would be great to be able to have the project deps installed and then any notebook-specific deps layered on top all in a single sandbox. Not sure if that's achievable today? Maybe with uv directly? However it's best done, this general pattern of having some notebooks for doing exploratory work within a larger project repo seems like a common patter that it'd be great to see addressed in the docs

@gabrielgrant gabrielgrant added the documentation Improvements or additions to documentation label Nov 29, 2024
@gabrielgrant gabrielgrant changed the title Working with external deps (sandbox?) Working with external surrounding project deps (with sandbox?) Nov 29, 2024
@mscolnick
Copy link
Contributor

We don't currently don't support this today. Maybe there is some magic we could do with uv's dependency groups.

The best workaround today would be calling subprocess.run(['uv', 'pip', 'install', '-r', 'requirements.txt']) or specific deps.

Another option is maybe marimo can ship mo.install() (can be fancy to include user confirmation, etc) which would hook into your user-configured package manager.

@gabrielgrant
Copy link
Contributor Author

gabrielgrant commented Dec 12, 2024

got part way there with:

import subprocess
import shutil

poetry_bin = shutil.which('poetry')

poetry_export = subprocess.Popen(
  [poetry_bin, "export", "--without-hashes", "--with", "dev", "-f", "requirements.txt"],
  stdout=subprocess.PIPE,
  env={"POETRY_WARNINGS_EXPORT": "false"}
)

uv_bin = shutil.which('uv')

subprocess.run(
  [uv_bin, "pip", "install", "--no-deps", "-r", "/dev/stdin"],
  stdin=poetry_export.stdout,
  check=True,
)
poetry_export.stdout.close()
poetry_export.wait()

(based loosely on https://mil.ad/blog/2024/uv-poetry-install.html )

that seems to install the packages into the sandbox:

Resolved 269 packages in 1.34s
Prepared 266 packages in 32.33s
Uninstalled 12 packages in 56ms
Installed 267 packages in 346ms
 + aiohttp==3.9.5
...
 + zipp==3.21.0

but then fails with a bunch of marimo errors that seem to be related to reloading:

Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 758, in <module>
    class SupportsAbs(Protocol[T_co]):
                      ~~~~~~~~^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1874, in __class_getitem__
    return _GenericAlias(cls, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined

Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/__init__.py", line 27, in <module>
    from .exceptions import Abort as Abort
ImportError: cannot import name 'Abort' from 'click.exceptions' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/exceptions.py)
Fix with AI
[Search on Google](https://www.google.com/search?q=ImportError%3A%20cannot%20import%20name%20%27Abort%27%20from%20%27click.exceptions%27%20(%2Fhome%2Fgabriel%2F.cache%2Fuv%2Farchive-v0%2F5J61la12AYpwy5dgfoIpa%2Flib%2Fpython3.11%2Fsite-packages%2Fclick%2Fexceptions.py))
Error trying to reload module click: cannot import name 'Abort' from 'click.exceptions' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/exceptions.py) 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/abc/__init__.py", line 49, in <module>
    from .._core._tasks import CancelScope as CancelScope
ImportError: cannot import name 'CancelScope' from 'anyio._core._tasks' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/_core/_tasks.py)
Fix with AI
Search on Google
Error trying to reload module anyio.abc: cannot import name 'CancelScope' from 'anyio._core._tasks' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/_core/_tasks.py) 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/streams/tls.py", line 28, in <module>
    _PCTRTT = Tuple[Tuple[str, str], ...]
              ~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1677, in __getitem__
    return self.copy_with((*params, _TypingEllipsis))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
    return _GenericAlias(self.__origin__, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=ImportError%3A%20cannot%20import%20name%20%27CancelScope%27%20from%20%27anyio._core._tasks%27%20(%2Fhome%2Fgabriel%2F.cache%2Fuv%2Farchive-v0%2F5J61la12AYpwy5dgfoIpa%2Flib%2Fpython3.11%2Fsite-packages%2Fanyio%2F_core%2F_tasks.py))
Error trying to reload module anyio.streams.tls: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/formatting.py", line 12, in <module>
    def measure_table(rows: t.Iterable[t.Tuple[str, str]]) -> t.Tuple[int, ...]:
                            ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
    return self.copy_with(params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
    return _GenericAlias(self.__origin__, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module click.formatting: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/utils.py", line 103, in <module>
    class LazyFile:
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/utils.py", line 180, in LazyFile
    def __iter__(self) -> t.Iterator[t.AnyStr]:
                          ~~~~~~~~~~^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
    return self.copy_with(params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
    return _GenericAlias(self.__origin__, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module click.utils: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/jedi/api/refactoring/__init__.py", line 81, in <module>
    class Refactoring:
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/jedi/api/refactoring/__init__.py", line 87, in Refactoring
    def get_changed_files(self) -> Dict[Path, ChangedFile]:
                                   ~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
    return self.copy_with(params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
    return _GenericAlias(self.__origin__, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module jedi.api.refactoring: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/exceptions.py", line 15, in <module>
    param_hint: t.Optional[t.Union[t.Sequence[str], str]]
                           ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 502, in __getitem__
    return self._getitem(self, parameters)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 721, in Union
    return _UnionGenericAlias(self, parameters)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module click.exceptions: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 76, in <module>
    _version_cache: Dict[Tuple[int, int], Mapping[str, PathInfo]] = {}
                                          ~~~~~~~^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
    return self.copy_with(params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
    return _GenericAlias(self.__origin__, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module jedi.inference.gradual.typeshed: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/_core/_tasks.py", line 12, in <module>
    class _IgnoredTaskStatus(TaskStatus[object]):
                             ~~~~~~~~~~^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1874, in __class_getitem__
    return _GenericAlias(cls, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
Search on Google
Error trying to reload module anyio._core._tasks: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/itsdangerous/timed.py", line 26, in <module>
    class TimestampSigner(Signer):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/itsdangerous/timed.py", line 75, in TimestampSigner
    ) -> _t.Tuple[bytes, datetime]:
         ~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1680, in __getitem__
    return self.copy_with(params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
    return _GenericAlias(self.__origin__, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module itsdangerous.timed: name '_has_generic_or_protocol_as_origin' is not defined 
Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 621, in _exec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 758, in <module>
    class SupportsAbs(Protocol[T_co]):
                      ~~~~~~~~^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1874, in __class_getitem__
    return _GenericAlias(cls, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)

@mscolnick
Copy link
Contributor

@gabrielgrant - does it work if you turn off module reloading? Its on the footer, there is: on, lazy, off.
if thats fixes it, we can look into the module reload error

@gabrielgrant
Copy link
Contributor Author

the cell with the install code only shows the error the first time it is run after starting the kernel (after that it is just Audited 279 packages in 2.05s); the subsequent cell where i actually try to use a package seems to fail with the same error regardless of the auto-module-reload setting (same error as many of the above, though less clear whether it is actually coming from marimo this time?):

Traceback (most recent call last):
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/executor.py", line 157, in execute_cell
    exec(cell.body, glbls)
  Cell marimo://app/api/queue/notebooks/nutrient_estimation_tests_marimo.py#cell=cell-2, line 14, in <module>
    from app.util.testing.notebook_helpers import init_app
  File "/home/gabriel/repos/rxfood/MNT/app/util/testing/notebook_helpers.py", line 5, in <module>
    from google.cloud import storage
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/google/cloud/storage/__init__.py", line 35, in <module>
    from google.cloud.storage.batch import Batch
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/google/cloud/storage/batch.py", line 40, in <module>
    import requests
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/__init__.py", line 45, in <module>
    from .exceptions import RequestsDependencyWarning
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/exceptions.py", line 9, in <module>
    from .compat import JSONDecodeError as CompatJSONDecodeError
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/compat.py", line 30, in <module>
    chardet = _resolve_char_detection()
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/compat.py", line 24, in _resolve_char_detection
    chardet = importlib.import_module(lib)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/__init__.py", line 24, in <module>
    from .api import from_bytes, from_fp, from_path, normalize
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/api.py", line 10, in <module>
    from .cd import (
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/cd.py", line 9, in <module>
    from .md import is_suspiciously_successive_range
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/md.py", line 5, in <module>
    from .utils import (
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/utils.py", line 250, in <module>
    def identify_sig_or_bom(sequence: bytes) -> Tuple[Optional[str], bytes]:
                                                ~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1680, in __getitem__
    return self.copy_with(params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
    return _GenericAlias(self.__origin__, params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
    self.__parameters__ = _collect_parameters(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
    """
        
NameError: name '_has_generic_or_protocol_as_origin' is not defined

@gabrielgrant
Copy link
Contributor Author

gabrielgrant commented Dec 12, 2024

Oh, actually I misspoke: I had been re-launching the server in its entirety before (so recreating a new sandbox), not just restarting the kernel. Just restarting the kernel (with module change tracking turned off) actually does seem to work!

@gabrielgrant
Copy link
Contributor Author

gabrielgrant commented Dec 31, 2024

Unfortunately this workaround seems to no longer be working as of 0.10.9 (I believe it was still working on 0.10.5). Still looks like the uv install is working, output is the same ("Audited 279 packages in 2.43s") but seems the packages aren't actually being resolved when importing (even after kernel restart) and they're not showing in the marimo packages pane list (which i think they were before? not 100% sure about that)

A quick glance thru the release notes doesn't point to any obvious changes to dep handling that would have affected this. (the only one that seems maybe semi-relevant is #3291 , but only tangentially so). Any idea what might have changed?

@mscolnick
Copy link
Contributor

Could your uv have been upgraded? Do other versions work? You can run with uvx --with marimo==0.10.5 marimo edit

@gabrielgrant
Copy link
Contributor Author

Thanks for the follow-up. It seems the issue was related to a python upgrade

details

default had been updated in one branch of the parent repo but hadn't in another, so switching between was causing issues where the deps were being installed in the wrong place/by the wrong python. Didn't totally track down all the details of what was going wrong, but rebasing to stop the swapping between default py versions seems to have fixed it.

So the workaround install code i posted above is working again

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

No branches or pull requests

2 participants