Skip to content

[DRAFT] Added initial skeleton code for the remote vector index builder #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

rchitale7
Copy link
Member

Description

Initial skeleton for the remote vector index builder service. Contains the API routes, workflow execution logic, and more. Does not have the code for the object store client and faiss client yet.

This is a draft PR; I'm looking for feedback on the general structure/ideas in the code. If it looks good, i'll add comments to all the relevant functions and add unit tests, and raise a separate PR to main.

Issue Resolved

Related Issue: opensearch-project/k-NN#2545. TODO: Transfer issue to this repo.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@Rajrahane
Copy link
Member

Hi Rohan!
Can you please put all the service files in a remote-vector-index-build-service-worker folder?
We would be adding the custom-faiss-image code in this repo as well.


import logging

router = APIRouter()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little rusty on python, but I think this stuff can happen in __init__.py?

raise HTTPException(status_code=429, detail=str(e))
except CapacityError as e:
raise HTTPException(status_code=507, detail=str(e))
return CreateJobResponse(job_id=job_id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to explicitly specify 200 here?

# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
class BuildServiceError(Exception):
"""Base exception for build service errors"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably use this as the place to codify the status codes -> exceptions mappings then

Comment on lines +19 to +22
def can_allocate(self, gpu_memory: float, cpu_memory: float) -> bool:
with self._lock:
return (self._available_gpu_memory >= gpu_memory and
self._available_cpu_memory >= cpu_memory)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just keep this as a TODO, but I think we will want to separately track rejections due to GPU vs CPU

Comment on lines +1 to +2
fastapi[standard]>=0.113.0,<0.114.0
pydantic>=2.7.0,<3.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're vending an image here I think strict fixed versions is probably preferable. If this were a library then I would say the opposite though.

Signed-off-by: Rohan Chitale <[email protected]>
Signed-off-by: Rohan Chitale <[email protected]>
@navneet1v
Copy link
Collaborator

@Rajrahane is this PR still a draft PR?

@rchitale7
Copy link
Member Author

rchitale7 commented Feb 27, 2025

@navneet1v im going to close this and re-open as a PR to main, once I have unit tests written. Will also make the modifications suggested by @jed326

@rchitale7 rchitale7 closed this Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants