Skip to content

Commit

Permalink
Merge pull request #21 from wwakabobik/0.0.8
Browse files Browse the repository at this point in the history
0.0.8
  • Loading branch information
wwakabobik authored Nov 22, 2023
2 parents 50581e9 + 5c2c4b6 commit 2f8ddd0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Updated metadata
- Updated GitHub workflows

## [0.0.8] - 2023-11-22

### Changed
- Fixed wait_for_image_generation method (default is 0 now)
- Updated GitHub workflows (Python 3.12 added for linters)
- Bumped requirements
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "leonardo_api"
version = "0.0.7"
version = "0.0.8"
authors = [
{ name="Iliya Vereshchagin", email="[email protected]" },
]
Expand Down Expand Up @@ -33,6 +33,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = leonardo_api
version = attr: leonardo_api.0.0.7
version = attr: leonardo_api.0.0.8
author = Iliya Vereshchagin
author_email = [email protected]
maintainer = Iliya Vereshchagin
Expand All @@ -17,6 +17,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Operating System :: OS Independent
Intended Audience :: Developers
Intended Audience :: Information Technology
Expand Down
7 changes: 3 additions & 4 deletions src/leonardo_api/leonardo_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,12 @@ async def delete_custom_model_by_id(self, model_id: str):
self.___logger.error(f"Error delete custom model: {str(error)}")
raise

async def wait_for_image_generation(self, generation_id, image_index=None, poll_interval=5, timeout=120):
async def wait_for_image_generation(self, generation_id, image_index=0, poll_interval=5, timeout=120):
"""
This method waits for the completion of image generation.
:param generation_id: The ID of the generation to check.
:param image_index: (Optional) The index of the specific image to wait for.
If None, waits for all images to complete.
:param image_index: (Optional) The index of the specific image to wait for. Default is 0.
:param poll_interval: (Optional) The time interval in seconds between each check. Default is 5 seconds.
:param timeout: (Optional) Waiting timeout. Default is 120 seconds.
Expand All @@ -581,7 +580,7 @@ async def wait_for_image_generation(self, generation_id, image_index=None, poll_
if status == "COMPLETE":
images = generation.get("generated_images", [])
if image_index is not None:
if image_index >= len(images):
if len(images) <= image_index < 0:
raise IndexError("Incorrect image index")
return images[image_index]

Expand Down
4 changes: 2 additions & 2 deletions src/leonardo_api/leonardo_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def delete_custom_model_by_id(self, model_id: str):
self.___logger.error(f"Error delete custom model: {str(error)}")
raise

def wait_for_image_generation(self, generation_id, image_index=None, poll_interval=5, timeout=120):
def wait_for_image_generation(self, generation_id, image_index=0, poll_interval=5, timeout=120):
"""
This method waits for the completion of image generation.
Expand All @@ -562,7 +562,7 @@ def wait_for_image_generation(self, generation_id, image_index=None, poll_interv
if status == "COMPLETE":
images = generation.get("generated_images", [])
if image_index is not None:
if image_index >= len(images):
if len(images) <= image_index < 0:
raise IndexError("Incorrect image index")
return images[image_index]

Expand Down

0 comments on commit 2f8ddd0

Please sign in to comment.