From 82bd0d0a27be410ba58675a5adff6c1d0b34e1c1 Mon Sep 17 00:00:00 2001 From: benshuk Date: Tue, 3 Jun 2025 13:19:24 +0300 Subject: [PATCH 1/3] fix: :recycle: expose `poll_for_status` function --- ai21/clients/common/maestro/run.py | 2 +- ai21/clients/studio/resources/maestro/run.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ai21/clients/common/maestro/run.py b/ai21/clients/common/maestro/run.py index b729c835..df6bdc29 100644 --- a/ai21/clients/common/maestro/run.py +++ b/ai21/clients/common/maestro/run.py @@ -66,7 +66,7 @@ def retrieve(self, run_id: str) -> RunResponse: pass @abstractmethod - def _poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: + def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: pass @abstractmethod diff --git a/ai21/clients/studio/resources/maestro/run.py b/ai21/clients/studio/resources/maestro/run.py index 5a49176d..7bb45fba 100644 --- a/ai21/clients/studio/resources/maestro/run.py +++ b/ai21/clients/studio/resources/maestro/run.py @@ -53,7 +53,7 @@ def retrieve( ) -> RunResponse: return self._get(path=f"/{self._module_name}/{run_id}", response_cls=RunResponse) - def _poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: + def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: start_time = time.time() while True: @@ -92,7 +92,7 @@ def create_and_poll( **kwargs, ) - return self._poll_for_status(run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec) + return self.poll_for_status(run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec) class AsyncMaestroRun(AsyncStudioResource, BaseMaestroRun): @@ -127,7 +127,7 @@ async def retrieve( ) -> RunResponse: return await self._get(path=f"/{self._module_name}/{run_id}", response_cls=RunResponse) - async def _poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: + async def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: start_time = time.time() while True: @@ -166,6 +166,4 @@ async def create_and_poll( **kwargs, ) - return await self._poll_for_status( - run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec - ) + return await self.poll_for_status(run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec) From 0569d39d82a63ef27f91187f5df181406c1b347a Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 5 Jun 2025 13:26:46 +0300 Subject: [PATCH 2/3] refactor: :recycle: update `poll_for_status` method parameters to use consistent naming convention --- ai21/clients/common/maestro/run.py | 2 +- ai21/clients/studio/resources/maestro/run.py | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ai21/clients/common/maestro/run.py b/ai21/clients/common/maestro/run.py index df6bdc29..f7e7e20a 100644 --- a/ai21/clients/common/maestro/run.py +++ b/ai21/clients/common/maestro/run.py @@ -66,7 +66,7 @@ def retrieve(self, run_id: str) -> RunResponse: pass @abstractmethod - def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: + def poll_for_status(self, *, run_id: str, poll_interval_sec: float, poll_timeout_sec: float) -> RunResponse: pass @abstractmethod diff --git a/ai21/clients/studio/resources/maestro/run.py b/ai21/clients/studio/resources/maestro/run.py index 7bb45fba..c8b7f690 100644 --- a/ai21/clients/studio/resources/maestro/run.py +++ b/ai21/clients/studio/resources/maestro/run.py @@ -53,7 +53,7 @@ def retrieve( ) -> RunResponse: return self._get(path=f"/{self._module_name}/{run_id}", response_cls=RunResponse) - def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: + def poll_for_status(self, *, run_id: str, poll_interval_sec: float, poll_timeout_sec: float) -> RunResponse: start_time = time.time() while True: @@ -62,10 +62,10 @@ def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: fl if run.status in TERMINATED_RUN_STATUSES: return run - if (time.time() - start_time) >= poll_timeout: + if (time.time() - start_time) >= poll_timeout_sec: return run - time.sleep(poll_interval) + time.sleep(poll_interval_sec) def create_and_poll( self, @@ -92,7 +92,9 @@ def create_and_poll( **kwargs, ) - return self.poll_for_status(run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec) + return self.poll_for_status( + run_id=run.id, poll_interval_sec=poll_interval_sec, poll_timeout_sec=poll_timeout_sec + ) class AsyncMaestroRun(AsyncStudioResource, BaseMaestroRun): @@ -127,7 +129,7 @@ async def retrieve( ) -> RunResponse: return await self._get(path=f"/{self._module_name}/{run_id}", response_cls=RunResponse) - async def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeout: float) -> RunResponse: + async def poll_for_status(self, *, run_id: str, poll_interval_sec: float, poll_timeout_sec: float) -> RunResponse: start_time = time.time() while True: @@ -136,10 +138,10 @@ async def poll_for_status(self, *, run_id: str, poll_interval: float, poll_timeo if run.status in TERMINATED_RUN_STATUSES: return run - if (time.time() - start_time) >= poll_timeout: + if (time.time() - start_time) >= poll_timeout_sec: return run - await asyncio.sleep(poll_interval) + await asyncio.sleep(poll_interval_sec) async def create_and_poll( self, @@ -166,4 +168,6 @@ async def create_and_poll( **kwargs, ) - return await self.poll_for_status(run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec) + return await self.poll_for_status( + run_id=run.id, poll_interval_sec=poll_interval_sec, poll_timeout_sec=poll_timeout_sec + ) From cd97e2324b67cc5d1fc1bba2b548715e337b6422 Mon Sep 17 00:00:00 2001 From: benshuk Date: Sun, 8 Jun 2025 11:12:05 +0300 Subject: [PATCH 3/3] chore: :wrench: update CI configuration to use ubuntu-latest --- .github/workflows/semantic-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 49e2017c..dc9fae55 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -13,7 +13,7 @@ on: jobs: semantic-pr: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest timeout-minutes: 1 steps: - name: Semantic pull-request