Skip to content

[WIP]♻️ refactor me model module.#1151

Closed
porkpink wants to merge 1 commit intodevelopfrom
jpl/jpl_0829
Closed

[WIP]♻️ refactor me model module.#1151
porkpink wants to merge 1 commit intodevelopfrom
jpl/jpl_0829

Conversation

@porkpink
Copy link
Contributor

@porkpink porkpink commented Sep 8, 2025

♻️ refactor me model module.

Copilot AI review requested due to automatic review settings September 8, 2025 03:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the ME (Model Engine) model module by extracting functionality from the app layer into dedicated service modules and consolidating test files.

  • Separates business logic from API layer by moving implementation to service modules
  • Creates comprehensive test coverage for the extracted service functionality
  • Consolidates ME model management tests into dedicated test files

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/backend/services/test_me_model_management_service.py New comprehensive test file for ME model management service functionality
test/backend/app/test_me_model_managment_app.py Updated app tests to use mocked service functions and improved test structure
backend/services/model_health_service.py Added new connectivity check implementation and improved code formatting
backend/services/me_model_management_service.py New service module containing extracted ME model management logic
backend/apps/me_model_managment_app.py Refactored to use service layer and simplified API endpoints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"status": "Disconnected",
"connect_status": ModelConnectStatusEnum.UNAVAILABLE.value
"desc": "Connection failed, error code: 404",
"connect_status": "unavailable" # 使用实际的值
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

Chinese comment should be in English. Replace '使用实际的值' with 'using actual value' for consistency with the codebase language.

Copilot uses AI. Check for mistakes.
"status": "Disconnected",
"connect_status": ModelConnectStatusEnum.UNAVAILABLE.value
"desc": "Connection timeout",
"connect_status": "unavailable" # 使用实际的值
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

Chinese comment should be in English. Replace '使用实际的值' with 'using actual value' for consistency with the codebase language.

Copilot uses AI. Check for mistakes.
assert "Connection failed" in response_data["message"]
assert "Test exception" in response_data["message"]
assert response_data["data"]["status"] == "Disconnected"
# 使用实际的值
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

Chinese comment should be in English. Replace '使用实际的值' with 'using actual value' for consistency with the codebase language.

Suggested change
# 使用实际的值
# using actual value

Copilot uses AI. Check for mistakes.
Comment on lines 4 to 9

from consts.const import MODEL_ENGINE_APIKEY, MODEL_ENGINE_HOST
from consts.exceptions import TimeoutException


async def get_me_models_impl(timeout, type):
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

Missing type hints for function parameters. Add type annotations for 'timeout' (int) and 'type' (Optional[str]) parameters and return type (List[Dict]).

Suggested change
from consts.const import MODEL_ENGINE_APIKEY, MODEL_ENGINE_HOST
from consts.exceptions import TimeoutException
async def get_me_models_impl(timeout, type):
from typing import List, Dict, Optional
from consts.const import MODEL_ENGINE_APIKEY, MODEL_ENGINE_HOST
from consts.exceptions import TimeoutException
async def get_me_models_impl(timeout: int, type: Optional[str]) -> List[Dict]:

Copilot uses AI. Check for mistakes.
from consts.exceptions import TimeoutException


async def get_me_models_impl(timeout, type):
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

Missing docstring for the function. Add a docstring explaining the function's purpose, parameters, return value, and possible exceptions.

Suggested change
async def get_me_models_impl(timeout, type):
async def get_me_models_impl(timeout, type):
"""
Fetches a list of models from the model engine API, optionally filtering by type.
Parameters:
timeout (float): The total timeout for the request in seconds.
type (str or None): The type of model to filter for. If None, returns all models.
Returns:
list: A list of model data dictionaries, filtered by the specified type if provided.
Raises:
TimeoutException: If the request times out.
Exception: If no models of the specified type are found, or if another request error occurs.
"""

Copilot uses AI. Check for mistakes.
@porkpink porkpink changed the title ♻️ refactor me model module. [WIP]♻️ refactor me model module. Sep 8, 2025
"message": "Successfully retrieved",
"data": filtered_result
}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是否需要保留原有的408超时错误处理逻辑?

@porkpink porkpink closed this Sep 8, 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.

2 participants