A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix [6281]: Could not find function given request: FunctionCallReques… (#6365)
Max Koretskyie66a68a12521
diff --git a/frontend/src/plugins/core/registerReactComponent.tsx b/frontend/src/plugins/core/registerReactComponent.tsxindex 2075c42084..cb1f4d2f35 100644--- a/frontend/src/plugins/core/registerReactComponent.tsx+++ b/frontend/src/plugins/core/registerReactComponent.tsx@@ -1,4 +1,5 @@/* Copyright 2024 Marimo. All rights reserved. */+/* eslint-disable unicorn/prefer-spread *//*** WebComponent Factory for React Components@@ -21,16 +22,21 @@ import React, {import ReactDOM, { type Root } from "react-dom/client";import useEvent from "react-use-event-hook";import type { ZodSchema } from "zod";+import { notebookAtom } from "@/core/cells/cells.ts";+import { findCellId } from "@/core/cells/ids.ts";+import { isUninstantiated } from "@/core/cells/utils";import { createInputEvent, MarimoValueUpdateEvent } from "@/core/dom/events";import { getUIElementObjectId } from "@/core/dom/ui-element";import { UIElementRegistry } from "@/core/dom/uiregistry";import { FUNCTIONS_REGISTRY } from "@/core/functions/FunctionRegistry";+import { store } from "@/core/state/jotai";import {type HTMLElementNotDerivedFromRef,useEventListener,} from "@/hooks/useEventListener";import { StyleNamespace } from "@/theme/namespace";import { useTheme } from "@/theme/useTheme";+import { CellNotInitializedError } from "@/utils/errors.ts";import { Functions } from "@/utils/functions";import { shallowCompare } from "@/utils/shallow-compare";import { defineCustomElement } from "../../core/dom/defineCustomElement";@@ -78,6 +84,7 @@ interface PluginSlotProps<T> {}/* Handles synchronization of value on behalf of the component */+// eslint-disable-next-line react/function-component-definitionfunction PluginSlotInternal<T>({ hostElement, plugin, children, getInitialValue }: PluginSlotProps<T>,@@ -172,6 +179,27 @@ function PluginSlotInternal<T>();const objectId = getUIElementObjectId(hostElement);invariant(objectId, "Object ID should exist");++ const cellId = findCellId(hostElement);+ invariant(cellId, "Cell ID should exist");++ const notebookState = store.get(notebookAtom);+ const cellRuntime = notebookState.cellRuntime[cellId];+ const cellData = notebookState.cellData[cellId];++ const cellNotInitialized = isUninstantiated({+ executionTime:+ cellRuntime.runElapsedTimeMs ?? cellData.lastExecutionTime,+ status: cellRuntime.status,+ errored: cellRuntime.errored,+ interrupted: cellRuntime.interrupted,+ stopped: cellRuntime.stopped,+ });++ if (cellNotInitialized) {+ throw new CellNotInitializedError();+ }+const response = await FUNCTIONS_REGISTRY.request({args: prettyParse(input, args[0]),functionName: key,diff --git a/frontend/src/plugins/impl/FileBrowserPlugin.tsx b/frontend/src/plugins/impl/FileBrowserPlugin.tsxindex d1790a63d0..7c19dfe6dd 100644--- a/frontend/src/plugins/impl/FileBrowserPlugin.tsx+++ b/frontend/src/plugins/impl/FileBrowserPlugin.tsx@@ -158,6 +158,10 @@ export const FileBrowser = ({return null;}+ if (!data && error) {+ return <Banner kind="danger">{error.message}</Banner>;+ }+let { files } = data || {};if (files === undefined) {files = [];diff --git a/frontend/src/utils/errors.ts b/frontend/src/utils/errors.tsindex 698a7f9761..5789372605 100644--- a/frontend/src/utils/errors.ts+++ b/frontend/src/utils/errors.ts@@ -61,3 +61,12 @@ function safeJSONParse(message: string): unknown {return message;}}++export class CellNotInitializedError extends Error {+ constructor(+ message: string = "The cell containing this UI element has not been run yet. Please run the cell first.",+ ) {+ super(message);+ this.name = "CellNotInitializedError";+ }+}