Skip to content

Commit 06742fa

Browse files
author
Lincoln Stein
committed
Merge branch 'feat/execution-stats' of github.com:invoke-ai/InvokeAI into feat/execution-stats
2 parents d2bddf7 + cf72eba commit 06742fa

File tree

15 files changed

+98
-256
lines changed

15 files changed

+98
-256
lines changed
File renamed without changes.

.github/workflows/style-checks.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: Black # TODO: add isort and flake8 later
1+
name: style checks
2+
# just formatting for now
3+
# TODO: add isort and flake8 later
24

35
on:
4-
pull_request: {}
6+
pull_request:
57
push:
6-
branches: master
7-
tags: "*"
8+
branches: main
89

910
jobs:
10-
test:
11+
black:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- uses: actions/checkout@v3
@@ -19,8 +20,7 @@ jobs:
1920

2021
- name: Install dependencies with pip
2122
run: |
22-
pip install --upgrade pip wheel
23-
pip install .[test]
23+
pip install black
2424
2525
# - run: isort --check-only .
2626
- run: black --check .

.github/workflows/test-invoke-pip-skip.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/test-invoke-pip.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@ on:
33
push:
44
branches:
55
- 'main'
6-
paths:
7-
- 'pyproject.toml'
8-
- 'invokeai/**'
9-
- '!invokeai/frontend/web/**'
106
pull_request:
11-
paths:
12-
- 'pyproject.toml'
13-
- 'invokeai/**'
14-
- 'tests/**'
15-
- '!invokeai/frontend/web/**'
167
types:
178
- 'ready_for_review'
189
- 'opened'
@@ -65,24 +56,39 @@ jobs:
6556
id: checkout-sources
6657
uses: actions/checkout@v3
6758

59+
- name: Check for changed python files
60+
id: changed-files
61+
uses: tj-actions/changed-files@v37
62+
with:
63+
files_yaml: |
64+
python:
65+
- 'pyproject.toml'
66+
- 'invokeai/**'
67+
- '!invokeai/frontend/web/**'
68+
- 'tests/**'
69+
6870
- name: set test prompt to main branch validation
71+
if: steps.changed-files.outputs.python_any_changed == 'true'
6972
run: echo "TEST_PROMPTS=tests/validate_pr_prompt.txt" >> ${{ matrix.github-env }}
7073

7174
- name: setup python
75+
if: steps.changed-files.outputs.python_any_changed == 'true'
7276
uses: actions/setup-python@v4
7377
with:
7478
python-version: ${{ matrix.python-version }}
7579
cache: pip
7680
cache-dependency-path: pyproject.toml
7781

7882
- name: install invokeai
83+
if: steps.changed-files.outputs.python_any_changed == 'true'
7984
env:
8085
PIP_EXTRA_INDEX_URL: ${{ matrix.extra-index-url }}
8186
run: >
8287
pip3 install
8388
--editable=".[test]"
8489
8590
- name: run pytest
91+
if: steps.changed-files.outputs.python_any_changed == 'true'
8692
id: run-pytest
8793
run: pytest
8894

invokeai/app/services/images.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,10 @@ def get_dto(self, image_name: str) -> ImageDTO:
289289
def get_metadata(self, image_name: str) -> Optional[ImageMetadata]:
290290
try:
291291
image_record = self._services.image_records.get(image_name)
292+
metadata = self._services.image_records.get_metadata(image_name)
292293

293294
if not image_record.session_id:
294-
return ImageMetadata()
295+
return ImageMetadata(metadata=metadata)
295296

296297
session_raw = self._services.graph_execution_manager.get_raw(image_record.session_id)
297298
graph = None
@@ -303,7 +304,6 @@ def get_metadata(self, image_name: str) -> Optional[ImageMetadata]:
303304
self._services.logger.warn(f"Failed to parse session graph: {e}")
304305
graph = None
305306

306-
metadata = self._services.image_records.get_metadata(image_name)
307307
return ImageMetadata(graph=graph, metadata=metadata)
308308
except ImageRecordNotFoundException:
309309
self._services.logger.error("Image record not found")

invokeai/backend/stable_diffusion/diffusion/shared_invokeai_diffusion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ def __init__(
7878
self.cross_attention_control_context = None
7979
self.sequential_guidance = config.sequential_guidance
8080

81-
@classmethod
8281
@contextmanager
8382
def custom_attention_context(
84-
cls,
83+
self,
8584
unet: UNet2DConditionModel, # note: also may futz with the text encoder depending on requested LoRAs
8685
extra_conditioning_info: Optional[ExtraConditioningInfo],
8786
step_count: int,
@@ -91,18 +90,19 @@ def custom_attention_context(
9190
old_attn_processors = unet.attn_processors
9291
# Load lora conditions into the model
9392
if extra_conditioning_info.wants_cross_attention_control:
94-
cross_attention_control_context = Context(
93+
self.cross_attention_control_context = Context(
9594
arguments=extra_conditioning_info.cross_attention_control_args,
9695
step_count=step_count,
9796
)
9897
setup_cross_attention_control_attention_processors(
9998
unet,
100-
cross_attention_control_context,
99+
self.cross_attention_control_context,
101100
)
102101

103102
try:
104103
yield None
105104
finally:
105+
self.cross_attention_control_context = None
106106
if old_attn_processors is not None:
107107
unet.set_attn_processor(old_attn_processors)
108108
# TODO resuscitate attention map saving

invokeai/frontend/web/public/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@
124124
"deleteImageBin": "Deleted images will be sent to your operating system's Bin.",
125125
"deleteImagePermanent": "Deleted images cannot be restored.",
126126
"images": "Images",
127-
"assets": "Assets"
127+
"assets": "Assets",
128+
"autoAssignBoardOnClick": "Auto-Assign Board on Click"
128129
},
129130
"hotkeys": {
130131
"keyboardShortcuts": "Keyboard Shortcuts",

invokeai/frontend/web/src/features/gallery/components/Boards/BoardAutoAddSelect.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@ import { useListAllBoardsQuery } from 'services/api/endpoints/boards';
1111

1212
const selector = createSelector(
1313
[stateSelector],
14-
({ gallery }) => {
15-
const { autoAddBoardId } = gallery;
14+
({ gallery, system }) => {
15+
const { autoAddBoardId, autoAssignBoardOnClick } = gallery;
16+
const { isProcessing } = system;
1617

1718
return {
1819
autoAddBoardId,
20+
autoAssignBoardOnClick,
21+
isProcessing,
1922
};
2023
},
2124
defaultSelectorOptions
2225
);
2326

2427
const BoardAutoAddSelect = () => {
2528
const dispatch = useAppDispatch();
26-
const { autoAddBoardId } = useAppSelector(selector);
29+
const { autoAddBoardId, autoAssignBoardOnClick, isProcessing } =
30+
useAppSelector(selector);
2731
const inputRef = useRef<HTMLInputElement>(null);
2832
const { boards, hasBoards } = useListAllBoardsQuery(undefined, {
2933
selectFromResult: ({ data }) => {
@@ -67,7 +71,7 @@ const BoardAutoAddSelect = () => {
6771
data={boards}
6872
nothingFound="No matching Boards"
6973
itemComponent={IAIMantineSelectItemWithTooltip}
70-
disabled={!hasBoards}
74+
disabled={!hasBoards || autoAssignBoardOnClick || isProcessing}
7175
filter={(value, item: SelectItem) =>
7276
item.label?.toLowerCase().includes(value.toLowerCase().trim()) ||
7377
item.value.toLowerCase().includes(value.toLowerCase().trim())

invokeai/frontend/web/src/features/gallery/components/Boards/BoardContextMenu.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ const BoardContextMenu = memo(
2525

2626
const selector = useMemo(
2727
() =>
28-
createSelector(stateSelector, ({ gallery }) => {
28+
createSelector(stateSelector, ({ gallery, system }) => {
2929
const isAutoAdd = gallery.autoAddBoardId === board_id;
30-
return { isAutoAdd };
30+
const isProcessing = system.isProcessing;
31+
const autoAssignBoardOnClick = gallery.autoAssignBoardOnClick;
32+
return { isAutoAdd, isProcessing, autoAssignBoardOnClick };
3133
}),
3234
[board_id]
3335
);
3436

35-
const { isAutoAdd } = useAppSelector(selector);
37+
const { isAutoAdd, isProcessing, autoAssignBoardOnClick } =
38+
useAppSelector(selector);
3639
const boardName = useBoardName(board_id);
3740

3841
const handleSetAutoAdd = useCallback(() => {
@@ -59,7 +62,7 @@ const BoardContextMenu = memo(
5962
<MenuGroup title={boardName}>
6063
<MenuItem
6164
icon={<FaPlus />}
62-
isDisabled={isAutoAdd}
65+
isDisabled={isAutoAdd || isProcessing || autoAssignBoardOnClick}
6366
onClick={handleSetAutoAdd}
6467
>
6568
Auto-add to this Board

invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/GalleryBoard.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
1616
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
1717
import IAIDroppable from 'common/components/IAIDroppable';
1818
import SelectionOverlay from 'common/components/SelectionOverlay';
19-
import { boardIdSelected } from 'features/gallery/store/gallerySlice';
19+
import {
20+
autoAddBoardIdChanged,
21+
boardIdSelected,
22+
} from 'features/gallery/store/gallerySlice';
2023
import { memo, useCallback, useMemo, useState } from 'react';
2124
import { FaUser } from 'react-icons/fa';
2225
import { useUpdateBoardMutation } from 'services/api/endpoints/boards';
@@ -38,18 +41,25 @@ const GalleryBoard = memo(
3841
() =>
3942
createSelector(
4043
stateSelector,
41-
({ gallery }) => {
44+
({ gallery, system }) => {
4245
const isSelectedForAutoAdd =
4346
board.board_id === gallery.autoAddBoardId;
47+
const autoAssignBoardOnClick = gallery.autoAssignBoardOnClick;
48+
const isProcessing = system.isProcessing;
4449

45-
return { isSelectedForAutoAdd };
50+
return {
51+
isSelectedForAutoAdd,
52+
autoAssignBoardOnClick,
53+
isProcessing,
54+
};
4655
},
4756
defaultSelectorOptions
4857
),
4958
[board.board_id]
5059
);
5160

52-
const { isSelectedForAutoAdd } = useAppSelector(selector);
61+
const { isSelectedForAutoAdd, autoAssignBoardOnClick, isProcessing } =
62+
useAppSelector(selector);
5363
const [isHovered, setIsHovered] = useState(false);
5464
const handleMouseOver = useCallback(() => {
5565
setIsHovered(true);
@@ -66,7 +76,10 @@ const GalleryBoard = memo(
6676

6777
const handleSelectBoard = useCallback(() => {
6878
dispatch(boardIdSelected(board_id));
69-
}, [board_id, dispatch]);
79+
if (autoAssignBoardOnClick && !isProcessing) {
80+
dispatch(autoAddBoardIdChanged(board_id));
81+
}
82+
}, [board_id, autoAssignBoardOnClick, isProcessing, dispatch]);
7083

7184
const [updateBoard, { isLoading: isUpdateBoardLoading }] =
7285
useUpdateBoardMutation();

0 commit comments

Comments
 (0)