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

Python Panels #4528

Open
wants to merge 144 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
07737bf
add panel state built in operators
ritch Apr 1, 2024
04c3d44
current panel and operations utils
ritch Apr 1, 2024
8b3bda2
register panel operator
ritch Apr 1, 2024
369dc3c
register panel op
ritch Apr 2, 2024
d99055d
panel state refactor
ritch Apr 2, 2024
20ca72c
improve operator prompts
ritch Apr 5, 2024
fafd001
python panel improvements
ritch Apr 5, 2024
43444a7
python panel cleanup
ritch Apr 17, 2024
e76b387
property change handlers
ritch Apr 25, 2024
e87a5b0
python panel syntactic sugar
ritch Apr 25, 2024
b8bb4f8
fix python panel layout and add loading state
imanjra Apr 14, 2024
33a5fcb
persist python panel on app reload
imanjra Apr 14, 2024
8d7e3ac
add GridView with layout customization
imanjra Apr 22, 2024
b8f6333
operator callback and handle panel onload error
imanjra Apr 22, 2024
c061ff6
rename VirtualPanel PanelRef
ritch Apr 30, 2024
04d0fa3
Merge remote-tracking branch 'origin/py-panels-develop' into py-panel…
ritch Apr 30, 2024
443ff0b
fix merge
ritch Apr 30, 2024
1ac64fb
add ctx.prompt
ritch Apr 30, 2024
d1ba8fb
fix ctx.prompt panel_state
ritch Apr 30, 2024
22839c7
add explicit plot events
ritch Apr 30, 2024
fb03c5b
Merge pull request #4321 from voxel51/py-panels-syntax-and-events
ritch Apr 30, 2024
599225c
remove logs
ritch Apr 30, 2024
79285df
Merge pull request #4332 from voxel51/ctx-prompt
ritch May 1, 2024
975c602
heatmap on click
ritch May 2, 2024
de23850
notify operator
ritch May 2, 2024
1e08693
fix panel state merge
ritch May 3, 2024
00ff4ba
Merge pull request #4343 from voxel51/heatmap-on-click
ritch May 3, 2024
d9c5e65
Merge pull request #4344 from voxel51/notify-op
ritch May 3, 2024
331d107
Merge remote-tracking branch 'origin/develop' into py-panels-develop
ritch May 3, 2024
5a097ea
add plot util
ritch May 6, 2024
84c8ff4
remove stray logs
ritch May 6, 2024
676f127
plot util doc string
ritch May 6, 2024
5f49925
Merge pull request #4361 from voxel51/plot-util
ritch May 6, 2024
3465d19
persist python panel state in session
imanjra May 6, 2024
1d987b3
invoke python panel on load on external state changes
imanjra May 6, 2024
8900d15
move data and panel schema to local state
imanjra May 6, 2024
e52c5c1
fix duplicate PANEL_LOAD_TIMEOUT
ritch May 8, 2024
8a5dd01
add results to prompt success
ritch May 9, 2024
0f2b2ec
add ctx change panel events
ritch May 9, 2024
df6b469
add all ctx change panel event
ritch May 9, 2024
33a3131
add MuiIconFont component
imanjra May 8, 2024
e8762ee
add IconButtonView to operators
imanjra May 8, 2024
aa459fd
python panel icon support
imanjra May 8, 2024
e3c972a
IconButtonView fixes and enhancements
imanjra May 9, 2024
ade432b
Merge pull request #4376 from voxel51/prompt-success-callback
ritch May 9, 2024
1d634f5
Merge pull request #4377 from voxel51/panel-ctx-callbacks
ritch May 10, 2024
5ba14e1
plot on_selected panel event
ritch May 10, 2024
db4dcd8
Merge pull request #4385 from voxel51/plot-on-selected
ritch May 21, 2024
4d35f9e
fix panel state changes
ritch May 22, 2024
198b5b4
Merge pull request #4408 from voxel51/fix-panel-prop-change
ritch May 22, 2024
3e0f984
fix missing panel id
ritch May 22, 2024
61bcf45
add set extended selection op
ritch May 22, 2024
77d9939
Merge pull request #4409 from voxel51/fix-panel-id
ritch May 22, 2024
ca5c7a7
py panels embeddings extended selection
ritch May 23, 2024
46cb107
add ctx.extended_selection and change event
ritch May 23, 2024
85c0a7a
add panel state deep get and set methods
ritch May 23, 2024
f207751
Merge pull request #4413 from voxel51/ctx-extended-selection
ritch May 23, 2024
c926bc3
Merge pull request #4412 from voxel51/py-panels-ex-selection
ritch May 23, 2024
e21cd5c
remove panel.data getter
ritch May 23, 2024
4fa01ea
Merge branch 'py-panels-develop' into panel-state-utils
ritch May 23, 2024
9610ad1
Merge pull request #4414 from voxel51/panel-state-utils
ritch May 23, 2024
9d27c31
panel.py tests
ritch May 23, 2024
753e22b
fix panel test
ritch May 23, 2024
09ddb30
Merge pull request #4418 from voxel51/py-panel-tests
ritch May 23, 2024
ce7caa1
css grid based GridView
imanjra May 13, 2024
adb1b0b
show panel render error
imanjra May 1, 2024
111b349
remove plotly view internal selected points state
ritch Jun 4, 2024
b663c13
add new layout views
ritch Jun 4, 2024
e54b1b1
Merge pull request #4451 from voxel51/btn-group-view
ritch Jun 4, 2024
98c0b7c
add media player
ritch Jun 4, 2024
4189742
Merge pull request #4333 from voxel51/bugfix/show-render-err
ritch Jun 5, 2024
d0c2fe4
Merge pull request #4454 from voxel51/react-player
ritch Jun 5, 2024
947ee9f
Merge pull request #4450 from voxel51/remove-plotly-view-selection-state
ritch Jun 5, 2024
c9ba1b0
Merge remote-tracking branch 'origin/develop' into py-panels-develop
ritch Jun 7, 2024
6349001
fix operator uri resolution
ritch Jun 7, 2024
7cdb3e7
Merge pull request #4470 from voxel51/py-panels-develop-syncd
ritch Jun 10, 2024
ff948e5
add space to btn()
ritch Jun 11, 2024
695a682
fix missing py dep
ritch Jun 11, 2024
c99e559
fix executeOperator options
imanjra Jun 10, 2024
7ed1786
scrollable add panel popout
imanjra Jun 10, 2024
141ecb3
fix python panel state persistence on app reload
imanjra Jun 11, 2024
689f284
enhancements for ButtonView and IconButtonView
imanjra Jun 11, 2024
06d28b5
add active fields op
ritch Jun 11, 2024
3bc44cb
Merge pull request #4482 from voxel51/active-paths-op
ritch Jun 11, 2024
e6409a0
event tracker
ritch Jun 13, 2024
0d28c2b
add error tracking
ritch Jun 13, 2024
2167a12
only track anonymous params or param names
ritch Jun 13, 2024
b4737d9
fix ctx.panel.close operation
imanjra Jun 12, 2024
7e1f22f
add ctx.panel.set_title operation
imanjra Jun 12, 2024
128ca5d
PlotlyView visual tweaks
imanjra Jun 13, 2024
c664250
add force option to open_panel operation
imanjra Jun 13, 2024
35ed40d
refactor analytics
ritch Jun 13, 2024
8093092
debounce spaces updates to session
imanjra May 7, 2024
5bbe262
finalize segment int
ritch Jun 13, 2024
b0050fa
fix track_event op
ritch Jun 13, 2024
4ce0cb4
Merge remote-tracking branch 'origin/py-panels-develop' into segment-int
ritch Jun 13, 2024
86cb626
refactor analytics take 2
ritch Jun 14, 2024
381a400
stray logs
ritch Jun 14, 2024
5e77e74
python error tracking
ritch Jun 14, 2024
167e011
stray logs
ritch Jun 14, 2024
2901f41
Merge pull request #4489 from voxel51/segment-int
ritch Jun 14, 2024
47ce163
move event tracker to Dataset
ritch Jun 14, 2024
fccbb0e
Merge remote-tracking branch 'origin/py-panels-develop' into segment-int
ritch Jun 14, 2024
2637445
improve analytics debugging
ritch Jun 14, 2024
4808ed1
viewbar tracking
ritch Jun 14, 2024
3c2962d
operator browser open event
ritch Jun 14, 2024
e21ea2c
saved view tracking
ritch Jun 14, 2024
79c5f28
Merge pull request #4495 from voxel51/analytics-follow-ups
ritch Jun 14, 2024
98b9041
fix ctx event race condition
ritch Jun 14, 2024
d9e6637
Merge pull request #4498 from voxel51/fix-ctx-ev-rc
ritch Jun 14, 2024
0d662c3
add force_duplicate param for open_panel operation
imanjra Jun 14, 2024
3d2f501
fix markdown spacing
ritch Jun 15, 2024
f1affd5
Merge pull request #4502 from voxel51/markdown-spacing
ritch Jun 15, 2024
5ed49ce
Merge pull request #4501 from voxel51/open_panel_force_duplicate
ritch Jun 17, 2024
1bc0563
Merge remote-tracking branch 'origin/develop' into py-panels-develop
ritch Jun 19, 2024
4cb1724
fix resolve output for operators in app
imanjra Jun 20, 2024
b6955c9
fix missing python panel load error trace
imanjra Jun 20, 2024
3e3b533
overridable panel not found component
imanjra Jun 21, 2024
d4276cd
initial python panel e2e test
imanjra Apr 15, 2024
effc006
fix grid based views
imanjra Jun 21, 2024
19da5f6
Merge remote-tracking branch 'origin/develop' into py-panels-develop
ritch Jun 24, 2024
a2b1587
Merge pull request #4523 from voxel51/bugfix/grid-based-views
ritch Jun 24, 2024
52e81cf
Merge pull request #4514 from voxel51/bugfix/resolve-output
ritch Jun 24, 2024
ad00391
Merge pull request #4516 from voxel51/bugfix/py-panel-load-error
ritch Jun 24, 2024
2eb5d95
Merge pull request #4364 from voxel51/bugfix/spaces-session-debounce
ritch Jun 24, 2024
57edf02
Merge pull request #4522 from voxel51/feat/panel-not-found
ritch Jun 24, 2024
fd59b0f
Merge pull request #4270 from voxel51/e2e/python-panel
ritch Jun 24, 2024
027ed03
event path
ritch Jun 27, 2024
e2d6679
Merge pull request #4540 from voxel51/plot-path-on-click
ritch Jul 9, 2024
280d3b2
operator ButtonView enhancements
imanjra Jul 3, 2024
3c09d52
add ArrowNavView for operator
imanjra Jul 3, 2024
fc1a7cd
add support for containerizing operators views
imanjra Jul 3, 2024
534063e
add overlay support for composite views of operators
imanjra Jul 4, 2024
5e1f1cf
enhance views to support displaying in menu-friendly style
imanjra Jul 4, 2024
463b727
fix notify operation variant
imanjra Jul 4, 2024
1f71557
switch some built-in operators from listed/unlisted
imanjra Jul 5, 2024
dc67397
visual tweaks for menu and views in menu
imanjra Jul 10, 2024
e678555
fix PlotlyView layout issue
imanjra Jul 11, 2024
68e64b3
make on_load optional for panel operator
imanjra Jul 17, 2024
0c85106
onChange support for all the views
imanjra Jul 17, 2024
5726176
operator views enhancements
imanjra Jul 17, 2024
9dcd204
enhancement for grid layout
imanjra Jul 11, 2024
95188e9
Analytics Consent (#4559)
benjaminpkane Jul 22, 2024
0595d8f
merge develop
benjaminpkane Jul 25, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- develop
- feat/*
- main
- py-panels-develop
- release/v[0-9]+.[0-9]+.[0-9]+

jobs:
Expand Down
5 changes: 4 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"devDependencies": {
"@testing-library/react": "latest",
"@testing-library/react-hooks": "latest",
"@types/react-plotly.js": "^2.6.3",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"@vitest/coverage-v8": "^0.34.6",
Expand Down Expand Up @@ -51,6 +52,8 @@
],
"packageManager": "yarn@3.2.1",
"dependencies": {
"jpeg-js": "^0.4.4"
"jpeg-js": "^0.4.4",
"react-player": "^2.16.0",
"react-plotly.js": "^2.6.0"
}
}
5 changes: 5 additions & 0 deletions app/packages/analytics/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"react-hooks/rules-of-hooks": "off"
}
}
11 changes: 11 additions & 0 deletions app/packages/analytics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store
build/**
node_modules/**

.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions

yarn-error.log
1 change: 1 addition & 0 deletions app/packages/analytics/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
28 changes: 28 additions & 0 deletions app/packages/analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# FiftyOne Analytics

FiftyOne Analytics package.

## Configuring Analytics

```typescript
const [info, setInfo] = useAnalyticsInfo();

setInfo({
writeKey: "<segment_write_key>",
userId: "123",
userGroup: "group1",
doNotTrack: false,
});
```

## Tracking Events from React

```typescript
function MyComponent() {
const trackEvent = useTrackEvent();

useEffect(() => {
trackEvent("my_component_loaded", { customProp: 42 });
}, []);
}
```
7 changes: 7 additions & 0 deletions app/packages/analytics/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* global module */
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
};
16 changes: 16 additions & 0 deletions app/packages/analytics/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@fiftyone/analytics",
"author": "Voxel51, Inc.",
"version": "0.0.0",
"description": "FiftyOne analytics",
"homepage": "https://github.com/voxel51/fiftyone/app/packages/analytics",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/voxel51/fiftyone/"
},
"main": "./src/index.ts",
"private": true,
"dependencies": {
"@segment/analytics-next": "^1.70.0"
}
}
6 changes: 6 additions & 0 deletions app/packages/analytics/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { default as useTrackEvent } from "./useTrackEvent";
export { default as usingAnalytics, Analytics } from "./usingAnalytics";
export { default as useAnalyticsInfo } from "./useAnalyticsInfo";
export { analyticsInfo } from "./state";
export { DEFAULT_WRITE_KEYS } from "./keys";
export type { AnalyticsInfo } from "./usingAnalytics";
4 changes: 4 additions & 0 deletions app/packages/analytics/src/keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const DEFAULT_WRITE_KEYS = {
dev: "MrAGfUuvQq2FOJIgAgbwgjMQgRNgruRa", // oss-dev
prod: "SjCRPH72QTHlVhFZIT5067V9rhuq80Dl", // oss-prod
};
7 changes: 7 additions & 0 deletions app/packages/analytics/src/state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { atom } from "recoil";
import { AnalyticsInfo } from "./usingAnalytics";

export const analyticsInfo = atom<AnalyticsInfo>({
key: "analyticsInfo",
default: null,
});
10 changes: 10 additions & 0 deletions app/packages/analytics/src/useAnalyticsInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useRecoilState } from "recoil";
import { analyticsInfo } from "./state";
import { AnalyticsInfo } from "./usingAnalytics";

export default function useAnalyticsInfo(): [
AnalyticsInfo,
(info: AnalyticsInfo) => void
] {
return useRecoilState<AnalyticsInfo>(analyticsInfo);
}
21 changes: 21 additions & 0 deletions app/packages/analytics/src/useTrackEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as fos from "@fiftyone/state";
import usingAnalytics, { AnalyticsInfo } from "./usingAnalytics";
import { useRecoilValue } from "recoil";
import { useCallback } from "react";
import { analyticsInfo } from "./state";

/**
* Track an event. This can be called from any component to track an event, however
* only when a user is opted in to analytics, will an event be sent to the analytics
* service.
*/
export default function useTrackEvent() {
const info = useRecoilValue<AnalyticsInfo>(analyticsInfo);
return useCallback(
(eventName: string, properties?: Record<string, any>) => {
const analytics = usingAnalytics(info);
analytics.trackEvent(eventName, properties);
},
[info]
);
}
86 changes: 86 additions & 0 deletions app/packages/analytics/src/usingAnalytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { AnalyticsBrowser } from "@segment/analytics-next";

export type AnalyticsInfo = {
writeKey: string;
userId: string;
userGroup: string;
doNotTrack?: boolean;
debug: boolean;
};

let _analytics: Analytics = null;

export default function usingAnalytics(info: AnalyticsInfo): Analytics {
if (!_analytics) {
_analytics = new Analytics();
}
if (info) {
_analytics.load(info);
}
return _analytics;
}

export class Analytics {
private _segment?: AnalyticsBrowser;
private _debug = false;
load(info: AnalyticsInfo) {
if (this._segment) return;
this._debug = info?.debug;
if (!info || info.doNotTrack) {
console.warn("Analytics disabled");
console.log(info);
this.disable();
return;
}
if (!info.writeKey) {
console.warn("Analytics disabled (no write key)");
this.disable();
return;
}
this.enable(info);
}

enable(info: AnalyticsInfo) {
this._segment = AnalyticsBrowser.load({
writeKey: info.writeKey,
});
if (info.userId) {
this.identify(info.userId);
}
if (info.userGroup) {
this.group(info.userGroup);
}
}

disable() {
this._segment = null;
}

page(name?: string, properties?: {}) {
if (!this._segment) return;
this._segment.page(name, properties);
}

track(name: string, properties?: {}) {
if (this._debug) {
console.log("track", name, properties);
}
if (!this._segment) return;
this._segment.track(name, properties);
}

trackEvent(name: string, properties?: {}) {
if (!this._segment) return;
this.track(name, properties);
}

identify(userId: string, traits?: {}) {
if (!this._segment) return;
this._segment.identify(userId, traits);
}

group(groupId: string, traits?: {}) {
if (!this._segment) return;
this._segment.group(groupId, traits);
}
}
26 changes: 26 additions & 0 deletions app/packages/analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"moduleResolution": "Node",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noImplicitAny": false,
"plugins": [],
"types": ["vite/client"],
"jsx": "react-jsx"
},
"include": ["./src"],
"references": [
{ "path": "../components" },
{ "path": "../looker" },
{ "path": "../flashlight" },
{ "path": "../utilities" }
]
}
18 changes: 18 additions & 0 deletions app/packages/analytics/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { UserConfig } from "vite";

export default <UserConfig>{
esbuild: true,
build: {
lib: {
entry: "src/index.ts",
formats: ["es"],
},
target: "es2015",
minify: false,
},
resolve: {
alias: {
"@fiftyone/looker": "@fiftyone/looker/src/index.ts",
},
},
};
1 change: 1 addition & 0 deletions app/packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"copy-to-desktop": "rm -rf ../desktop/dist/ && cp -r ./dist ../desktop/dist"
},
"dependencies": {
"@fiftyone/analytics": "*",
"@fiftyone/components": "*",
"@fiftyone/core": "*",
"@fiftyone/relay": "*",
Expand Down
46 changes: 46 additions & 0 deletions app/packages/app/src/components/Analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { isElectron } from "@fiftyone/utilities";
import React, { useCallback } from "react";
import ReactGA from "react-ga4";
import { graphql, useFragment } from "react-relay";
import gaConfig from "../ga";
import AnalyticsConsent from "./AnalyticsConsent";
import type { NavGA$data, NavGA$key } from "./__generated__/NavGA.graphql";

const useCallGA = (info: NavGA$data) => {
return useCallback(() => {
const dev = info.dev;
const buildType = dev ? "dev" : "prod";
ReactGA.initialize(gaConfig.app_ids[buildType], {
testMode: false,
gaOptions: {
storage: "none",
cookieDomain: "none",
clientId: info.uid,
page_location: "omitted",
page_path: "omitted",
kind: isElectron() ? "Desktop" : "Web",
version: info.version,
context: info.context,
checkProtocolTask: null, // disable check, allow file:// URLs
},
});
}, [info]);
};

export default function Analytics({ fragment }: { fragment: NavGA$key }) {
const info = useFragment(
graphql`
fragment Analytics on Query {
context
dev
doNotTrack
uid
version
}
`,
fragment
);
const callGA = useCallGA(info);

return <AnalyticsConsent callGA={callGA} info={info} />;
}
Loading
Loading