Runware/sdk-python

None is returned when calling imageInference() with invalid numberResults value e.g 0 or -1.

adilentiq opened this issue · 1 comments

Description

None is returned when calling imageInference() with invalid numberResults value e.g 0 or -1

Context

Runware Python SDK version: runware==0.2.7

Requirements

  • Python installed on your workstation

Reproduction steps

  1. Create a directory

  2. Create a file e.g my_test.py with the following content:

from runware import Runware, IImageInference, IControlNetCanny
import asyncio
import os
from dotenv import load_dotenv

load_dotenv()


async def main() -> None:
    runware = Runware(
        api_key=os.getenv("RUNWARE_API_KEY"), url=os.getenv("RUNWARE_WSS_URL")
    )

    await runware.connect()

    request_image = IImageInference(
        positivePrompt="a beautiful sunset over the mountains",
        negativePrompt="cloudy, rainy",
        model=os.getenv("RUNWARE_MODEL"),
        lora= [],
        numberResults=0,
        height=512,
        width=512,
        outputType=["URL"],
    )


    print(f"Payload: {request_image}")

    images = await runware.imageInference(requestImage=request_image)

    print(f"Images: {images}")


asyncio.run(main())
  1. Create a virtual environment
python -m venv venv
  1. Activate venv environment
# Windows
venv\Scripts\activate

# Linux/MacOS
 source venv/bin/activate
  1. Create a requirements.txt file with the following content:
aiofiles==23.2.1
asyncio==3.4.3
python-dotenv==1.0.1
runware==0.2.7
websockets==12.0
  1. Install project dependencies:
 pip install -r requirements.txt
  1. Create .env file and set up environment variables
touch .env
source .env

Example

RUNWARE_API_KEY="your_runware_api_key"
RUNWARE_URL="wss://ws-api.runware.ai/v1"
RUNWARE_MODEL="runware:100@1"
  1. Run the python script
python my_test.py

Actual result

$ python ./text_to_image.py 
Payload: IImageInference(positivePrompt='a beautiful sunset over the mountains', model='civitai:81458@132760', taskUUID=None, outputType=['URL'], outputFormat=None, uploadEndpoint=None, checkNsfw=None, negativePrompt='cloudy, rainy', seedImage=None, maskImage=None, strength=None, height=512, width=512, steps=None, scheduler=None, seed=None, CFGScale=None, clipSkip=None, usePromptWeighting=None, numberResults=0, controlNet=[], lora=[], includeCost=None, useCache=None, onPartialImages=None)
Images: None

Expected result

I was expecting to receive an error.

@adilentiq I've added validation