Skip to content

[BUG] export_code: forecaster-shaped fit example for all scitypes, is_pipeline false-positives, ignored dataset param, fails on loaded models #534

Description

@Shashankss1205

Severity: P1 — the generated artifact is wrong or unusable. Verified live 2026-08-09. Note: the string-escaping bug (BUG-02) is already fixed (commit c6b2fd7); these are the remaining export_code defects.

BUG-03 — fit example is forecaster-shaped for every scitype

export_code(handle, include_fit_example=true) always emits {var}.fit(y) + {var}.predict(fh=fh), regardless of object_type:

export_code(<BoxCoxTransformer>, include_fit_example=true)  -> runs, then AttributeError: no attribute 'predict'
export_code(<SlidingWindowSplitter>, include_fit_example=true) -> runs, then AttributeError: no attribute 'fit'

Fix: branch the example on the object_type tag — transformers get fit_transform(X), splitters get list(splitter.split(y)), classifiers/regressors get fit(X, y) + predict(X).

BUG-04 — is_pipeline heuristic false-positives on any list argument

is_pipeline = "*" in spec or "Pipeline" in spec or "[" in spec

SlidingWindowSplitter(window_length=24, fh=[1,2,3]) reports is_pipeline: true because of the [.
Fix: inspect the instantiated object (isinstance / object_type tag), not the spec string.

NB-15 — dataset parameter is ignored; fit example always hardcodes load_airline

export_code(<fitted NaiveForecaster>, dataset="sunspots", include_fit_example=true)
  -> emitted code contains `from sktime.datasets import load_airline`

Data-handle ids are also silently accepted as dataset and still produce airline. An estimator fitted via y_handle gets a fabricated airline example with no provenance note.
Fix: honor the documented param; reject unknown dataset names / handle ids, or state the example dataset in the output.

NB-17 — loaded models can't be exported

load_model(path=<saved model>)  -> handle with params: {}
export_code(<that handle>)      -> {"success": false, "error": "No craft spec found in handle parameters."}

load_model handles carry empty params, so codegen has no spec to work from.
Fix: reconstruct a spec from get_params() (or repr) at load time so loaded models are exportable.

(Catalogued as BUG-03 / BUG-04 / NB-15 / NB-17 in MCP_TEST_FINDINGS.md.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions