From 35dd58e273c64059ce0d708db36e85c8670ac520 Mon Sep 17 00:00:00 2001 From: Saurav Maheshkar Date: Sat, 29 Jul 2023 12:59:56 +0530 Subject: [PATCH 01/11] chore: move PR template to `.github/` dir --- pull_request_template.md => .github/pull_request_template.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pull_request_template.md => .github/pull_request_template.md (100%) diff --git a/pull_request_template.md b/.github/pull_request_template.md similarity index 100% rename from pull_request_template.md rename to .github/pull_request_template.md From 0d125bf3e43567f88adeec5a4f6494e7306912b6 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 1 Aug 2023 23:59:32 +1000 Subject: [PATCH 02/11] chore: delete nonfunctional `shell.nix` This was for v2.3 and is very broken. See `flake.nix`, thanks to @zopieux --- shell.nix | 162 ------------------------------------------------------ 1 file changed, 162 deletions(-) delete mode 100644 shell.nix diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 3de8c91b38..0000000000 --- a/shell.nix +++ /dev/null @@ -1,162 +0,0 @@ -{ pkgs ? import {} - , lib ? pkgs.lib - , stdenv ? pkgs.stdenv - , fetchurl ? pkgs.fetchurl - , runCommand ? pkgs.runCommand - , makeWrapper ? pkgs.makeWrapper - , mkShell ? pkgs.mkShell - , buildFHSUserEnv ? pkgs.buildFHSUserEnv - , frameworks ? pkgs.darwin.apple_sdk.frameworks -}: - -# Setup InvokeAI environment using nix -# Simple usage: -# nix-shell -# python3 scripts/preload_models.py -# python3 scripts/invoke.py -h - -let - conda-shell = { url, sha256, installPath, packages, shellHook }: - let - src = fetchurl { inherit url sha256; }; - libPath = lib.makeLibraryPath ([] ++ lib.optionals (stdenv.isLinux) [ pkgs.zlib ]); - condaArch = if stdenv.system == "aarch64-darwin" then "osx-arm64" else ""; - installer = - if stdenv.isDarwin then - runCommand "conda-install" { - nativeBuildInputs = [ makeWrapper ]; - } '' - mkdir -p $out/bin - cp ${src} $out/bin/miniconda-installer.sh - chmod +x $out/bin/miniconda-installer.sh - makeWrapper \ - $out/bin/miniconda-installer.sh \ - $out/bin/conda-install \ - --add-flags "-p ${installPath}" \ - --add-flags "-b" - '' - else if stdenv.isLinux then - runCommand "conda-install" { - nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ pkgs.zlib ]; - } - # on line 10, we have 'unset LD_LIBRARY_PATH' - # we have to comment it out however in a way that the number of bytes in the - # file does not change. So we replace the 'u' in the line with a '#' - # The reason is that the binary payload is encoded as number - # of bytes from the top of the installer script - # and unsetting the library path prevents the zlib library from being discovered - '' - mkdir -p $out/bin - sed 's/unset LD_LIBRARY_PATH/#nset LD_LIBRARY_PATH/' ${src} > $out/bin/miniconda-installer.sh - chmod +x $out/bin/miniconda-installer.sh - makeWrapper \ - $out/bin/miniconda-installer.sh \ - $out/bin/conda-install \ - --add-flags "-p ${installPath}" \ - --add-flags "-b" \ - --prefix "LD_LIBRARY_PATH" : "${libPath}" - '' - else {}; - - hook = '' - export CONDA_SUBDIR=${condaArch} - '' + shellHook; - - fhs = buildFHSUserEnv { - name = "conda-shell"; - targetPkgs = pkgs: [ stdenv.cc pkgs.git installer ] ++ packages; - profile = hook; - runScript = "bash"; - }; - - shell = mkShell { - shellHook = if stdenv.isDarwin then hook else "conda-shell; exit"; - packages = if stdenv.isDarwin then [ pkgs.git installer ] ++ packages else [ fhs ]; - }; - in shell; - - packages = with pkgs; [ - cmake - protobuf - libiconv - rustc - cargo - rustPlatform.bindgenHook - ]; - - env = { - aarch64-darwin = { - envFile = "environment-mac.yml"; - condaPath = (builtins.toString ./.) + "/.conda"; - ptrSize = "8"; - }; - x86_64-linux = { - envFile = "environment.yml"; - condaPath = (builtins.toString ./.) + "/.conda"; - ptrSize = "8"; - }; - }; - - envFile = env.${stdenv.system}.envFile; - installPath = env.${stdenv.system}.condaPath; - ptrSize = env.${stdenv.system}.ptrSize; - shellHook = '' - conda-install - - # tmpdir is too small in nix - export TMPDIR="${installPath}/tmp" - - # Add conda to PATH - export PATH="${installPath}/bin:$PATH" - - # Allows `conda activate` to work properly - source ${installPath}/etc/profile.d/conda.sh - - # Paths for gcc if compiling some C sources with pip - export NIX_CFLAGS_COMPILE="-I${installPath}/include -I$TMPDIR/include" - export NIX_CFLAGS_LINK="-L${installPath}/lib $BINDGEN_EXTRA_CLANG_ARGS" - - export PIP_EXISTS_ACTION=w - - # rust-onig fails (think it writes config.h to wrong location) - mkdir -p "$TMPDIR/include" - cat <<'EOF' > "$TMPDIR/include/config.h" - #define HAVE_PROTOTYPES 1 - #define STDC_HEADERS 1 - #define HAVE_STRING_H 1 - #define HAVE_STDARG_H 1 - #define HAVE_STDLIB_H 1 - #define HAVE_LIMITS_H 1 - #define HAVE_INTTYPES_H 1 - #define SIZEOF_INT 4 - #define SIZEOF_SHORT 2 - #define SIZEOF_LONG ${ptrSize} - #define SIZEOF_VOIDP ${ptrSize} - #define SIZEOF_LONG_LONG 8 - EOF - - conda env create -f "${envFile}" || conda env update --prune -f "${envFile}" - conda activate invokeai - ''; - - version = "4.12.0"; - conda = { - aarch64-darwin = { - shell = conda-shell { - inherit shellHook installPath; - url = "https://repo.anaconda.com/miniconda/Miniconda3-py39_${version}-MacOSX-arm64.sh"; - sha256 = "4bd112168cc33f8a4a60d3ef7e72b52a85972d588cd065be803eb21d73b625ef"; - packages = [ frameworks.Security ] ++ packages; - }; - }; - x86_64-linux = { - shell = conda-shell { - inherit shellHook installPath; - url = "https://repo.continuum.io/miniconda/Miniconda3-py39_${version}-Linux-x86_64.sh"; - sha256 = "78f39f9bae971ec1ae7969f0516017f2413f17796670f7040725dd83fcff5689"; - packages = with pkgs; [ libGL glib ] ++ packages; - }; - }; - }; -in conda.${stdenv.system}.shell From 0ba8a0ea6c4f874db22d91b3192f8c084f8a6fd2 Mon Sep 17 00:00:00 2001 From: Kevin Brack Date: Sun, 30 Jul 2023 13:05:29 -0500 Subject: [PATCH 03/11] Board assignment changing on click --- .../components/GallerySettingsPopover.tsx | 19 ++++++++++++++++--- .../features/gallery/store/gallerySlice.ts | 6 ++++++ .../web/src/features/gallery/store/types.ts | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx b/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx index 21a580d9a9..04cc98edb7 100644 --- a/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx @@ -8,6 +8,7 @@ import IAIPopover from 'common/components/IAIPopover'; import IAISimpleCheckbox from 'common/components/IAISimpleCheckbox'; import IAISlider from 'common/components/IAISlider'; import { + autoAssignBoardOnClickChanged, setGalleryImageMinimumWidth, shouldAutoSwitchChanged, } from 'features/gallery/store/gallerySlice'; @@ -19,11 +20,16 @@ import BoardAutoAddSelect from './Boards/BoardAutoAddSelect'; const selector = createSelector( [stateSelector], (state) => { - const { galleryImageMinimumWidth, shouldAutoSwitch } = state.gallery; + const { + galleryImageMinimumWidth, + shouldAutoSwitch, + autoAssignBoardOnClick, + } = state.gallery; return { galleryImageMinimumWidth, shouldAutoSwitch, + autoAssignBoardOnClick, }; }, defaultSelectorOptions @@ -33,7 +39,7 @@ const GallerySettingsPopover = () => { const dispatch = useAppDispatch(); const { t } = useTranslation(); - const { galleryImageMinimumWidth, shouldAutoSwitch } = + const { galleryImageMinimumWidth, shouldAutoSwitch, autoAssignBoardOnClick } = useAppSelector(selector); const handleChangeGalleryImageMinimumWidth = (v: number) => { @@ -69,7 +75,14 @@ const GallerySettingsPopover = () => { dispatch(shouldAutoSwitchChanged(e.target.checked)) } /> - + ) => + dispatch(autoAssignBoardOnClickChanged(e.target.checked)) + } + /> + {!autoAssignBoardOnClick && } ); diff --git a/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts b/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts index 5eabe5de26..851e1b6c3b 100644 --- a/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts +++ b/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts @@ -8,6 +8,7 @@ export const initialGalleryState: GalleryState = { selection: [], shouldAutoSwitch: true, autoAddBoardId: undefined, + autoAssignBoardOnClick: true, galleryImageMinimumWidth: 96, selectedBoardId: undefined, galleryView: 'images', @@ -66,9 +67,13 @@ export const gallerySlice = createSlice({ setGalleryImageMinimumWidth: (state, action: PayloadAction) => { state.galleryImageMinimumWidth = action.payload; }, + autoAssignBoardOnClickChanged: (state, action: PayloadAction) => { + state.autoAssignBoardOnClick = action.payload; + }, boardIdSelected: (state, action: PayloadAction) => { state.selectedBoardId = action.payload; state.galleryView = 'images'; + state.autoAssignBoardOnClick && (state.autoAddBoardId = action.payload); }, isBatchEnabledChanged: (state, action: PayloadAction) => { state.isBatchEnabled = action.payload; @@ -140,6 +145,7 @@ export const { imageSelectionToggled, imageSelected, shouldAutoSwitchChanged, + autoAssignBoardOnClickChanged, setGalleryImageMinimumWidth, boardIdSelected, isBatchEnabledChanged, diff --git a/invokeai/frontend/web/src/features/gallery/store/types.ts b/invokeai/frontend/web/src/features/gallery/store/types.ts index d19a6fded3..298b792362 100644 --- a/invokeai/frontend/web/src/features/gallery/store/types.ts +++ b/invokeai/frontend/web/src/features/gallery/store/types.ts @@ -18,6 +18,7 @@ export type GalleryState = { selection: string[]; shouldAutoSwitch: boolean; autoAddBoardId: string | undefined; + autoAssignBoardOnClick: boolean; galleryImageMinimumWidth: number; selectedBoardId: BoardId; galleryView: GalleryView; From 450e95de592ac623bce8acca2ebeb60bbeb1a24a Mon Sep 17 00:00:00 2001 From: Kevin Brack Date: Sun, 30 Jul 2023 18:35:18 -0500 Subject: [PATCH 04/11] auto change board waiting for isReady --- .../Boards/BoardsList/GalleryBoard.tsx | 19 +++++++++++++++---- .../Boards/BoardsList/NoBoardBoard.tsx | 18 +++++++++++++----- .../features/gallery/store/gallerySlice.ts | 1 - 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx index 67c45c131b..a4124e2393 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx @@ -16,7 +16,10 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; import IAIDroppable from 'common/components/IAIDroppable'; import SelectionOverlay from 'common/components/SelectionOverlay'; -import { boardIdSelected } from 'features/gallery/store/gallerySlice'; +import { + autoAddBoardIdChanged, + boardIdSelected, +} from 'features/gallery/store/gallerySlice'; import { memo, useCallback, useMemo, useState } from 'react'; import { FaUser } from 'react-icons/fa'; import { useUpdateBoardMutation } from 'services/api/endpoints/boards'; @@ -24,6 +27,7 @@ import { useGetImageDTOQuery } from 'services/api/endpoints/images'; import { BoardDTO } from 'services/api/types'; import AutoAddIcon from '../AutoAddIcon'; import BoardContextMenu from '../BoardContextMenu'; +import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke'; interface GalleryBoardProps { board: BoardDTO; @@ -41,15 +45,17 @@ const GalleryBoard = memo( ({ gallery }) => { const isSelectedForAutoAdd = board.board_id === gallery.autoAddBoardId; + const autoAssignBoardOnClick = gallery.autoAssignBoardOnClick; - return { isSelectedForAutoAdd }; + return { isSelectedForAutoAdd, autoAssignBoardOnClick }; }, defaultSelectorOptions ), [board.board_id] ); - const { isSelectedForAutoAdd } = useAppSelector(selector); + const { isSelectedForAutoAdd, autoAssignBoardOnClick } = + useAppSelector(selector); const [isHovered, setIsHovered] = useState(false); const handleMouseOver = useCallback(() => { setIsHovered(true); @@ -64,9 +70,14 @@ const GalleryBoard = memo( const { board_name, board_id } = board; const [localBoardName, setLocalBoardName] = useState(board_name); + const isReady = useIsReadyToInvoke(); + const handleSelectBoard = useCallback(() => { dispatch(boardIdSelected(board_id)); - }, [board_id, dispatch]); + if (autoAssignBoardOnClick && isReady) { + dispatch(autoAddBoardIdChanged(board_id)); + } + }, [board_id, autoAssignBoardOnClick, isReady, dispatch]); const [updateBoard, { isLoading: isUpdateBoardLoading }] = useUpdateBoardMutation(); diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx index ee1d8f6bea..3963fc04d9 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx @@ -7,11 +7,15 @@ import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; import InvokeAILogoImage from 'assets/images/logo.png'; import IAIDroppable from 'common/components/IAIDroppable'; import SelectionOverlay from 'common/components/SelectionOverlay'; -import { boardIdSelected } from 'features/gallery/store/gallerySlice'; +import { + boardIdSelected, + autoAddBoardIdChanged, +} from 'features/gallery/store/gallerySlice'; import { memo, useCallback, useMemo, useState } from 'react'; import { useBoardName } from 'services/api/hooks/useBoardName'; import AutoAddIcon from '../AutoAddIcon'; import BoardContextMenu from '../BoardContextMenu'; +import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke'; interface Props { isSelected: boolean; } @@ -19,19 +23,23 @@ interface Props { const selector = createSelector( stateSelector, ({ gallery }) => { - const { autoAddBoardId } = gallery; - return { autoAddBoardId }; + const { autoAddBoardId, autoAssignBoardOnClick } = gallery; + return { autoAddBoardId, autoAssignBoardOnClick }; }, defaultSelectorOptions ); const NoBoardBoard = memo(({ isSelected }: Props) => { const dispatch = useAppDispatch(); - const { autoAddBoardId } = useAppSelector(selector); + const { autoAddBoardId, autoAssignBoardOnClick } = useAppSelector(selector); const boardName = useBoardName(undefined); + const isReady = useIsReadyToInvoke(); const handleSelectBoard = useCallback(() => { dispatch(boardIdSelected(undefined)); - }, [dispatch]); + if (autoAssignBoardOnClick && isReady) { + dispatch(autoAddBoardIdChanged(undefined)); + } + }, [dispatch, autoAssignBoardOnClick, isReady]); const [isHovered, setIsHovered] = useState(false); const handleMouseOver = useCallback(() => { setIsHovered(true); diff --git a/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts b/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts index 851e1b6c3b..9c65e818f4 100644 --- a/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts +++ b/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts @@ -73,7 +73,6 @@ export const gallerySlice = createSlice({ boardIdSelected: (state, action: PayloadAction) => { state.selectedBoardId = action.payload; state.galleryView = 'images'; - state.autoAssignBoardOnClick && (state.autoAddBoardId = action.payload); }, isBatchEnabledChanged: (state, action: PayloadAction) => { state.isBatchEnabled = action.payload; From 366952f810fcedd676b735046c9e384d08aa244f Mon Sep 17 00:00:00 2001 From: Kevin Brack Date: Sun, 30 Jul 2023 19:02:53 -0500 Subject: [PATCH 05/11] fix localization --- invokeai/frontend/web/public/locales/en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json index cf84e4d773..63380a19fa 100644 --- a/invokeai/frontend/web/public/locales/en.json +++ b/invokeai/frontend/web/public/locales/en.json @@ -124,7 +124,8 @@ "deleteImageBin": "Deleted images will be sent to your operating system's Bin.", "deleteImagePermanent": "Deleted images cannot be restored.", "images": "Images", - "assets": "Assets" + "assets": "Assets", + "autoAssignBoardOnClick": "Auto-Assign Board on Click" }, "hotkeys": { "keyboardShortcuts": "Keyboard Shortcuts", From 87424be95d17434bb698bb4742acbaa7fb63d2d6 Mon Sep 17 00:00:00 2001 From: Kevin Brack Date: Mon, 31 Jul 2023 19:34:24 -0500 Subject: [PATCH 06/11] block auto add board change during generation. Switch condition to isProcessing --- .../components/Boards/BoardAutoAddSelect.tsx | 12 ++++++++---- .../Boards/BoardsList/GalleryBoard.tsx | 18 ++++++++++-------- .../Boards/BoardsList/NoBoardBoard.tsx | 14 +++++++------- .../components/GallerySettingsPopover.tsx | 2 +- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardAutoAddSelect.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardAutoAddSelect.tsx index ad0e5ab80d..9f02a29f10 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardAutoAddSelect.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardAutoAddSelect.tsx @@ -11,11 +11,14 @@ import { useListAllBoardsQuery } from 'services/api/endpoints/boards'; const selector = createSelector( [stateSelector], - ({ gallery }) => { - const { autoAddBoardId } = gallery; + ({ gallery, system }) => { + const { autoAddBoardId, autoAssignBoardOnClick } = gallery; + const { isProcessing } = system; return { autoAddBoardId, + autoAssignBoardOnClick, + isProcessing, }; }, defaultSelectorOptions @@ -23,7 +26,8 @@ const selector = createSelector( const BoardAutoAddSelect = () => { const dispatch = useAppDispatch(); - const { autoAddBoardId } = useAppSelector(selector); + const { autoAddBoardId, autoAssignBoardOnClick, isProcessing } = + useAppSelector(selector); const inputRef = useRef(null); const { boards, hasBoards } = useListAllBoardsQuery(undefined, { selectFromResult: ({ data }) => { @@ -67,7 +71,7 @@ const BoardAutoAddSelect = () => { data={boards} nothingFound="No matching Boards" itemComponent={IAIMantineSelectItemWithTooltip} - disabled={!hasBoards} + disabled={!hasBoards || autoAssignBoardOnClick || isProcessing} filter={(value, item: SelectItem) => item.label?.toLowerCase().includes(value.toLowerCase().trim()) || item.value.toLowerCase().includes(value.toLowerCase().trim()) diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx index a4124e2393..3b591ee00f 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx @@ -27,7 +27,6 @@ import { useGetImageDTOQuery } from 'services/api/endpoints/images'; import { BoardDTO } from 'services/api/types'; import AutoAddIcon from '../AutoAddIcon'; import BoardContextMenu from '../BoardContextMenu'; -import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke'; interface GalleryBoardProps { board: BoardDTO; @@ -42,19 +41,24 @@ const GalleryBoard = memo( () => createSelector( stateSelector, - ({ gallery }) => { + ({ gallery, system }) => { const isSelectedForAutoAdd = board.board_id === gallery.autoAddBoardId; const autoAssignBoardOnClick = gallery.autoAssignBoardOnClick; + const isProcessing = system.isProcessing; - return { isSelectedForAutoAdd, autoAssignBoardOnClick }; + return { + isSelectedForAutoAdd, + autoAssignBoardOnClick, + isProcessing, + }; }, defaultSelectorOptions ), [board.board_id] ); - const { isSelectedForAutoAdd, autoAssignBoardOnClick } = + const { isSelectedForAutoAdd, autoAssignBoardOnClick, isProcessing } = useAppSelector(selector); const [isHovered, setIsHovered] = useState(false); const handleMouseOver = useCallback(() => { @@ -70,14 +74,12 @@ const GalleryBoard = memo( const { board_name, board_id } = board; const [localBoardName, setLocalBoardName] = useState(board_name); - const isReady = useIsReadyToInvoke(); - const handleSelectBoard = useCallback(() => { dispatch(boardIdSelected(board_id)); - if (autoAssignBoardOnClick && isReady) { + if (autoAssignBoardOnClick && !isProcessing) { dispatch(autoAddBoardIdChanged(board_id)); } - }, [board_id, autoAssignBoardOnClick, isReady, dispatch]); + }, [board_id, autoAssignBoardOnClick, isProcessing, dispatch]); const [updateBoard, { isLoading: isUpdateBoardLoading }] = useUpdateBoardMutation(); diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx index 3963fc04d9..118b2108f7 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/NoBoardBoard.tsx @@ -15,31 +15,31 @@ import { memo, useCallback, useMemo, useState } from 'react'; import { useBoardName } from 'services/api/hooks/useBoardName'; import AutoAddIcon from '../AutoAddIcon'; import BoardContextMenu from '../BoardContextMenu'; -import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke'; interface Props { isSelected: boolean; } const selector = createSelector( stateSelector, - ({ gallery }) => { + ({ gallery, system }) => { const { autoAddBoardId, autoAssignBoardOnClick } = gallery; - return { autoAddBoardId, autoAssignBoardOnClick }; + const { isProcessing } = system; + return { autoAddBoardId, autoAssignBoardOnClick, isProcessing }; }, defaultSelectorOptions ); const NoBoardBoard = memo(({ isSelected }: Props) => { const dispatch = useAppDispatch(); - const { autoAddBoardId, autoAssignBoardOnClick } = useAppSelector(selector); + const { autoAddBoardId, autoAssignBoardOnClick, isProcessing } = + useAppSelector(selector); const boardName = useBoardName(undefined); - const isReady = useIsReadyToInvoke(); const handleSelectBoard = useCallback(() => { dispatch(boardIdSelected(undefined)); - if (autoAssignBoardOnClick && isReady) { + if (autoAssignBoardOnClick && !isProcessing) { dispatch(autoAddBoardIdChanged(undefined)); } - }, [dispatch, autoAssignBoardOnClick, isReady]); + }, [dispatch, autoAssignBoardOnClick, isProcessing]); const [isHovered, setIsHovered] = useState(false); const handleMouseOver = useCallback(() => { setIsHovered(true); diff --git a/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx b/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx index 04cc98edb7..796cc542e7 100644 --- a/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/GallerySettingsPopover.tsx @@ -82,7 +82,7 @@ const GallerySettingsPopover = () => { dispatch(autoAssignBoardOnClickChanged(e.target.checked)) } /> - {!autoAssignBoardOnClick && } + ); From 26ef5249b1902132493ef6cbc5f1c8d6c4c7bdd8 Mon Sep 17 00:00:00 2001 From: Kevin Brack Date: Mon, 31 Jul 2023 19:44:41 -0500 Subject: [PATCH 07/11] guard board switching in board context menu --- .../gallery/components/Boards/BoardContextMenu.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardContextMenu.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardContextMenu.tsx index 35fcbd87f7..2774288612 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardContextMenu.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardContextMenu.tsx @@ -25,14 +25,17 @@ const BoardContextMenu = memo( const selector = useMemo( () => - createSelector(stateSelector, ({ gallery }) => { + createSelector(stateSelector, ({ gallery, system }) => { const isAutoAdd = gallery.autoAddBoardId === board_id; - return { isAutoAdd }; + const isProcessing = system.isProcessing; + const autoAssignBoardOnClick = gallery.autoAssignBoardOnClick; + return { isAutoAdd, isProcessing, autoAssignBoardOnClick }; }), [board_id] ); - const { isAutoAdd } = useAppSelector(selector); + const { isAutoAdd, isProcessing, autoAssignBoardOnClick } = + useAppSelector(selector); const boardName = useBoardName(board_id); const handleSetAutoAdd = useCallback(() => { @@ -59,7 +62,7 @@ const BoardContextMenu = memo( } - isDisabled={isAutoAdd} + isDisabled={isAutoAdd || isProcessing || autoAssignBoardOnClick} onClick={handleSetAutoAdd} > Auto-add to this Board From 7021467048925d413e9fd132545491ee04ac603e Mon Sep 17 00:00:00 2001 From: Eugene Brodsky Date: Wed, 2 Aug 2023 19:46:02 -0400 Subject: [PATCH 08/11] (ci) do not install all dependencies when running static checks (#4036) Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com> --- .github/workflows/style-checks.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/style-checks.yml b/.github/workflows/style-checks.yml index 8aceb6469e..0bb19e95e5 100644 --- a/.github/workflows/style-checks.yml +++ b/.github/workflows/style-checks.yml @@ -1,13 +1,15 @@ -name: Black # TODO: add isort and flake8 later +name: style checks +# just formatting for now +# TODO: add isort and flake8 later on: - pull_request: {} + pull_request: push: - branches: master + branches: main tags: "*" jobs: - test: + black: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -19,8 +21,7 @@ jobs: - name: Install dependencies with pip run: | - pip install --upgrade pip wheel - pip install .[test] + pip install black # - run: isort --check-only . - run: black --check . From 4e0949fa5503c4ed2a61641aa9deb0f3e1134fb4 Mon Sep 17 00:00:00 2001 From: Damian Stewart Date: Sun, 30 Jul 2023 20:12:53 +0200 Subject: [PATCH 09/11] fix .swap() by reverting improperly merged @classmethod change --- .../diffusion/shared_invokeai_diffusion.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py b/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py index 272518e928..c01cf82c57 100644 --- a/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py +++ b/invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py @@ -78,10 +78,9 @@ class InvokeAIDiffuserComponent: self.cross_attention_control_context = None self.sequential_guidance = config.sequential_guidance - @classmethod @contextmanager def custom_attention_context( - cls, + self, unet: UNet2DConditionModel, # note: also may futz with the text encoder depending on requested LoRAs extra_conditioning_info: Optional[ExtraConditioningInfo], step_count: int, @@ -91,18 +90,19 @@ class InvokeAIDiffuserComponent: old_attn_processors = unet.attn_processors # Load lora conditions into the model if extra_conditioning_info.wants_cross_attention_control: - cross_attention_control_context = Context( + self.cross_attention_control_context = Context( arguments=extra_conditioning_info.cross_attention_control_args, step_count=step_count, ) setup_cross_attention_control_attention_processors( unet, - cross_attention_control_context, + self.cross_attention_control_context, ) try: yield None finally: + self.cross_attention_control_context = None if old_attn_processors is not None: unet.set_attn_processor(old_attn_processors) # TODO resuscitate attention map saving From 118d5b387b05c1e906cb186c1a7540379e13cc01 Mon Sep 17 00:00:00 2001 From: Brandon Rising Date: Tue, 1 Aug 2023 16:22:20 -0400 Subject: [PATCH 10/11] deploy: refactor github workflows Currently we use some workflow trigger conditionals to run either a real test workflow (installing the app and running it) or a fake workflow, disguised as the real one, that just auto-passes. This change refactors the workflow to use a single workflow that can be skipped, using another github action to determine which things to run depending on the paths changed. --- .github/workflows/style-checks.yml | 1 - .github/workflows/test-invoke-pip-skip.yml | 50 ---------------------- .github/workflows/test-invoke-pip.yml | 24 +++++++---- 3 files changed, 15 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/test-invoke-pip-skip.yml diff --git a/.github/workflows/style-checks.yml b/.github/workflows/style-checks.yml index 0bb19e95e5..d29b489418 100644 --- a/.github/workflows/style-checks.yml +++ b/.github/workflows/style-checks.yml @@ -6,7 +6,6 @@ on: pull_request: push: branches: main - tags: "*" jobs: black: diff --git a/.github/workflows/test-invoke-pip-skip.yml b/.github/workflows/test-invoke-pip-skip.yml deleted file mode 100644 index 004b46d5a8..0000000000 --- a/.github/workflows/test-invoke-pip-skip.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Test invoke.py pip - -# This is a dummy stand-in for the actual tests -# we don't need to run python tests on non-Python changes -# But PRs require passing tests to be mergeable - -on: - pull_request: - paths: - - '**' - - '!pyproject.toml' - - '!invokeai/**' - - '!tests/**' - - 'invokeai/frontend/web/**' - merge_group: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - matrix: - if: github.event.pull_request.draft == false - strategy: - matrix: - python-version: - - '3.10' - pytorch: - - linux-cuda-11_7 - - linux-rocm-5_2 - - linux-cpu - - macos-default - - windows-cpu - include: - - pytorch: linux-cuda-11_7 - os: ubuntu-22.04 - - pytorch: linux-rocm-5_2 - os: ubuntu-22.04 - - pytorch: linux-cpu - os: ubuntu-22.04 - - pytorch: macos-default - os: macOS-12 - - pytorch: windows-cpu - os: windows-2022 - name: ${{ matrix.pytorch }} on ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - steps: - - name: skip - run: echo "no build required" diff --git a/.github/workflows/test-invoke-pip.yml b/.github/workflows/test-invoke-pip.yml index 40be0a529e..6086d10069 100644 --- a/.github/workflows/test-invoke-pip.yml +++ b/.github/workflows/test-invoke-pip.yml @@ -3,16 +3,7 @@ on: push: branches: - 'main' - paths: - - 'pyproject.toml' - - 'invokeai/**' - - '!invokeai/frontend/web/**' pull_request: - paths: - - 'pyproject.toml' - - 'invokeai/**' - - 'tests/**' - - '!invokeai/frontend/web/**' types: - 'ready_for_review' - 'opened' @@ -65,10 +56,23 @@ jobs: id: checkout-sources uses: actions/checkout@v3 + - name: Check for changed python files + id: changed-files + uses: tj-actions/changed-files@v37 + with: + files_yaml: | + python: + - 'pyproject.toml' + - 'invokeai/**' + - '!invokeai/frontend/web/**' + - 'tests/**' + - name: set test prompt to main branch validation + if: steps.changed-files.outputs.python_any_changed == 'true' run: echo "TEST_PROMPTS=tests/validate_pr_prompt.txt" >> ${{ matrix.github-env }} - name: setup python + if: steps.changed-files.outputs.python_any_changed == 'true' uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -76,6 +80,7 @@ jobs: cache-dependency-path: pyproject.toml - name: install invokeai + if: steps.changed-files.outputs.python_any_changed == 'true' env: PIP_EXTRA_INDEX_URL: ${{ matrix.extra-index-url }} run: > @@ -83,6 +88,7 @@ jobs: --editable=".[test]" - name: run pytest + if: steps.changed-files.outputs.python_any_changed == 'true' id: run-pytest run: pytest From a6f9396a3021f561dda0ddd5e35bdc2d07207bbd Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:08:17 +1000 Subject: [PATCH 11/11] fix(db): retrieve metadata even when no `session_id` this was unnecessarily skipped if there was no `session_id`. --- invokeai/app/services/images.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/app/services/images.py b/invokeai/app/services/images.py index f8376eb626..2240846dac 100644 --- a/invokeai/app/services/images.py +++ b/invokeai/app/services/images.py @@ -289,9 +289,10 @@ class ImageService(ImageServiceABC): def get_metadata(self, image_name: str) -> Optional[ImageMetadata]: try: image_record = self._services.image_records.get(image_name) + metadata = self._services.image_records.get_metadata(image_name) if not image_record.session_id: - return ImageMetadata() + return ImageMetadata(metadata=metadata) session_raw = self._services.graph_execution_manager.get_raw(image_record.session_id) graph = None @@ -303,7 +304,6 @@ class ImageService(ImageServiceABC): self._services.logger.warn(f"Failed to parse session graph: {e}") graph = None - metadata = self._services.image_records.get_metadata(image_name) return ImageMetadata(graph=graph, metadata=metadata) except ImageRecordNotFoundException: self._services.logger.error("Image record not found")