Skip to content

Commit 3f7f7ac

Browse files
markurtzCopilot
andauthored
Scheduler refactor [utils]: auto_importer, pydantic_utils, registry, singleton (#289)
## Summary This PR introduces four new utility modules that provide foundational capabilities for auto-discovery, registry patterns, singleton management, and enhanced Pydantic utilities. It additionally consolidates the pydantic utility classes from guidellm.objects into the dedicated guidellm.utils module containing the new additions. This change improves code organization and establishes the foundation for upcoming scheduler refactoring work. ## Details - **Moved core utilities** from `guidellm.objects.pydantic` to `guidellm.utils.pydantic_utils` - **Added `AutoImporterMixin`** for dynamic module discovery within packages - **Added `RegistryMixin`** for object registration with optional auto-discovery - **Added singleton mixins** (`SingletonMixin`, `ThreadSafeSingletonMixin`) for instance management - **Enhanced Pydantic utilities** with `ReloadableBaseModel`, `StandardBaseDict`, and `PydanticClassRegistryMixin` for polymorphic model serialization - **Updated all imports** across the codebase to reference new module locations - **Added comprehensive test coverage** for all new utility modules - **Removed obsolete** `guidellm.objects.pydantic` module and associated tests ## Test Plan - Run existing test suite to ensure no regressions from import changes - Execute new utility module test suites covering smoke, sanity, and regression scenarios ## Related Issues --- - [x] "I certify that all code in this PR is my own, except as noted below." ## Use of AI - [x] Includes AI-assisted code completion - [x] Includes code generated by an AI application - [ ] Includes AI-generated tests (NOTE: AI written tests should have a docstring that includes `## WRITTEN BY AI ##`) --------- Signed-off-by: Mark Kurtz <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent a99d1bc commit 3f7f7ac

25 files changed

+2651
-152
lines changed

src/guidellm/backend/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pydantic import computed_field
44

55
from guidellm.config import settings
6-
from guidellm.objects.pydantic import StandardBaseModel
6+
from guidellm.utils import StandardBaseModel
77

88
__all__ = [
99
"RequestArgs",

src/guidellm/benchmark/aggregator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
from guidellm.config import settings
2525
from guidellm.objects import (
2626
RunningStats,
27-
StandardBaseModel,
28-
StatusBreakdown,
2927
TimeRunningStats,
3028
)
3129
from guidellm.request import (
@@ -40,7 +38,7 @@
4038
SchedulerRequestResult,
4139
WorkerDescription,
4240
)
43-
from guidellm.utils import check_load_processor
41+
from guidellm.utils import StandardBaseModel, StatusBreakdown, check_load_processor
4442

4543
__all__ = [
4644
"AggregatorT",

src/guidellm/benchmark/benchmark.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
ThroughputProfile,
1414
)
1515
from guidellm.objects import (
16-
StandardBaseModel,
17-
StatusBreakdown,
1816
StatusDistributionSummary,
1917
)
2018
from guidellm.request import (
@@ -32,6 +30,7 @@
3230
ThroughputStrategy,
3331
WorkerDescription,
3432
)
33+
from guidellm.utils import StandardBaseModel, StatusBreakdown
3534

3635
__all__ = [
3736
"Benchmark",

src/guidellm/benchmark/benchmarker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
)
2323
from guidellm.benchmark.benchmark import BenchmarkArgs, GenerativeBenchmark
2424
from guidellm.benchmark.profile import Profile
25-
from guidellm.objects import StandardBaseModel
2625
from guidellm.request import (
2726
GenerationRequest,
2827
GenerativeRequestLoaderDescription,
@@ -37,6 +36,7 @@
3736
SchedulerRequestResult,
3837
SchedulingStrategy,
3938
)
39+
from guidellm.utils import StandardBaseModel
4040

4141
__all__ = ["Benchmarker", "BenchmarkerResult", "GenerativeBenchmarker"]
4242

src/guidellm/benchmark/output.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
from guidellm.config import settings
2424
from guidellm.objects import (
2525
DistributionSummary,
26-
StandardBaseModel,
2726
StatusDistributionSummary,
2827
)
2928
from guidellm.presentation import UIDataBuilder
3029
from guidellm.presentation.injector import create_report
3130
from guidellm.scheduler import strategy_display_str
32-
from guidellm.utils import Colors, split_text_list_by_length
31+
from guidellm.utils import Colors, StandardBaseModel, split_text_list_by_length
3332

3433
__all__ = [
3534
"GenerativeBenchmarksConsole",

src/guidellm/benchmark/profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pydantic import Field, computed_field
66

77
from guidellm.config import settings
8-
from guidellm.objects import StandardBaseModel
98
from guidellm.scheduler import (
109
AsyncConstantStrategy,
1110
AsyncPoissonStrategy,
@@ -15,6 +14,7 @@
1514
SynchronousStrategy,
1615
ThroughputStrategy,
1716
)
17+
from guidellm.utils import StandardBaseModel
1818

1919
__all__ = [
2020
"AsyncProfile",

src/guidellm/benchmark/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
from guidellm.backend.backend import BackendType
1313
from guidellm.benchmark.profile import ProfileType
14-
from guidellm.objects.pydantic import StandardBaseModel
1514
from guidellm.scheduler.strategy import StrategyType
15+
from guidellm.utils import StandardBaseModel
1616

1717
__ALL__ = ["Scenario", "GenerativeTextScenario", "get_builtin_scenarios"]
1818

src/guidellm/objects/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from .pydantic import StandardBaseModel, StatusBreakdown
21
from .statistics import (
32
DistributionSummary,
43
Percentiles,
@@ -11,8 +10,6 @@
1110
"DistributionSummary",
1211
"Percentiles",
1312
"RunningStats",
14-
"StandardBaseModel",
15-
"StatusBreakdown",
1613
"StatusDistributionSummary",
1714
"TimeRunningStats",
1815
]

src/guidellm/objects/pydantic.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/guidellm/objects/statistics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
from pydantic import Field, computed_field
88

9-
from guidellm.objects.pydantic import StandardBaseModel, StatusBreakdown
9+
from guidellm.utils import StandardBaseModel, StatusBreakdown
1010

1111
__all__ = [
1212
"DistributionSummary",

0 commit comments

Comments
 (0)