Skip to content

Commit 9942af7

Browse files
Merge branch 'main' into remove-onnx-model-check-from-pipeline-download
2 parents 82d259f + bf94412 commit 9942af7

File tree

128 files changed

+2588
-2433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+2588
-2433
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

Lines changed: 75 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
from fastapi import Body, HTTPException, Path, Query
1+
from fastapi import Body, HTTPException
22
from fastapi.routing import APIRouter
3-
from invokeai.app.services.board_record_storage import BoardRecord, BoardChanges
4-
from invokeai.app.services.image_record_storage import OffsetPaginatedResults
5-
from invokeai.app.services.models.board_record import BoardDTO
6-
from invokeai.app.services.models.image_record import ImageDTO
3+
from pydantic import BaseModel, Field
74

85
from ..dependencies import ApiDependencies
96

107
board_images_router = APIRouter(prefix="/v1/board_images", tags=["boards"])
118

129

10+
class AddImagesToBoardResult(BaseModel):
11+
board_id: str = Field(description="The id of the board the images were added to")
12+
added_image_names: list[str] = Field(description="The image names that were added to the board")
13+
14+
15+
class RemoveImagesFromBoardResult(BaseModel):
16+
removed_image_names: list[str] = Field(description="The image names that were removed from their board")
17+
18+
1319
@board_images_router.post(
1420
"/",
15-
operation_id="create_board_image",
21+
operation_id="add_image_to_board",
1622
responses={
1723
201: {"description": "The image was added to a board successfully"},
1824
},
1925
status_code=201,
2026
)
21-
async def create_board_image(
27+
async def add_image_to_board(
2228
board_id: str = Body(description="The id of the board to add to"),
2329
image_name: str = Body(description="The name of the image to add"),
2430
):
@@ -29,26 +35,78 @@ async def create_board_image(
2935
)
3036
return result
3137
except Exception as e:
32-
raise HTTPException(status_code=500, detail="Failed to add to board")
38+
raise HTTPException(status_code=500, detail="Failed to add image to board")
3339

3440

3541
@board_images_router.delete(
3642
"/",
37-
operation_id="remove_board_image",
43+
operation_id="remove_image_from_board",
3844
responses={
3945
201: {"description": "The image was removed from the board successfully"},
4046
},
4147
status_code=201,
4248
)
43-
async def remove_board_image(
44-
board_id: str = Body(description="The id of the board"),
45-
image_name: str = Body(description="The name of the image to remove"),
49+
async def remove_image_from_board(
50+
image_name: str = Body(description="The name of the image to remove", embed=True),
4651
):
47-
"""Deletes a board_image"""
52+
"""Removes an image from its board, if it had one"""
4853
try:
49-
result = ApiDependencies.invoker.services.board_images.remove_image_from_board(
50-
board_id=board_id, image_name=image_name
51-
)
54+
result = ApiDependencies.invoker.services.board_images.remove_image_from_board(image_name=image_name)
5255
return result
5356
except Exception as e:
54-
raise HTTPException(status_code=500, detail="Failed to update board")
57+
raise HTTPException(status_code=500, detail="Failed to remove image from board")
58+
59+
60+
@board_images_router.post(
61+
"/batch",
62+
operation_id="add_images_to_board",
63+
responses={
64+
201: {"description": "Images were added to board successfully"},
65+
},
66+
status_code=201,
67+
response_model=AddImagesToBoardResult,
68+
)
69+
async def add_images_to_board(
70+
board_id: str = Body(description="The id of the board to add to"),
71+
image_names: list[str] = Body(description="The names of the images to add", embed=True),
72+
) -> AddImagesToBoardResult:
73+
"""Adds a list of images to a board"""
74+
try:
75+
added_image_names: list[str] = []
76+
for image_name in image_names:
77+
try:
78+
ApiDependencies.invoker.services.board_images.add_image_to_board(
79+
board_id=board_id, image_name=image_name
80+
)
81+
added_image_names.append(image_name)
82+
except:
83+
pass
84+
return AddImagesToBoardResult(board_id=board_id, added_image_names=added_image_names)
85+
except Exception as e:
86+
raise HTTPException(status_code=500, detail="Failed to add images to board")
87+
88+
89+
@board_images_router.post(
90+
"/batch/delete",
91+
operation_id="remove_images_from_board",
92+
responses={
93+
201: {"description": "Images were removed from board successfully"},
94+
},
95+
status_code=201,
96+
response_model=RemoveImagesFromBoardResult,
97+
)
98+
async def remove_images_from_board(
99+
image_names: list[str] = Body(description="The names of the images to remove", embed=True),
100+
) -> RemoveImagesFromBoardResult:
101+
"""Removes a list of images from their board, if they had one"""
102+
try:
103+
removed_image_names: list[str] = []
104+
for image_name in image_names:
105+
try:
106+
ApiDependencies.invoker.services.board_images.remove_image_from_board(image_name=image_name)
107+
removed_image_names.append(image_name)
108+
except:
109+
pass
110+
return RemoveImagesFromBoardResult(removed_image_names=removed_image_names)
111+
except Exception as e:
112+
raise HTTPException(status_code=500, detail="Failed to remove images from board")

invokeai/app/api/routers/images.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from fastapi.responses import FileResponse
66
from fastapi.routing import APIRouter
77
from PIL import Image
8+
from pydantic import BaseModel, Field
89

910
from invokeai.app.invocations.metadata import ImageMetadata
1011
from invokeai.app.models.image import ImageCategory, ResourceOrigin
@@ -25,7 +26,7 @@
2526

2627

2728
@images_router.post(
28-
"/",
29+
"/upload",
2930
operation_id="upload_image",
3031
responses={
3132
201: {"description": "The image was uploaded successfully"},
@@ -77,7 +78,7 @@ async def upload_image(
7778
raise HTTPException(status_code=500, detail="Failed to create image")
7879

7980

80-
@images_router.delete("/{image_name}", operation_id="delete_image")
81+
@images_router.delete("/i/{image_name}", operation_id="delete_image")
8182
async def delete_image(
8283
image_name: str = Path(description="The name of the image to delete"),
8384
) -> None:
@@ -103,7 +104,7 @@ async def clear_intermediates() -> int:
103104

104105

105106
@images_router.patch(
106-
"/{image_name}",
107+
"/i/{image_name}",
107108
operation_id="update_image",
108109
response_model=ImageDTO,
109110
)
@@ -120,7 +121,7 @@ async def update_image(
120121

121122

122123
@images_router.get(
123-
"/{image_name}",
124+
"/i/{image_name}",
124125
operation_id="get_image_dto",
125126
response_model=ImageDTO,
126127
)
@@ -136,7 +137,7 @@ async def get_image_dto(
136137

137138

138139
@images_router.get(
139-
"/{image_name}/metadata",
140+
"/i/{image_name}/metadata",
140141
operation_id="get_image_metadata",
141142
response_model=ImageMetadata,
142143
)
@@ -152,7 +153,7 @@ async def get_image_metadata(
152153

153154

154155
@images_router.get(
155-
"/{image_name}/full",
156+
"/i/{image_name}/full",
156157
operation_id="get_image_full",
157158
response_class=Response,
158159
responses={
@@ -187,7 +188,7 @@ async def get_image_full(
187188

188189

189190
@images_router.get(
190-
"/{image_name}/thumbnail",
191+
"/i/{image_name}/thumbnail",
191192
operation_id="get_image_thumbnail",
192193
response_class=Response,
193194
responses={
@@ -216,7 +217,7 @@ async def get_image_thumbnail(
216217

217218

218219
@images_router.get(
219-
"/{image_name}/urls",
220+
"/i/{image_name}/urls",
220221
operation_id="get_image_urls",
221222
response_model=ImageUrlsDTO,
222223
)
@@ -265,3 +266,24 @@ async def list_image_dtos(
265266
)
266267

267268
return image_dtos
269+
270+
271+
class DeleteImagesFromListResult(BaseModel):
272+
deleted_images: list[str]
273+
274+
275+
@images_router.post("/delete", operation_id="delete_images_from_list", response_model=DeleteImagesFromListResult)
276+
async def delete_images_from_list(
277+
image_names: list[str] = Body(description="The list of names of images to delete", embed=True),
278+
) -> DeleteImagesFromListResult:
279+
try:
280+
deleted_images: list[str] = []
281+
for image_name in image_names:
282+
try:
283+
ApiDependencies.invoker.services.images.delete(image_name)
284+
deleted_images.append(image_name)
285+
except:
286+
pass
287+
return DeleteImagesFromListResult(deleted_images=deleted_images)
288+
except Exception as e:
289+
raise HTTPException(status_code=500, detail="Failed to delete images")

0 commit comments

Comments
 (0)