Skip to content

chore(BA-1005): Migrate to pydantic in manager configuration #3994

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

HyeockJinKim
Copy link
Collaborator

resolves #3993 (BA-1005)

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue
  • Installer updates including:
    • Fixtures for db schema changes
    • New mandatory config options
  • Update of end-to-end CLI integration tests in ai.backend.test
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

@HyeockJinKim HyeockJinKim requested a review from fregataa March 17, 2025 03:12
@HyeockJinKim HyeockJinKim self-assigned this Mar 17, 2025
@Copilot Copilot AI review requested due to automatic review settings March 17, 2025 03:12
@github-actions github-actions bot added the size:XL 500~ LoC label Mar 17, 2025
Copy link
Contributor

@Copilot 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 migrates the manager configuration to use pydantic by introducing new models for managing volume configuration.

  • Added pydantic models for virtual folder types (VFolderTypeConfig) and proxies (VFolderProxyConfig).
  • Introduced a VolumeConfig model consolidating configuration details for virtual folders and volume proxies.
Comments suppressed due to low confidence (1)

src/ai/backend/manager/config/volume.py:72

  • [nitpick] The default factory for '_types' in VolumeConfig only sets a default value for 'user' but leaves 'group' as None. If both configurations are intended to be initialized similarly, consider providing a default for 'group' as well.
default_factory=lambda: VFolderTypeConfig(user={}),

@github-actions github-actions bot added the comp:manager Related to Manager component label Mar 17, 2025
@HyeockJinKim HyeockJinKim changed the title feat(BA-1005): Migrate to pydantic in manager configuration chore(BA-1005): Migrate to pydantic in manager configuration Mar 17, 2025
@HyeockJinKim HyeockJinKim force-pushed the refactor/move-to-pydantic-config-manager branch from 667c5cc to 01796c3 Compare March 17, 2025 04:05
Comment on lines +83 to +111
pool_size: int = Field(
default=8,
ge=1,
description="""
Size of the database connection pool.
Determines how many concurrent database connections to maintain.
Should be tuned based on expected load and database server capacity.
""",
examples=[1, 8],
)
pool_recycle: float = Field(
default=-1,
ge=-1,
description="""
Maximum lifetime of a connection in seconds before it's recycled.
Set to -1 to disable connection recycling.
Useful to handle cases where database connections are closed by the server after inactivity.
""",
examples=[-1, 50],
)
pool_pre_ping: bool = Field(
default=False,
description="""
Whether to test connections with a lightweight ping before using them.
Helps detect stale connections before they cause application errors.
Adds a small overhead but improves reliability.
""",
examples=[True],
)
Copy link
Member

Choose a reason for hiding this comment

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

Could you leave the SQLAlchemy reference of the settings?
More refs are here.
pool_recycle , pool_pre_ping

default=False,
description="""
Whether to use the experimental Redis-based event dispatcher.
May provide better performance for event handling in large clusters.
Copy link
Member

Choose a reason for hiding this comment

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

The reason we implemented this dispatcher is because the redis-py async module seems to have issues. (It is not because of performance)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most of the descriptions are written by the copilot, but I'll check the whole thing once.

Limits the complexity of queries to prevent abuse.
Set to None to disable the limit.
""",
examples=[None, 10, 15],
Copy link
Member

Choose a reason for hiding this comment

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

How does pydantic.Field convert null value to None? Users should be able to set null values through config explicitly

@HyeockJinKim HyeockJinKim force-pushed the refactor/move-to-pydantic-config-manager branch from 459a517 to 7e93d9d Compare April 11, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:manager Related to Manager component size:XL 500~ LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to pydantic based manager configuration schema
2 participants