Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP platform api refactor #230

Draft
wants to merge 5 commits into
base: palp/sagemaker
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/stability-ai/stability-sdk-devcontainer
cacheFrom: ghcr.io/stability-ai/stability-sdk-devcontainer
push: always
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "api-interfaces"]
path = src/stability_sdk/interfaces
url = https://github.com/stability-ai/api-interfaces
5 changes: 4 additions & 1 deletion nbs/demo_colab.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -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",
Expand All @@ -57,6 +58,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -100,6 +102,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ classifiers = [
"Topic :: Scientific/Engineering :: Image Processing",
]
dependencies = [
"stability-api @ git+https://[email protected]/Stability-AI/api-interfaces.git@19fd1bf29b08cede4f1da6787ee06469ac7e39f0#egg=stability_api",
"Pillow",
"protobuf>=3.19,<5.0",
"pydantic>=1.9.2,<2.0",
"python-dotenv",
"grpcio>=1.45.0",
]

[tool.hatch.metadata]
allow-direct-references = true

[project.optional-dependencies]
sagemaker = [
Expand Down
4 changes: 2 additions & 2 deletions src/stability_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/stability_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/stability_sdk/interfaces
Submodule interfaces deleted from d8839b
4 changes: 2 additions & 2 deletions src/stability_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 2 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down