Skip to content

Bad exception experience loading a model #2567

Closed
@eerhardt

Description

@eerhardt

See this PR review comment: https://github.com/dotnet/machinelearning/pull/1951/files#r244808064.

try
{
ModelLoadContext.LoadModel<TransformerChain<ITransformer>, SignatureLoadModel>(env, out var transformerChain, rep, LoaderSignature);
return transformerChain;
}
catch
{
var chain = ModelFileUtils.LoadPipeline(env, stream, new MultiFileSource(null), extractInnerPipe: false);
TransformerChain<ITransformer> transformChain = (chain as CompositeDataLoader).GetTransformer();

This is causing a real problem with the Custom Mapping Transformer work that I'm doing.

When a user tries loading a model that contains a Custom Mapping Transformer, but we can't find that extension/contract we throw an exception during ModelLoadContext.LoadModel above saying Can't find extension 'foo'.

However, this code here eats that exception, tries doing something else and then throws a terrible exception Repository doesn't contain entry DataLoaderModel\Model.key, which makes absolutely no sense to the user.

We should change this code such that the original exception is thrown if we can't load the Pipeline. Maybe we could start writing a flag into a "pipeline" model file to tell if it is supposed to be a Pipeline or not...? If we don't see that flag, then for sure the exception from ModelLoadContext.LoadModel above should be thrown.

@TomFinley @Ivanidzo4ka - Thoughts?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions