Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions backend/app/modules/platform/artifacts_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ async def get_artifact(artifact_id: str) -> ArtifactResponse:


@router.get("", response_model=ArtifactListResponse)
async def list_artifacts(runId: Optional[str] = Query(None, description="Filter by runId")) -> ArtifactListResponse:
async def list_artifacts(
runId: Optional[str] = Query(None, description="Filter by runId"),
limit: int = Query(100, ge=1, le=1000, description="Maximum number of artifacts to return"),
offset: int = Query(0, ge=0, description="Number of artifacts to skip"),
) -> ArtifactListResponse:
service = get_service()
artifacts = service.list_artifacts(runId=runId)
artifacts = service.list_artifacts(runId=runId, limit=limit, offset=offset)
return ArtifactListResponse(
artifacts=[ArtifactResponse.model_validate(a) for a in artifacts],
total=len(artifacts),
Expand Down
10 changes: 6 additions & 4 deletions backend/app/services/artifact_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,22 @@ def get_artifact(self, artifact_id: str) -> Optional[Artifact]:
"""
return self.storage.get(artifact_id)

def list_artifacts(self, runId: Optional[str] = None) -> List[Artifact]:
def list_artifacts(self, runId: Optional[str] = None, limit: int = 100, offset: int = 0) -> List[Artifact]:
"""
List Artifacts with optional filters.
List Artifacts with optional filters and pagination.

Args:
runId: Optional runId filter
limit: Maximum number of artifacts to return (default 100)
offset: Number of artifacts to skip (default 0)

Returns:
List of artifacts matching filters, sorted by creation time (newest first)
"""
if runId:
return self.storage.list_by_run(runId)
return self.storage.list_by_run(runId, limit=limit, offset=offset)
else:
return self.storage.list_all()
return self.storage.list_all(limit=limit, offset=offset)


# Global service instance
Expand Down
20 changes: 14 additions & 6 deletions backend/app/storage/artifact_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ def get(self, artifact_id: str) -> Optional[Artifact]:

return self._deserialize_artifact(artifact_dict)

def list_all(self) -> List[Artifact]:
def list_all(self, limit: int = 100, offset: int = 0) -> List[Artifact]:
"""
List all Artifacts.
List all Artifacts with pagination.

Args:
limit: Maximum number of artifacts to return (default 100)
offset: Number of artifacts to skip (default 0)

Returns:
List of artifacts, sorted by creation time (newest first)
"""
Expand All @@ -125,14 +129,17 @@ def list_all(self) -> List[Artifact]:
# Sort by creation time (newest first)
artifacts.sort(key=lambda a: a.createdAt, reverse=True)

return artifacts
# Apply pagination
return artifacts[offset:offset + limit]

def list_by_run(self, runId: str) -> List[Artifact]:
def list_by_run(self, runId: str, limit: int = 100, offset: int = 0) -> List[Artifact]:
"""
List all Artifacts for a specific Run.
List all Artifacts for a specific Run with pagination.

Args:
runId: Run identifier
limit: Maximum number of artifacts to return (default 100)
offset: Number of artifacts to skip (default 0)

Returns:
List of artifacts linked to this run, sorted by creation time
Expand All @@ -148,7 +155,8 @@ def list_by_run(self, runId: str) -> List[Artifact]:

artifacts.sort(key=lambda a: a.createdAt, reverse=True)

return artifacts
# Apply pagination
return artifacts[offset:offset + limit]

def exists(self, artifact_id: str) -> bool:
"""
Expand Down