unsloth/studio/backend/plugins
Daniel Han 35672fc9b3
Studio: keep pandas out of the backend startup import graph (#8962)
* Studio: keep pandas out of the backend startup import graph

* Hold the resolved pandas module in a global so a repeat call is not an import statement

* Resolve the unstructured seed plugin on first use, not at startup

Importing data_designer_unstructured_seed.chunking runs the package __init__
first, and that re-exports .config and .impl, which import the data designer
engine, which imports pandas and pyarrow. Dropping the module-scope import
inside chunking.py therefore left the whole cost in import main's graph
wherever the plugin is installed: measured 534ms cumulative for
routes.data_recipe.seed, with pandas and pyarrow both loaded.

The route resolves the plugin through _chunking() on first use instead. None
still means "not installed", so the existing 500 and the raw-text fallback
are unchanged, and the failed probe is remembered rather than retried per
request.

The runtime guards in test_startup_defers_torch.py pass vacuously wherever
the optional plugin is not installed, which is most CI jobs, so add a
source-level guard that reads seed.py and fails on a module-scope import of
the plugin either way. test_data_recipe_seed.py covers the availability
cases: unavailable without the plugin on both preview entry points, probed
once, raw text fallback, and the installed path.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten the comments on the deferred imports

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten comments in the deferred pandas import paths

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: oobabooga <112222186+oobabooga@users.noreply.github.com>
Co-authored-by: danielhanchen <unslothshared@gmail.com>
2026-08-18 00:14:50 -07:00
..
data-designer-github-repo-seed One interpreter leg on a pull request, and a floor lint that reads more than syntax (#9100) 2026-08-17 18:48:26 -07:00
data-designer-unstructured-seed Studio: keep pandas out of the backend startup import graph (#8962) 2026-08-18 00:14:50 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00