Skip to content

Commit

Permalink
5.1.2 client.constant -> client.constants fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zenafey committed Mar 27, 2024
1 parent f4daa1f commit e7b28eb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests
9 changes: 4 additions & 5 deletions prodiapy/_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from prodiapy.resources.engine import SyncAPIClient
from prodiapy.resources import constants
from prodiapy import resources
from typing import Optional
from prodiapy._exceptions import *
Expand All @@ -8,6 +9,7 @@


class Prodia(SyncAPIClient):
"""Prodia Client"""
api_key: str
sd: resources.StableDiffusion
sdxl: resources.StableDiffusionXL
Expand All @@ -24,10 +26,7 @@ def __init__(
- `api_key` from `PRODIA_API_KEY`
"""
if api_key is None:
raise AuthenticationError(
"The api_key client option must be set either by passing api_key to the client or by setting the \
PRODIA_API_KEY environment variable"
)
raise AuthenticationError(constants.AUTHENTICATION_ERROR)
self.api_key = api_key

super().__init__(
Expand All @@ -44,7 +43,7 @@ def __init__(
self.upscale = general.upscale
self.create = general.create
self.job = general.job
self.constant = general.constants
self.constants = general.constants
self.wait = general.wait

@property
Expand Down
18 changes: 8 additions & 10 deletions prodiapy/aio.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from typing import Optional
import os

from prodiapy.resources.engine import AsyncAPIClient
from prodiapy.resources import constants
from prodiapy import resources
from typing import Optional
from prodiapy._exceptions import *

import os
from prodiapy._exceptions import AuthenticationError


class Prodia(AsyncAPIClient):
"""Asynchronous Prodia Client"""
api_key: str
sd: resources.AsyncStableDiffusion
sdxl: resources.AsyncStableDiffusionXL
Expand All @@ -24,10 +25,7 @@ def __init__(
- `api_key` from `PRODIA_API_KEY`
"""
if api_key is None:
raise AuthenticationError(
"The api_key client option must be set either by passing api_key to the client or by setting the \
PRODIA_API_KEY environment variable"
)
raise AuthenticationError(constants.AUTHENTICATION_ERROR)
self.api_key = api_key

super().__init__(
Expand All @@ -44,10 +42,10 @@ def __init__(
self.upscale = general.upscale
self.create = general.create
self.job = general.job
self.constant = general.constants
self.constants = general.constants
self.wait = general.wait

@property
def auth_headers(self) -> dict:
api_key = self.api_key
return {'X-Prodia-Key': api_key, 'Content-Type': 'application/json'}
return {'X-Prodia-Key': api_key, 'Content-Type': 'application/json'}
3 changes: 3 additions & 0 deletions prodiapy/resources/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

AUTHENTICATION_ERROR = "The api_key client option must be set either by passing api_key to the client \
or by setting the PRODIA_API_KEY environment variable"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "prodiapy"
version = "5.1.1"
version = "5.1.2"
description = "Package for using Prodia API"
authors = ["zenafey <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit e7b28eb

Please sign in to comment.