diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 1f608b2..b9d95e2 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9856d5c..2e5f42b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 331b42f..897daca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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="i.vereshchagin@gmail.com" }, ] @@ -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", diff --git a/setup.cfg b/setup.cfg index cc6a0d8..4c86497 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 = i.vereshchagin@gmail.com maintainer = Iliya Vereshchagin @@ -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 diff --git a/src/leonardo_api/leonardo_async.py b/src/leonardo_api/leonardo_async.py index e8da24d..6dfd501 100644 --- a/src/leonardo_api/leonardo_async.py +++ b/src/leonardo_api/leonardo_async.py @@ -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. @@ -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] diff --git a/src/leonardo_api/leonardo_sync.py b/src/leonardo_api/leonardo_sync.py index 59908d5..3a14313 100644 --- a/src/leonardo_api/leonardo_sync.py +++ b/src/leonardo_api/leonardo_sync.py @@ -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. @@ -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]