Skip to content

Commit

Permalink
fix rebase screwups
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Nov 1, 2024
1 parent cad07a5 commit 8e3da6d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions llama_deploy/client/models/apiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

from .model import Collection, Model

DEFAULT_POLL_INTERVAL = 0.5


class Session(Model):
"""A model representing a session."""
Expand Down Expand Up @@ -58,6 +56,24 @@ async def create(self) -> Session:
model_class = self._prepare(Session)
return model_class(client=self.client, id=session_def.session_id)

async def list(self) -> list[Session]: # type: ignore
"""Returns a collection of all the sessions in the given deployment."""
sessions_url = (
f"{self.client.api_server_url}/deployments/{self.deployment_id}/sessions"
)
r = await self.client.request(
"GET",
sessions_url,
verify=not self.client.disable_ssl,
timeout=self.client.timeout,
)
model_class = self._prepare(Session)
items = [
model_class(client=self.client, id=session_def.session_id)
for session_def in r.json()
]
return items


class Task(Model):
"""A model representing a task belonging to a given session in the given deployment."""
Expand Down Expand Up @@ -98,7 +114,7 @@ async def events(self) -> AsyncGenerator[dict[str, Any], None]: # pragma: no co
except httpx.HTTPStatusError as e:
if e.response.status_code != 404:
raise # Re-raise if it's not a 404 error
await asyncio.sleep(DEFAULT_POLL_INTERVAL)
await asyncio.sleep(self.client.poll_interval)


class TaskCollection(Collection):
Expand Down

0 comments on commit 8e3da6d

Please sign in to comment.