nirs4all.pipeline.dagml.methods_lane module

Callback-free DAG-ML lane for pipelines of generic n4m role steps.

A generator-free or model-parameter-sweep pipeline whose steps are all n4m.roles estimators runs through DAG-ML’s native Methods estimator controllers (dag_ml._dag_ml.run_cv_refit_methods_in_process). DAG-ML compiles and schedules exactly the campaign of the host-callback lane — same fold set, envelope views, variant SELECT, FIT_CV, REFIT and scoring — while every node fits, transforms and predicts inside libn4m. Python only lowers the steps to n4m:<method_id> nodes, supplies the identity-keyed numeric rows once, and rebuilds the captured REFIT pipeline from the N4ME states for the existing joblib artifact contract.

native_methods_refusal() is the complete eligibility rule. A pipeline it refuses keeps the host-callback lane unchanged; the chosen lane is recorded on the result as per_dataset[...]["execution_lane"].

nirs4all.pipeline.dagml.methods_lane.lane_record(lane: str, reason: str | None = None) → dict[str, Any][source]

The provenance record of the lane one campaign ran on.

nirs4all.pipeline.dagml.methods_lane.merge_lane_records(records: list[dict[str, Any]]) → dict[str, Any][source]

One record for a result assembled from several campaigns.

nirs4all.pipeline.dagml.methods_lane.native_methods_refusal(steps: list[Any], spectro: Any, *, identity: Any, excluded: set[int] | None = None) → str | None[source]

Return why steps cannot run on the native Methods lane, or None.

steps are the splitter-free, model-parameter-applied steps of one DAG campaign. The native lane takes them when:

  • N4A_DAGML_NATIVE_METHODS does not disable it, the in-process DAG-ML mechanism is selected and the installed extension exposes the native Methods CV/REFIT lane;

  • the dataset is one single-source 2D block with no augmented rows, no repetition grouping, no held-out test partition and no sample excluded in the OOF universe;

  • every step before the model is an n4m.roles transformer or selector and the last step is {"model": <n4m.roles regressor or classifier>} (optionally with name) — a classifier exactly for a classification task, which then has one integral class column;

  • no method requires a fit input a DAG node cannot supply (sample weights, groups, feature groups, blocks, spectral axis, target domain, fold ids) or retains training rows in its fitted state;

  • every parameter has an exact native value (integral int, finite double), and a parameter sweep only produces exact native values: a _range_ over an int parameter has integral bounds and step, and a _log_range_ sweeps a double parameter.

Anything else keeps the host-callback lane.

nirs4all.pipeline.dagml.methods_lane.native_params(estimator: Any) → dict[str, Any][source]

Typed native parameter values of an n4m role estimator.

None leaves the native default, as the n4m Python binding does. A value without an exact native representation raises ValueError.

nirs4all.pipeline.dagml.methods_lane.record_execution_lane(result: Any, record: Mapping[str, Any]) → None[source]

Record the lane on every dataset entry of result.

nirs4all.pipeline.dagml.methods_lane.result_lane_record(result: Any) → dict[str, Any][source]

The lane record of a single-campaign-family result.

DAG runs outside the lowered concrete and parameter-sweep paths execute their operators through the host callback, so an unrecorded entry is a host-callback run.

nirs4all.pipeline.dagml.methods_lane.run_cv_refit_lane(*, steps: list[Any], dsl: dict[str, Any], envelope: dict[str, Any], spectro: Any, identity: Any, excluded: set[int] | None, selection_metric: str, refit: bool, refit_top_k: int, run_callback: Callable[[], dict[str, Any]]) → dict[str, Any][source]

Run one CV+REFIT campaign on the native Methods lane when eligible.

run_callback runs the unchanged host-callback campaign. Both lanes return the same outcome shape plus an execution_lane record; neither retries the other.