Skip to content

Commit

Permalink
adjustments for AppAPI 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 committed Feb 17, 2024
1 parent 51300c0 commit ff36ebb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
19 changes: 2 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ help:
@echo " "
@echo " build-push build image and upload to ghcr.io"
@echo " "
@echo " deploy deploy example to registered 'docker_dev' for Nextcloud Last"
@echo " deploy27 deploy example to registered 'docker_dev' for Nextcloud 27"
@echo " "
@echo " run install AIImageGeneratorBot for Nextcloud Last"
@echo " run27 install AIImageGeneratorBot for Nextcloud 27"
@echo " "
Expand All @@ -26,18 +23,6 @@ build-push:
docker login ghcr.io
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 .

.PHONY: deploy
deploy:
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot \
--info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml

.PHONY: deploy27
deploy27:
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot \
--info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml

.PHONY: run
run:
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
Expand All @@ -54,12 +39,12 @@ run27:
register:
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot manual_install --json-info \
"{\"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}" \
"{\"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}" \
--force-scopes --wait-finish

.PHONY: register27
register27:
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot manual_install --json-info \
"{\"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}" \
"{\"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}" \
--force-scopes --wait-finish
8 changes: 4 additions & 4 deletions lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from huggingface_hub import snapshot_download
from nc_py_api import AsyncNextcloudApp, NextcloudApp
from nc_py_api.ex_app import (
AppAPIAuthMiddleware,
LogLvl,
anc_app,
atalk_bot_msg,
persistent_storage,
run_app,
Expand All @@ -32,7 +32,7 @@


@asynccontextmanager
async def lifespan(_app: FastAPI):
async def lifespan(app: FastAPI):
if torch.cuda.is_available() or torch.backends.mps.is_available():
allow_patterns = ["*.fp16.safetensors", "*.json", "*.txt"]
ignore_patterns = None
Expand All @@ -42,7 +42,7 @@ async def lifespan(_app: FastAPI):
allow_patterns = None
ignore_patterns = ["*onnx*", "*fp16*", "sd_xl_turbo_1*"]
set_handlers(
APP,
app,
enabled_handler,
models_to_fetch={
MODEL_NAME: {
Expand All @@ -57,6 +57,7 @@ async def lifespan(_app: FastAPI):


APP = FastAPI(lifespan=lifespan)
APP.add_middleware(AppAPIAuthMiddleware)
SD_BOT = AsyncTalkBot(
"/stable_diffusion",
"Stable Diffusion",
Expand Down Expand Up @@ -128,7 +129,6 @@ async def stable_diffusion_process_request(message: TalkBotMessage):
@APP.post("/stable_diffusion")
async def stable_diffusion(
message: Annotated[TalkBotMessage, Depends(atalk_bot_msg)],
_nc: Annotated[AsyncNextcloudApp, Depends(anc_app)],
background_tasks: BackgroundTasks,
):
if message.object_name == "message" and message.actor_id.startswith("users/"):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nc_py_api[app]>=0.9.0
nc_py_api[app]>=0.10.0
diffusers>=0.23.1
transformers>=4.36.1
accelerate
Expand Down

0 comments on commit ff36ebb

Please sign in to comment.