Commit dc5b298
Fix type bug in build_trackers -- skip non-callable modules (#1249)
Summary:
Fix Pyre type error in `build_trackers()` where `load_module()` can return
a `ModuleType` that is then called as a factory function.
**Problem:**
- `load_module(factory_name)` returns `ModuleType | Callable | None`
- When the user passes a bare module path (no `:attr` suffix), a `ModuleType`
is returned, which is not callable
- Calling `factory(config)` on a `ModuleType` is a runtime `TypeError` and
a Pyre type error [29]
**Fix:**
- Add a `callable()` check after resolving the factory
- Non-callable modules are skipped with a descriptive warning guiding the user
to use `module.path:factory_function` syntax
- Rename intermediate variable to `resolved` so Pyre can narrow the type
before assigning to `factory`
**Cleanup:**
- Convert f-string log calls to `%s` formatting per TorchX conventions
Differential Revision: D959321841 parent b3b5388 commit dc5b298
2 files changed
Lines changed: 37 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
| 158 | + | |
| 159 | + | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
162 | 164 | | |
163 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
164 | 174 | | |
165 | | - | |
| 175 | + | |
166 | 176 | | |
167 | | - | |
| 177 | + | |
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
| |||
289 | 287 | | |
290 | 288 | | |
291 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
292 | 312 | | |
293 | 313 | | |
294 | 314 | | |
| |||
0 commit comments