Skip to content

Commit ff36ebb

Browse files
committed
adjustments for AppAPI 2.1.0
1 parent 51300c0 commit ff36ebb

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

Makefile

+2-17
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ help:
99
@echo " "
1010
@echo " build-push build image and upload to ghcr.io"
1111
@echo " "
12-
@echo " deploy deploy example to registered 'docker_dev' for Nextcloud Last"
13-
@echo " deploy27 deploy example to registered 'docker_dev' for Nextcloud 27"
14-
@echo " "
1512
@echo " run install AIImageGeneratorBot for Nextcloud Last"
1613
@echo " run27 install AIImageGeneratorBot for Nextcloud 27"
1714
@echo " "
@@ -26,18 +23,6 @@ build-push:
2623
docker login ghcr.io
2724
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/cloud-py-api/ai_image_generator_bot:2.0.0 --tag ghcr.io/cloud-py-api/ai_image_generator_bot:latest .
2825

29-
.PHONY: deploy
30-
deploy:
31-
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
32-
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot \
33-
--info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml
34-
35-
.PHONY: deploy27
36-
deploy27:
37-
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
38-
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot \
39-
--info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml
40-
4126
.PHONY: run
4227
run:
4328
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
@@ -54,12 +39,12 @@ run27:
5439
register:
5540
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
5641
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot manual_install --json-info \
57-
"{\"appid\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9080,\"scopes\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"system_app\":1}" \
42+
"{\"id\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9080,\"scopes\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"system\":1}" \
5843
--force-scopes --wait-finish
5944

6045
.PHONY: register27
6146
register27:
6247
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
6348
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot manual_install --json-info \
64-
"{\"appid\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9080,\"scopes\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"system_app\":1}" \
49+
"{\"id\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9080,\"scopes\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"system\":1}" \
6550
--force-scopes --wait-finish

lib/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from huggingface_hub import snapshot_download
1616
from nc_py_api import AsyncNextcloudApp, NextcloudApp
1717
from nc_py_api.ex_app import (
18+
AppAPIAuthMiddleware,
1819
LogLvl,
19-
anc_app,
2020
atalk_bot_msg,
2121
persistent_storage,
2222
run_app,
@@ -32,7 +32,7 @@
3232

3333

3434
@asynccontextmanager
35-
async def lifespan(_app: FastAPI):
35+
async def lifespan(app: FastAPI):
3636
if torch.cuda.is_available() or torch.backends.mps.is_available():
3737
allow_patterns = ["*.fp16.safetensors", "*.json", "*.txt"]
3838
ignore_patterns = None
@@ -42,7 +42,7 @@ async def lifespan(_app: FastAPI):
4242
allow_patterns = None
4343
ignore_patterns = ["*onnx*", "*fp16*", "sd_xl_turbo_1*"]
4444
set_handlers(
45-
APP,
45+
app,
4646
enabled_handler,
4747
models_to_fetch={
4848
MODEL_NAME: {
@@ -57,6 +57,7 @@ async def lifespan(_app: FastAPI):
5757

5858

5959
APP = FastAPI(lifespan=lifespan)
60+
APP.add_middleware(AppAPIAuthMiddleware)
6061
SD_BOT = AsyncTalkBot(
6162
"/stable_diffusion",
6263
"Stable Diffusion",
@@ -128,7 +129,6 @@ async def stable_diffusion_process_request(message: TalkBotMessage):
128129
@APP.post("/stable_diffusion")
129130
async def stable_diffusion(
130131
message: Annotated[TalkBotMessage, Depends(atalk_bot_msg)],
131-
_nc: Annotated[AsyncNextcloudApp, Depends(anc_app)],
132132
background_tasks: BackgroundTasks,
133133
):
134134
if message.object_name == "message" and message.actor_id.startswith("users/"):

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
nc_py_api[app]>=0.9.0
1+
nc_py_api[app]>=0.10.0
22
diffusers>=0.23.1
33
transformers>=4.36.1
44
accelerate

0 commit comments

Comments
 (0)