LoadRunModelUnit
Restore a run's trained model for an explanation.
Deliberately not LoadTrainedModelUnit, and the difference is not
cosmetic to preserve even though it is very likely accidental:
- this unit builds an instance with
model_class(**run.parameters)and only then callsloadon it, the way the explanation flow always has; LoadTrainedModelUnitcallsloadstraight on the class.
Every concrete model in this codebase declares load as a
staticmethod or a classmethod that rebuilds the object from the
file, so the instance built here is thrown away and the extra step changes
nothing — and no explainer reads anything that __init__ sets: the only
model attributes any of them touch (one_hot_encoder,
categorical_columns, label_encoder) are set during training and
restored from the artifact.
The two units are kept apart because merging them would have to unify their error messages, which are user-visible and differ word for word. Do not collapse them into one with a flag without deciding that first.
Parameters
- run_id : integer, default=
1 - Identifier of the run whose trained model is restored. The model component, its parameters and the artifact path all come from that row.
Methods
execute(self, ctx: DashAI.back.units.context.ExecutionContext) -> None
LoadRunModelUnitDo the unit's work, reading from and writing to the context.
Parameters
- ctx : ExecutionContext
- The shared execution context.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
validate(self, ctx: DashAI.back.units.context.ExecutionContext) -> None
BaseUnitCheck preconditions without executing the unit.
Parameters
- ctx : ExecutionContext
- The shared execution context.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.