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

[WIP] refactor js operator runtime #4949

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/packages/core/src/components/Starter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useOperatorBrowser,
useOperatorExecutor,
usePromptOperatorInput,
} from "@fiftyone/operators/src/state";
} from "@fiftyone/operators/src/runtime";
import { datasetName as datasetNameAtom } from "@fiftyone/state";
import {
Button,
Expand Down Expand Up @@ -192,7 +192,9 @@ export function OperatorLauncher(props: OperatorLauncherPropsType) {

const handleClick = useCallback(() => {
if (prompt) {
promptForInput(uri);
promptForInput({
uriOrName: uri,
});
} else {
execute({});
}
Expand Down
6 changes: 4 additions & 2 deletions app/packages/operators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"main": "./src/index.ts",
"scripts": {
"dev": "vite"
"dev": "vite",
"test": "vitest"
},
"private": true,
"files": [
Expand All @@ -24,7 +25,8 @@
"jest": "^29.7.0",
"prettier": "2.2.1",
"typescript": "4.2.4",
"vite": "^5.2.14"
"vite": "^5.2.14",
"vitest": "^2.1.3"
},
"peerDependencies": {
"@mui/icons-material": "*",
Expand Down
4 changes: 2 additions & 2 deletions app/packages/operators/src/OperatorBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Close, Extension, Help, Lock } from "@mui/icons-material";
import { Link } from "@mui/material";
import { createPortal } from "react-dom";
import styled from "styled-components";
import { initializationErrors } from "./operators";
import { useOperatorBrowser } from "./state";
import { initializationErrors } from "./runtime/operators";
import { useOperatorBrowser } from "./runtime";

// todo: use plugin component
import { useTrackEvent } from "@fiftyone/analytics";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useMemo } from "react";
import {
useInvocationRequestExecutor,
useInvocationRequestQueue,
} from "./state";
} from "./runtime";
import { QueueItemStatus } from "./constants";

export default function OperatorInvocationRequestExecutor() {
Expand Down
6 changes: 3 additions & 3 deletions app/packages/operators/src/OperatorPlacements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { Extension } from "@mui/icons-material";
import styled from "styled-components";
import { types } from ".";
import OperatorIcon from "./OperatorIcon";
import { Operator } from "./operators";
import { Operator } from "./runtime/operators";
import {
useOperatorExecutor,
useOperatorPlacements,
usePromptOperatorInput,
} from "./state";
} from "./runtime";
import { Placement, Places } from "./types";

import { getStringAndNumberProps } from "@fiftyone/core/src/components/Actions/utils";
Expand Down Expand Up @@ -117,7 +117,7 @@ function ButtonPlacement(props: OperatorPlacementProps) {

const handleClick = () => {
if (prompt) {
promptForInput(uri);
promptForInput({ uriOrName: uri });
} else {
execute({});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createPortal } from "react-dom";
import OperatorIO from "../OperatorIO";
import OperatorPalette from "../OperatorPalette";
import { useShowOperatorIO } from "../state";
import { useShowOperatorIO } from "../runtime";
import { PaletteContentContainer } from "../styled-components";

export default function OperatorViewModal() {
Expand Down
2 changes: 1 addition & 1 deletion app/packages/operators/src/OperatorPrompt/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createPortal } from "react-dom";
import { useRecoilValue } from "recoil";
import { showOperatorPromptSelector, useOperatorPrompt } from "../state";
import { showOperatorPromptSelector, useOperatorPrompt } from "../runtime";
import { BaseStylesProvider } from "../styled-components";
import { OperatorPromptType } from "../types";
import OperatorModalPrompt from "./OperatorModalPrompt";
Expand Down
2 changes: 1 addition & 1 deletion app/packages/operators/src/Panel/register.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PluginComponentType, registerComponent } from "@fiftyone/plugins";
import { defineCustomPanel } from "../CustomPanel";
import OperatorIcon from "../OperatorIcon";
import { ExecutionContext } from "../operators";
import { ExecutionContext } from "../runtime/operators";

export default function registerPanel(ctx: ExecutionContext) {
registerComponent({
Expand Down
4 changes: 2 additions & 2 deletions app/packages/operators/src/built-in-operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
_registerBuiltInOperator,
executeOperator,
listLocalAndRemoteOperators,
} from "./operators";
import { useShowOperatorIO } from "./state";
} from "./runtime/operators";
import { useShowOperatorIO } from "./runtime";
import usePanelEvent from "./usePanelEvent";

//
Expand Down Expand Up @@ -812,7 +812,7 @@
unlisted: true,
});
}
useHooks(ctx: ExecutionContext): {} {

Check warning on line 815 in app/packages/operators/src/built-in-operators.ts

View workflow job for this annotation

GitHub Actions / lint / eslint

'ctx' is defined but never used. Allowed unused args must match /^_/u
return { updatePanelState: useUpdatePanelStatePartial() };
}
async execute(ctx: ExecutionContext): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions app/packages/operators/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
ExecutionContext,
fetchRemotePlacements,
resolveLocalPlacements,
} from "./operators";
} from "./runtime/operators";
import {
activePanelsEventCountAtom,
operatorPlacementsAtom,
operatorThrottledContext,
operatorsInitializedAtom,
useCurrentSample,
} from "./state";
} from "./runtime";

function useOperatorThrottledContextSetter() {
const datasetName = useRecoilValue(fos.datasetName);
Expand Down
5 changes: 2 additions & 3 deletions app/packages/operators/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ export {
ExecutionContext,
Operator,
OperatorConfig,
abortOperationsByExpression,
abortOperationsByURI,
executeOperator,
registerOperator,
} from "./operators";
} from "./runtime/operators";
export {
useGlobalExecutionContext,
useOperatorBrowser,
useOperatorExecutor,
useOperatorPlacements,
} from "./state";
} from "./runtime";
export * as types from "./types";
export { default as usePanelEvent } from "./usePanelEvent";
7 changes: 5 additions & 2 deletions app/packages/operators/src/loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import { useEffect, useState } from "react";
import { useRecoilValue, useSetRecoilState } from "recoil";
import { registerBuiltInOperators } from "./built-in-operators";
import { useOperatorPlacementsResolver } from "./hooks";
import { executeOperatorsForEvent, loadOperatorsFromServer } from "./operators";
import {
executeOperatorsForEvent,
loadOperatorsFromServer,
} from "./runtime/operators";
import {
availableOperatorsRefreshCount,
operatorsInitializedAtom,
} from "./state";
} from "./runtime";

let startupOperatorsExecuted = false;

Expand Down
Loading
Loading