MCPcopy
hub / github.com/marimo-team/marimo / _print_summary

Method _print_summary

marimo/_code_mode/_context.py:838–913  ·  view source on GitHub ↗

Print a human-readable summary of applied operations.

(
        self,
        ops: list[_Op],
        package_ops: list[_AddPackage | _RemovePackage],
        ui_updates: list[tuple[UIElementId, Any]],
        cells_to_run: set[CellId_t] | None = None,
    )

Source from the content-addressed store, hash-verified

836 # ------------------------------------------------------------------
837
838 def _print_summary(
839 self,
840 ops: list[_Op],
841 package_ops: list[_AddPackage | _RemovePackage],
842 ui_updates: list[tuple[UIElementId, Any]],
843 cells_to_run: set[CellId_t] | None = None,
844 ) -> None:
845 """Print a human-readable summary of applied operations."""
846 lines: list[str] = []
847
848 for pkg_op in package_ops:
849 if isinstance(pkg_op, _AddPackage):
850 lines.append(f"installed {pkg_op.package}")
851 else:
852 lines.append(f"uninstalled {pkg_op.package}")
853
854 _run = cells_to_run or set()
855 op_cell_ids: set[CellId_t] = set()
856 for op in ops:
857 cell_id = op.cell_id
858 op_cell_ids.add(cell_id)
859 label = self._cell_label(cell_id)
860 ran = cell_id in _run
861 errored = ran and self._cell_errored(cell_id)
862 if isinstance(op, _AddOp):
863 if errored:
864 verb = "created and ran"
865 suffix = " (error)"
866 elif ran:
867 verb = "created and ran"
868 suffix = ""
869 else:
870 verb = "created"
871 suffix = ""
872 lines.append(f"{verb} cell {label}{suffix}")
873 elif isinstance(op, _UpdateOp):
874 parts = []
875 if op.code is not None:
876 parts.append("code")
877 if op.config is not None:
878 parts.append("config")
879 detail = " and ".join(parts) if parts else "config"
880 if errored:
881 suffix = " and ran (error)"
882 elif ran:
883 suffix = " and ran"
884 else:
885 suffix = ""
886 lines.append(f"edited {detail} of cell {label}{suffix}")
887 elif isinstance(op, _DeleteOp):
888 lines.append(f"deleted cell {label}")
889 elif isinstance(op, _MoveOp):
890 lines.append(f"moved cell {label}")
891
892 # Report cells queued for execution that had no structural op.
893 if _run:
894 for cell_id in _run:
895 if cell_id not in op_cell_ids:

Callers 1

__aexit__Method · 0.95

Calls 6

_cell_labelMethod · 0.95
_cell_erroredMethod · 0.95
appendMethod · 0.45
addMethod · 0.45
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected