Commit b70ec18
feat: add load_model tool for resolving trained models (#45)
*Note: I realize #32 was just assigned to someone else, but I had
already finished these changes locally before it was assigned because no
contributor asked to take upon this issue at that time. I figured I
would put the PR up just in case having it done is helpful to the
project.*
#### Reference Issues/PRs
Closes #32
#### What does this implement/fix? Explain your changes.
This implements a new `load_model` tool to allow LLMs to restore
previously trained estimators from a local directory or URI without
having to re-fit the data from scratch.
**Implementation Details:**
- Created `load_model_tool` in `src/sktime_mcp/tools/instantiate.py`.
- Gracefully handles the optional `mlflow` dependency. If `mlflow` is
missing, it returns a clear error message instructing the user/LLM to
run `pip install sktime[mlflow]` rather than crashing the server.
- Registers the loaded estimator instance dynamically back into the
`HandleManager` marking it as fitted, allowing the LLM to immediately
follow up with a `predict` call using the newly restored handle.
- Added the tool routing logic to `call_tool` in `server.py`.
#### Does your contribution introduce a new dependency? If yes, which
one?
No new hard dependencies. `mlflow` is utilized as an optional extension
(`sktime[mlflow]`), strictly matching `sktime`'s existing dependency
strategy.
#### Demo Video
[load_model.webm](https://github.com/user-attachments/assets/d36c8be5-8736-4ec5-be95-2bd534db799a)
Co-authored-by: Shashank Shekhar Singh <123410790+Shashankss1205@users.noreply.github.com>1 parent 57580b8 commit b70ec18
2 files changed
Lines changed: 71 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
473 | 474 | | |
474 | 475 | | |
475 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
476 | 491 | | |
477 | 492 | | |
478 | 493 | | |
| |||
612 | 627 | | |
613 | 628 | | |
614 | 629 | | |
| 630 | + | |
| 631 | + | |
615 | 632 | | |
616 | 633 | | |
617 | 634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
0 commit comments