Skip to content

Commit

Permalink
fix: explicitly check for Cell type in primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
dmadisetti committed Dec 19, 2024
1 parent 5397513 commit 52581aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions marimo/_runtime/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ def sanitize_inputs(
except TypeError as e:
raise CloneError(
f"Could not clone reference `{ref}` of type "
f"{getattr(glbls[ref], '__module__', '<module>')}."
f"{glbls[ref].__class__.__name__}"
" try wrapping the object in a `zero_copy`"
f"{getattr(glbls[ref], '__module__', '<module>')}. "
f"{glbls[ref].__class__.__name__} "
"try wrapping the object in a `zero_copy` "
"call. If this is a common object type, consider "
"making an issue on the marimo GitHub "
"repository to never deepcopy."
Expand Down
4 changes: 4 additions & 0 deletions marimo/_runtime/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import TYPE_CHECKING, Any, Callable, Optional, Union

from marimo._ast.visitor import Name, VariableData
from marimo._ast.cell import Cell

if TYPE_CHECKING:
from marimo._runtime.dataflow import DirectedGraph
Expand Down Expand Up @@ -130,6 +131,9 @@ def is_instance_by_name(obj: object, name: str) -> bool:


def is_unclonable_type(obj: object) -> bool:
# Cell objects in particular are hidden by functools.wraps.
if isinstance(obj, Cell):
return True
return any([is_instance_by_name(obj, name) for name in UNCLONABLE_TYPES])


Expand Down

0 comments on commit 52581aa

Please sign in to comment.