diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bde6ccdc..737aacb8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,10 +2,7 @@ // README at: https://github.com/devcontainers/templates/tree/main/src/python { "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "build": { - "dockerfile": "Dockerfile", - }, + "image": "ghcr.io/stability-ai/stability-sdk-devcontainer:latest", "customizations": { "vscode": { "settings": { diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 00000000..2c1106a1 --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,29 @@ +name: Build dev container image + +on: + workflow_dispatch: + push: + paths: + - ".devcontainer/" + - "pyproject.toml" + - ".github/workflows/devcontainer.yml" + +jobs: + prebuild: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Login to container registry + uses: docker/login-action@v2.1.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Pre-build dev container image + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/stability-ai/stability-sdk-devcontainer + cacheFrom: ghcr.io/stability-ai/stability-sdk-devcontainer + push: always \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 1d32a6c4..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "api-interfaces"] - path = src/stability_sdk/interfaces - url = https://github.com/stability-ai/api-interfaces diff --git a/nbs/demo_colab.ipynb b/nbs/demo_colab.ipynb index 0a08ebd0..6b6533ef 100644 --- a/nbs/demo_colab.ipynb +++ b/nbs/demo_colab.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -47,7 +48,7 @@ "from IPython.display import display\n", "from PIL import Image\n", "from stability_sdk import client\n", - "import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation\n", + "import stability_api.platform.generation.v1.generation_pb2 as generation\n", "\n", "\n", "stability_api = client.StabilityInference(\n", @@ -57,6 +58,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -100,6 +102,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ diff --git a/pyproject.toml b/pyproject.toml index 3471c6bc..2ea1eb93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Image Processing", ] dependencies = [ + "stability-api @ git+https://git@github.com/Stability-AI/api-interfaces.git@19fd1bf29b08cede4f1da6787ee06469ac7e39f0#egg=stability_api", "Pillow", "protobuf>=3.19,<5.0", "pydantic>=1.9.2,<2.0", @@ -44,6 +45,8 @@ dependencies = [ "grpcio>=1.45.0", ] +[tool.hatch.metadata] +allow-direct-references = true [project.optional-dependencies] sagemaker = [ diff --git a/src/stability_sdk/api.py b/src/stability_sdk/api.py index 860ba789..1df3c55c 100644 --- a/src/stability_sdk/api.py +++ b/src/stability_sdk/api.py @@ -7,8 +7,8 @@ from typing import Any, Dict, List, Optional import sys -import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation -import stability_sdk.interfaces.gooseai.generation.generation_pb2_grpc as generation_grpc +import stability_api.platform.generation.v1.generation_pb2 as generation +import stability_api.platform.generation.v1.generation_pb2_grpc as generation_grpc class TextPrompt(BaseModel): diff --git a/src/stability_sdk/client.py b/src/stability_sdk/client.py index f5100087..6294693d 100644 --- a/src/stability_sdk/client.py +++ b/src/stability_sdk/client.py @@ -26,8 +26,8 @@ else: load_dotenv() -import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation -import stability_sdk.interfaces.gooseai.generation.generation_pb2_grpc as generation_grpc +import stability_api.platform.generation.v1.generation_pb2 as generation +import stability_api.platform.generation.v1.generation_pb2_grpc as generation_grpc from stability_sdk.utils import ( SAMPLERS, diff --git a/src/stability_sdk/interfaces b/src/stability_sdk/interfaces deleted file mode 160000 index d8839bd9..00000000 --- a/src/stability_sdk/interfaces +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d8839bd97f5f3042fcd9ab9671a7503e8a518bec diff --git a/src/stability_sdk/utils.py b/src/stability_sdk/utils.py index 96b75a97..7908e89c 100644 --- a/src/stability_sdk/utils.py +++ b/src/stability_sdk/utils.py @@ -12,8 +12,8 @@ from PIL import Image -import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation -import stability_sdk.interfaces.gooseai.generation.generation_pb2_grpc as generation_grpc +import stability_api.platform.generation.v1.generation_pb2 as generation +import stability_api.platform.generation.v1.generation_pb2_grpc as generation_grpc logger = logging.getLogger(__name__) logger.setLevel(level=logging.INFO) diff --git a/tests/conftest.py b/tests/conftest.py index 1c0f084a..c1c6cbb4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,19 +4,12 @@ import pytest import logging -import pathlib -import sys - -thisPath = pathlib.Path(__file__).parent.parent.resolve() -genPath = thisPath / "src/stability_sdk/interfaces/gooseai/generation" -assert genPath.exists() - logger = logging.getLogger(__name__) #sys.path.extend([str(genPath), str(tensPath)]) -import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation -import stability_sdk.interfaces.gooseai.generation.generation_pb2_grpc as generation_grpc +import stability_api.platform.generation.v1.generation_pb2 as generation +import stability_api.platform.generation.v1.generation_pb2_grpc as generation_grpc # modified from https://github.com/justdoit0823/grpc-resolver/blob/master/tests/conftest.py diff --git a/tests/test_api.py b/tests/test_api.py index 1cf8144b..5ad6c026 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -3,8 +3,8 @@ import base64 from stability_sdk.api import CreateRequest, CreateResponse, GenerationResponse -from stability_sdk.interfaces.gooseai.generation.generation_pb2 import Answer, Artifact -import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation +from stability_api.platform.generation.v1.generation_pb2 import Answer, Artifact +import stability_api.platform.generation.v1.generation_pb2 as generation def test_text_to_image(): request = CreateRequest( diff --git a/tests/test_client.py b/tests/test_client.py index a17feb72..f6a62830 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -2,8 +2,8 @@ from PIL import Image from stability_sdk import client -import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation -import stability_sdk.interfaces.gooseai.generation.generation_pb2_grpc as generation_grpc +import stability_api.platform.generation.v1.generation_pb2 as generation +import stability_api.platform.generation.v1.generation_pb2_grpc as generation_grpc import grpc diff --git a/tests/test_utils.py b/tests/test_utils.py index a9c909c5..56f482de 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,5 @@ import pytest -import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation +import stability_api.platform.generation.v1.generation_pb2 as generation from stability_sdk.utils import ( SAMPLERS,