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

[WIP] Backend: mock integration tests #906

Closed
wants to merge 8 commits into from

Conversation

ezawadski
Copy link
Collaborator

@ezawadski ezawadski commented Jan 14, 2025

Mocking Model Deployments in integrations tests

AI Description

This PR introduces several changes to the backend integration and unit tests, as well as updates to various files in the src/backend directory.

Backend Integration and Unit Tests

  • The backend_integration_tests.yml and backend_unit_tests.yml files have been updated to include additional steps for setting up the Python environment, installing dependencies, and configuring the test database.
  • The pytest_integration.ini file has been modified to include a new filter for warnings related to the pydantic module.

src/backend Directory

  • The model_deployments module has been updated to:
    • Modify the return type of the list_models method in the azure.py, bedrock.py, cohere_platform.py, sagemaker.py, and single_container.py files.
    • Change the method decorator of the list_models and is_available methods in the base.py file.
    • Update the parameter types of the invoke_rerank method in the azure.py, bedrock.py, cohere_platform.py, sagemaker.py, and single_container.py files.
  • The routers/organization.py file has been modified to use the model_dump() method instead of dict() when creating an organization.
  • The schemas/context.py file has been updated to:
    • Change the return type of several methods, including with_user, with_agent, with_model, with_deployment_config, with_conversation_id, with_stream_start_ms, with_agent_id, with_organization_id, with_organization, with_global_filtering, and without_global_filtering.
    • Add the Self type to the parameter of the with_user method.
  • The services/conversation.py file has been modified to:
    • Change the return type of the get_documents_to_rerank method.
    • Update the parameter types of the filter_conversations method.
  • The tests/integration/conftest.py file has been updated to include a return type for the client function.
  • The tests/integration/crud/test_deployment.py file has been modified to:
    • Add type annotations for the session and deployment parameters in several test functions.
    • Import the Session class from sqlalchemy.orm.
  • The tests/integration/crud/test_model.py file has been updated to:
    • Add type annotations for the session and deployment parameters in several test functions.
    • Import the Session class from sqlalchemy.orm.
  • The tests/integration/routers/test_agent.py file has been modified to:
    • Add type annotations for the user parameter in several test functions.
    • Import the User class from backend.schemas.user.
  • The tests/integration/routers/test_conversation.py file has been updated to:
    • Remove the os import.
    • Add a new variable _IS_GOOGLE_CLOUD_API_KEY_SET to store the result of Settings().get('google_cloud.api_key').
    • Modify several test functions to include the mock_available_model_deployments parameter.
  • The tests/integration/routers/test_model.py file has been updated to:
    • Add type annotations for the deployment parameter in several test functions.
    • Import the Session class from sqlalchemy.orm.
  • The tests/unit/model_deployments/mock_deployments/mock_azure.py, mock_bedrock.py, mock_sagemaker.py, and mock_single_container.py files have been modified to change the method decorator of the is_available method.
  • The tests/unit/model_deployments/mock_deployments/mock_cohere_platform.py file has been updated to:
    • Add the random import.
    • Change the method decorator of the is_available method.
    • Modify the invoke_chat and invoke_rerank methods to be asynchronous and include additional logic.
  • The tests/unit/routers/test_organization.py file has been modified to use the model_dump() method instead of dict() when creating an organization.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 95.74468% with 6 lines in your changes missing coverage. Please review.

Project coverage is 76.60%. Comparing base (802c232) to head (7fc86a9).

Files with missing lines Patch % Lines
...ployments/mock_deployments/mock_cohere_platform.py 71.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #906      +/-   ##
==========================================
- Coverage   76.64%   76.60%   -0.05%     
==========================================
  Files         259      259              
  Lines       10583    10590       +7     
==========================================
+ Hits         8111     8112       +1     
- Misses       2472     2478       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ezawadski ezawadski closed this Jan 15, 2025
@ezawadski ezawadski deleted the feat/mock_integration_tests branch January 15, 2025 17:39
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.

2 participants