Skip to content

Commit

Permalink
Merge pull request voxel51#3771 from voxel51/merge-main
Browse files Browse the repository at this point in the history
Merge main to develop
  • Loading branch information
benjaminpkane authored Nov 5, 2023
2 parents a72a432 + 14dfe52 commit 48b050b
Show file tree
Hide file tree
Showing 54 changed files with 684 additions and 465 deletions.
74 changes: 30 additions & 44 deletions .github/workflows/build-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux-aarch64
- linux-i686
- linux-x86_64
- mac-arm64
- mac-x86_64
- win-32
- win-amd64
- sdist
- darwin-arm64
- darwin-x86_64
- windows-32
- windows-x86_64
steps:
- name: Clone fiftyone
uses: actions/checkout@v4
Expand All @@ -40,48 +38,36 @@ jobs:
if [[ $RELEASE_TAG =~ ^refs\/tags\/db-v.*-rc\..*$ ]]; then
echo "RELEASE_VERSION=$(echo "${{ github.ref }}" | sed "s/^refs\/tags\/db-v//")" >> $GITHUB_ENV
fi
- name: Build wheel
run: |
cd package/db
python setup.py bdist_wheel --plat-name ${{ matrix.platform }}
- name: Build wheel (macOS Arm64)
if: ${{ matrix.platform == 'mac-arm64' }}
- name: Build Darwin arm64 wheel
if: ${{ matrix.platform == 'darwin-arm64' }}
run: |
cd package/db
python setup.py bdist_wheel --plat-name mac-arm64
- name: Build wheel (Ubuntu 22.04 x86_64)
if: ${{ matrix.platform == 'linux-x86_64' }}
env:
FIFTYONE_DB_BUILD_LINUX_DISTRO: ubuntu2204
FODB_MACHINE=arm64 FODB_SYSTEM=Darwin python setup.py bdist_wheel
- name: Build Darwin x86_64 wheel
if: ${{ matrix.platform == 'darwin-x86_64' }}
run: |
cd package/db
python setup.py bdist_wheel --plat-name linux-x86_64
- name: Build wheel (Ubuntu 20.04 x86_64)
if: ${{ matrix.platform == 'linux-x86_64' }}
env:
FIFTYONE_DB_BUILD_LINUX_DISTRO: ubuntu2004
FODB_MACHINE=x86_64 FODB_SYSTEM=Darwin python setup.py bdist_wheel
- name: Build Windows 32 wheel
if: ${{ matrix.platform == 'windows-32' }}
run: |
cd package/db
python setup.py bdist_wheel --plat-name linux-x86_64
- name: Build wheel (Debian 9 x86_64)
if: ${{ matrix.platform == 'linux-x86_64' }}
env:
FIFTYONE_DB_BUILD_LINUX_DISTRO: debian9
FODB_MACHINE=32 FODB_SYSTEM=Windows python setup.py bdist_wheel
- name: Build Windows x86_64 wheel
if: ${{ matrix.platform == 'windows-x86_64' }}
run: |
cd package/db
python setup.py bdist_wheel --plat-name linux-x86_64
- name: Build wheel (RHEL/CentOS 7 x86_64)
if: ${{ matrix.platform == 'linux-x86_64' }}
env:
FIFTYONE_DB_BUILD_LINUX_DISTRO: rhel7
FODB_MACHINE=x86_64 FODB_SYSTEM=Windows python setup.py bdist_wheel
- name: Build sdist
if: ${{ matrix.platform == 'sdist' }}
run: |
cd package/db
python setup.py bdist_wheel --plat-name linux-x86_64
- name: Upload wheel(s)
python setup.py sdist
- name: Upload
uses: actions/upload-artifact@v3
with:
name: wheel-${{ matrix.platform }}
path: package/db/dist/*.whl
name: dist-${{ matrix.platform }}
path: package/db/dist/*

test:
runs-on: ubuntu-20.04
Expand All @@ -91,14 +77,14 @@ jobs:
steps:
- name: Clone fiftyone
uses: actions/checkout@v4
- name: Download fiftyone-db wheel
- name: Download fiftyone-db
uses: actions/download-artifact@v3
with:
name: wheel-linux-x86_64
name: dist-sdist
path: downloads
- name: Install fiftyone-db
run: |
pip3 install downloads/fiftyone_db-*.whl
pip3 install downloads/fiftyone_db-*.tar.gz
- name: Install test dependencies
run: |
pip3 install pytest
Expand All @@ -108,11 +94,11 @@ jobs:
python3 -m pytest --verbose tests/
publish:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: [build, test]
if: startsWith(github.ref, 'refs/tags/db-v')
steps:
- name: Download wheels
- name: Download
uses: actions/download-artifact@v3
with:
path: downloads
Expand All @@ -130,4 +116,4 @@ jobs:
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
run: |
python -m twine upload downloads/wheel-*/*.whl
python -m twine upload downloads/dist-*/*
1 change: 1 addition & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ on:
pull_request:
branches:
- develop
- main
- rel-*
- release-*
- release/*
Expand Down
1 change: 1 addition & 0 deletions app/packages/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta charset="UTF-8" />
<meta name="description" content="Explore, Analyze, Curate" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="referrer" content="no-referrer" />
<title>FiftyOne</title>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion app/packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"react": "18.1.0",
"react-dom": "18.1.0",
"react-error-boundary": "^3.1.4",
"react-ga": "^3.1.2",
"react-ga4": "^2.1.0",
"react-hotkeys": "^2.0.0",
"react-input-autosize": "^3.0.0",
"react-is": "^17.0.1",
Expand Down
27 changes: 12 additions & 15 deletions app/packages/app/src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { isElectron } from "@fiftyone/utilities";
import { DarkMode, LightMode } from "@mui/icons-material";
import { useColorScheme } from "@mui/material";
import { AnimatePresence, motion } from "framer-motion";
import { default as React, Suspense, useEffect, useMemo } from "react";
import React, { Suspense, useEffect, useMemo } from "react";
import ReactDOM from "react-dom";
import ReactGA from "react-ga";
import ReactGA from "react-ga4";
import { useFragment, usePaginationFragment } from "react-relay";
import { useDebounce } from "react-use";
import { useRecoilState, useRecoilValue } from "recoil";
import { graphql } from "relay-runtime";
import ga from "../ga";
import gaConfig from "../ga";
import DatasetSelector from "./DatasetSelector";
import Teams from "./Teams";
import { NavDatasets$key } from "./__generated__/NavDatasets.graphql";
Expand Down Expand Up @@ -87,24 +87,21 @@ export const useGA = (fragment: NavGA$key) => {
}
const dev = info.dev;
const buildType = dev ? "dev" : "prod";

ReactGA.initialize(ga.app_ids[buildType], {
debug: false,
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
},
});
ReactGA.set({
userId: info.uid,
checkProtocolTask: null, // disable check, allow file:// URLs
[ga.dimensions.dev]: buildType,
[ga.dimensions.version]: `${info.version}`,
[ga.dimensions.context]: info.context + (isElectron() ? "-DESKTOP" : ""),
});
ReactGA.pageview("/");
}, [info]);
}, []);
};

const Nav: React.FC<{
Expand Down
4 changes: 2 additions & 2 deletions app/packages/app/src/ga.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
app_ids: {
prod: "UA-141773487-6",
dev: "UA-141773487-7",
prod: "G-NT3FLN0QHF",
dev: "G-7TMZEFFWB7",
},
dimensions: {
dev: "dimension1",
Expand Down
4 changes: 4 additions & 0 deletions app/packages/core/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ const InteractiveSidebar = ({
entry.kind !== fos.EntryKind.INPUT
);

if (after === undefined) {
return lastOrder.current;
}

if (after === null) {
return [
...section,
Expand Down
3 changes: 3 additions & 0 deletions app/packages/operators/src/OperatorCore.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import OperatorBrowser from "./OperatorBrowser";
import OperatorInvocationRequestExecutor from "./OperatorInvocationRequestExecutor";
import OperatorPrompt, { OperatorViewModal } from "./OperatorPrompt";
import { useOperatorPlacementsResolver } from "./hooks";

export default function OperatorCore() {
useOperatorPlacementsResolver();

return (
<>
<OperatorBrowser />
Expand Down
38 changes: 38 additions & 0 deletions app/packages/operators/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useEffect, useRef, useState } from "react";
import { useRecoilValue, useSetRecoilState } from "recoil";
import { isEqual } from "lodash";
import {
ExecutionContext,
fetchRemotePlacements,
resolveLocalPlacements,
} from "./operators";
import { operatorPlacementsAtom, operatorThrottledContext } from "./state";

export function useOperatorPlacementsResolver() {
const context = useRecoilValue(operatorThrottledContext);
const setOperatorPlacementsAtom = useSetRecoilState(operatorPlacementsAtom);
const [resolving, setResolving] = useState(false);
const lastContext = useRef(null);

useEffect(() => {
async function updateOperatorPlacementsAtom() {
setResolving(true);
try {
const ctx = new ExecutionContext({}, context);
const remotePlacements = await fetchRemotePlacements(ctx);
const localPlacements = await resolveLocalPlacements(ctx);
const placements = [...remotePlacements, ...localPlacements];
setOperatorPlacementsAtom(placements);
} catch (error) {
console.error(error);
}
setResolving(false);
}
if (!isEqual(lastContext.current, context) && context?.datasetName) {
lastContext.current = context;
updateOperatorPlacementsAtom();
}
}, [context, setOperatorPlacementsAtom]);

return { resolving };
}
54 changes: 34 additions & 20 deletions app/packages/operators/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import {
InvocationRequestQueue,
OperatorResult,
executeOperatorWithContext,
fetchRemotePlacements,
getInvocationRequestQueue,
getLocalOrRemoteOperator,
listLocalAndRemoteOperators,
resolveLocalPlacements,
} from "./operators";
import { Places } from "./types";
import { ValidationContext } from "./validation";
Expand Down Expand Up @@ -83,8 +81,16 @@ const globalContextSelector = selector({
const extended = get(fos.extendedStages);
const filters = get(fos.filters);
const selectedSamples = get(fos.selectedSamples);
const selectedLabels = get(fos.selectedLabels);

return { datasetName, view, extended, filters, selectedSamples };
return {
datasetName,
view,
extended,
filters,
selectedSamples,
selectedLabels,
};
},
});

Expand Down Expand Up @@ -635,7 +641,6 @@ export function useOperatorExecutor(uri, handlers: any = {}) {
const [isDelegated, setIsDelegated] = useState(false);

const [needsOutput, setNeedsOutput] = useState(false);
const selectedSamples = useRecoilValue(fos.selectedSamples);
const ctx = useExecutionContext(uri);
const hooks = operator.useHooks(ctx);

Expand Down Expand Up @@ -760,23 +765,17 @@ export const operatorThrottledContext = atom({
default: {},
});

export const operatorPlacementsSelector = selector({
key: "operatorPlacementsSelector",
get: async ({ get }) => {
const throttledContext = get(operatorThrottledContext);
const ctx = new ExecutionContext({}, throttledContext);
const remotePlacements = await fetchRemotePlacements(ctx);
const localPlacements = await resolveLocalPlacements(ctx);
return [...remotePlacements, ...localPlacements];
},
export const operatorPlacementsAtom = atom({
key: "operatorPlacementsAtom",
default: [],
});

export const placementsForPlaceSelector = selectorFamily({
key: "operatorsForPlaceSelector",
get:
(place: Places) =>
({ get }) => {
const placements = get(operatorPlacementsSelector);
const placements = get(operatorPlacementsAtom);
return placements
.filter(
(p) => p.placement.place === place && p.operator?.config?.canExecute
Expand All @@ -785,17 +784,23 @@ export const placementsForPlaceSelector = selectorFamily({
},
});

export function useOperatorPlacements(place: Place) {
export function useOperatorPlacements(place: Places) {
const datasetName = useRecoilValue(fos.datasetName);
const view = useRecoilValue(fos.view);
const extendedStages = useRecoilValue(fos.extendedStages);
const filters = useRecoilValue(fos.filters);
const selectedSamples = useRecoilValue(fos.selectedSamples);
const selectedLabels = useRecoilValue(fos.selectedLabels);
const setContext = useSetRecoilState(operatorThrottledContext);
const setThrottledContext = useCallback(
debounce(setContext, RESOLVE_PLACEMENTS_TTL, { leading: true }),
[]
);
const setThrottledContext = useMemo(() => {
return debounce(
(context) => {
setContext(context);
},
RESOLVE_PLACEMENTS_TTL,
{ leading: true }
);
}, [setContext]);

useEffect(() => {
setThrottledContext({
Expand All @@ -804,8 +809,17 @@ export function useOperatorPlacements(place: Place) {
extendedStages,
filters,
selectedSamples,
selectedLabels,
});
}, [datasetName, view, extendedStages, filters, selectedSamples]);
}, [
setThrottledContext,
datasetName,
view,
extendedStages,
filters,
selectedSamples,
selectedLabels,
]);

const placements = useRecoilValue(placementsForPlaceSelector(place));

Expand Down
Loading

0 comments on commit 48b050b

Please sign in to comment.