Add package disdantic to handle Pydantic polymorphic registries#919
Add package disdantic to handle Pydantic polymorphic registries#919SkiHatDuckie wants to merge 13 commits into
disdantic to handle Pydantic polymorphic registries#919Conversation
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
…odel with disdantic versions Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
Signed-off-by: SkiHatDuckie <SkiHatDuckie@gmail.com>
dbutenhof
left a comment
There was a problem hiding this comment.
Well that's interesting. I pulled this an ran a few tests. Something in this (I'm not quite sure what) has broken Sam's discovery-based CLI help code. A normal GuideLLM run works fine, but guidellm run --help generates this less than helpful message:
$ uv run guidellm run --help
usage: guidellm [-h] [--disdantic_.project_root Path] [--disdantic_.default_schema_discriminator str] [--disdantic_.registry_auto_discovery bool] [--disdantic_.auto_packages list[str]] [--disdantic_.auto_ignore_modules list[str]]
[--disdantic_.enable_schema_rebuilding bool] [--disdantic_.schema_rebuild_parents bool] [--disdantic_.info_exclude_keys list[str]]
Central configuration store and validation schema for the disdantic package.
This class serves as the single source of truth for runtime configurations,
defining default options and loading overrides dynamically across modules.
It integrates with Pydantic's BaseSettings to enforce type validation,
coercion, and environment prefixing.
Example:
.. code-block:: python
from disdantic.settings import Settings, get_settings
# Initialize a localized settings instance
settings = Settings(default_schema_discriminator="custom_type")
assert settings.default_schema_discriminator == "custom_type"
# Retrieve the global settings singleton instance
global_settings = get_settings()
print(global_settings.project_root)
options:
-h, --help show this help message and exit
--disdantic_.project_root Path
Maps the file system paths and resolves relative configuration files. (default factory: method)
--disdantic_.default_schema_discriminator str
Maps and retrieves model types within Pydantic registries using this key name. (default: model_type)
--disdantic_.registry_auto_discovery bool
Enables automatic scanning and loading of subclasses during registry initialization. (default: False)
--disdantic_.auto_packages list[str]
Configures target package namespaces to scan, enabling dynamic model discovery across submodules. (default factory: list)
--disdantic_.auto_ignore_modules list[str]
Configures submodule import paths to skip, mapping excluded modules during dynamic scanning. (default factory: list)
--disdantic_.enable_schema_rebuilding bool
Enables dynamic rebuilding of validation schemas, triggering Pydantic model schema rebuilds. (default: True)
--disdantic_.schema_rebuild_parents bool
Enables parent propagation, mapping validation schema updates up the subclass MRO hierarchy. (default: True)
--disdantic_.info_exclude_keys list[str]
Maps specific fields to skip and exclude during InfoMixin logging. (default factory: Settings.<lambda>)There was a problem hiding this comment.
I am not really seeing a benefit to this change. Looking at the disdantic package upstream it hasn't really bench touched outside the initial code dump and it doesn't look like anyone else is using it yet. The other project I know of that has this code is speculators and they still carry the code in-tree.
Not going to block but I think if we do merge (assuming Dave's comment is fixed). We likely want someone from GuideLLM to have maintainer access on that project.
I had much the same thought after looking through the repo. Doesn't necessarily mean it's a bad idea to use a package -- but you've got a good point about maintainer access to disdantic, and that power comes with the implication that we have to be willing to actually maintain our dependencies there given the lack of any real community around it. I'm not convinced that's a good idea. |
|
I'm personally fine with us sitting on this PR just to see if anything changes. As for the issue with --help getting hijacked: I've been doing some debugging and seems to be caused by disdantic's Pydantic |
Summary
Adds the disdantic package to supply the functionality for Pydantic subclass registries, dynamic polymorphism unions and automatic model discovery. This replaces multiple Pydantic utility classes that are currently GuideLLM's responsibility to maintain.
The motive for these changes was to assist in making GuideLLM simpler for maintainers and community members to contribute to by offloading functionality that is not necessarily the point of the software to elsewhere.
Many files have been changed, but many of those changes are just the switching around of imports. Files with substantial changes are mentioned in Details.
Details
pyproject.toml & tests/unit/test_settings.py
disdanticas a dependencyschemas/base.py
PydanticClassRegistryMixin. Replaced with a subclass of the same name which inheritsdisdantic.PydanticClassRegistryMixin, imported asBasePydanticClassRegistryMixin. Includes a couple methods that portions of GuideLLM expect which disdantic's version currently does not support:ReloadableBaseModel. Replaced withdisdantic.ReloadableBaseModelutils/registry.py
RegistryMixin. Replaced withdisdantic.RegistryMixinRegisterTandRegistryObjTremain. Although disdantic has equivalents to these, they are not included in__all__which makes me think they're not intended to be public facingtests/unit/schemas/test_base.py & tests/unit/utils/registry.py
benchmark/benchmarker.py
BenchmarkerMeta. This solely exists to avoid a metaclass conflict betweendisdantic.SingletonMetaandABCMetainBenchmarkerBenchmarkerscheduler/scheduler.py & tests/integration/scheduler/test_scheduler.py & tests/unit/scheduler/test_scheduler.py
ThreadSafeSingletonMixinwithdisdantic.SingletonMetainSchedulerSchedulerRemoved files:
disdantic.InfoMixin)disdantic.AutoImporterMixin)disdantic.SingletonMeta)Misc
Test Plan
uv sync --frozen, or some other means to update the local venvtoxRelated Issues
Use of AI
git log
commit e9c993f
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Thu Jul 2 09:24:46 2026 -0400
commit 42fc629
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Thu Jul 2 09:26:01 2026 -0400
commit 7fb7ea0
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Thu Jul 2 09:50:35 2026 -0400
commit c0cf7a4
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Thu Jul 2 09:56:22 2026 -0400
commit 8118bd6
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Mon Jul 6 14:28:51 2026 -0400
commit 98f5880
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Tue Jul 7 10:39:55 2026 -0400
commit cad523e
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Tue Jul 7 15:26:02 2026 -0400
commit de57e93
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Wed Jul 8 14:32:40 2026 -0400
commit a758165
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Wed Jul 8 15:05:20 2026 -0400
commit 11f66ff
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Wed Jul 8 16:30:03 2026 -0400
commit a14b49f
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Wed Jul 8 16:42:34 2026 -0400
commit 511699c
Author: SkiHatDuckie SkiHatDuckie@gmail.com
Date: Thu Jul 9 10:41:49 2026 -0400
Signed-off-by: SkiHatDuckie SkiHatDuckie@gmail.com