Commit 01c2fe7
[LLM] Fix dependency graph paper cuts: move imports to top level
Addresses two violations from #57890:
1. Move CloudFileSystem import from inside on_before_download_model_files_distributed()
to module top level in cloud_downloader.py.
2. Audit all imports in python/ray/llm/_internal and move unjustified
function-body imports to module top level:
- common/utils/lora_utils.py: filelock.FileLock
- batch/observability/usage_telemetry/usage.py: TagKey, HEAD_NODE_RESOURCE_NAME,
PlacementGroupSchedulingStrategy
- serve/observability/usage_telemetry/usage.py: TagKey, HEAD_NODE_RESOURCE_NAME,
PlacementGroupSchedulingStrategy, AcceleratorType, AutoscalingConfig
Remaining deferred imports are intentional:
- serve/core/ingress/builder.py: LLMRouter kept lazy — router.py instantiates
FastAPI() at module level with @serve.ingress(), which breaks Sphinx autodoc
when fastapi is mocked.
- Optional deps (vllm, transformers, sglang, huggingface_hub) stay lazy.
- VLLMEngine/VLLMEngineConfig stay lazy to avoid hard vllm module-level dep.
- Benchmark CLI imports stay lazy for startup performance.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: ps2181 <hellopritam31@gmail.com>1 parent 0907fcf commit 01c2fe7
4 files changed
Lines changed: 11 additions & 19 deletions
File tree
- python/ray/llm/_internal
- batch/observability/usage_telemetry
- common
- callbacks
- utils
- serve/observability/usage_telemetry
Lines changed: 3 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | | - | |
93 | | - | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 110 | | |
114 | 111 | | |
115 | 112 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | | - | |
78 | | - | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
116 | | - | |
117 | | - | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
175 | | - | |
176 | | - | |
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
| |||
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
255 | | - | |
256 | 254 | | |
257 | 255 | | |
258 | 256 | | |
| |||
288 | 286 | | |
289 | 287 | | |
290 | 288 | | |
291 | | - | |
292 | | - | |
293 | 289 | | |
294 | 290 | | |
295 | 291 | | |
| |||
0 commit comments