Skip to content
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

Implement Error Handling for Unsupported Model Types #10

Open
Blaizzy opened this issue Jul 11, 2024 · 0 comments
Open

Implement Error Handling for Unsupported Model Types #10

Blaizzy opened this issue Jul 11, 2024 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Blaizzy
Copy link
Collaborator

Blaizzy commented Jul 11, 2024

Description:

We need to improve our application's error handling by catching requests for unsupported model types and returning informative error responses. This will help users quickly understand when they're trying to use a model type that our system doesn't support.

Objective:

Create a mechanism to check if a requested model type is supported, and if not, return a clear error response.

Tasks:

  1. Create a list or set of supported model types in config.py.
  2. Implement a function to check if a given model type is supported.
  3. Modify the model loading or request handling process to use this check.
  4. Create a custom exception for unsupported model types.
  5. Update the API to catch this exception and return an appropriate HTTP response.

Example Implementation:

# In utils.py
MODELS= { "lm": ["gpt2", "bert", "t5", "llama"], "vlm": ["llava"]}

# In utils.py
from fastapi import HTTPException

class UnsupportedModelTypeError(Exception):
    pass

def is_supported_model_type(model_type: str) -> bool:
    return model_type.lower() in MODELS

def check_model_type(model_type: str) -> None:
    if not is_supported_model_type(model_type):
        raise UnsupportedModelTypeError(f"Model type '{model_type}' is not supported")

# In main.py or wherever model loading occurs
from fastapi import HTTPException

@app.post("/v1/load_model")
async def load_model(model_type: str, model_name: str):
    try:
        check_model_type(model_type)
        # Proceed with model loading
    except UnsupportedModelTypeError as e:
        raise HTTPException(status_code=400, detail=str(e))

Guidelines:

  • Keep the implementation simple and focused on the core functionality.
  • Ensure that the check for supported model types is case-insensitive.
  • Use clear and descriptive error messages.
  • Consider adding logging for unsupported model type requests.
  • Think about where in the request lifecycle this check should occur.

Resources:

Definition of Done:

  • Function to check for supported model types is created and working.
  • Custom exception for unsupported model types is implemented.
  • API endpoints are updated to use the new check and handle the custom exception.
  • Appropriate HTTP responses are returned for unsupported model types.
  • Basic logging for unsupported model type requests is implemented.
  • Code is commented and follows our style guide.

We're looking forward to your contribution! This feature will greatly improve the user experience by providing clear feedback when unsupported model types are requested. If you have any questions or need clarification, please don't hesitate to ask in the comments. Good luck!

@Blaizzy Blaizzy added help wanted Extra attention is needed good first issue Good for newcomers labels Jul 11, 2024
@Blaizzy Blaizzy pinned this issue Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant