Repository navigation
Description
Is your feature request related to a problem? Please describe.
Currently, it is possible to specify a custom model loader when adding a PredictionEnginePool to the servicecollection, as mentioned in this pull request #4393 . This is important in cases where you want to, for example, load a specific version of a model from something like Azure Blob Storage.
First of all, the official documentation makes no mention at all of this possibility. So this needs to be documented.
Secondly, when you want to add a model loader that needs access to the service provider, the AddPredictionEnginePool requires an implementationfactory with a lot of boilerplate, like so:
services.AddPredictionEnginePool<InputModel, OutputModel>(provider =>
{
IEnumerable<IConfigureOptions<PredictionEnginePoolOptions<InputModel, OutputModel>>>
configureOptionsList =
new List<IConfigureOptions<PredictionEnginePoolOptions<InputModel, OutputModel>>>()
{
new ConfigureOptions<PredictionEnginePoolOptions<InputModel, OutputModel>>(options=>
options.ModelLoader = new AzureModelLoader(provider))
};
IEnumerable<IPostConfigureOptions<PredictionEnginePoolOptions<InputModel, OutputModel>>>
postConfigures =
new List<IPostConfigureOptions<PredictionEnginePoolOptions<InputModel, OutputModel>>>();
var optionsfactory =
new OptionsFactory<PredictionEnginePoolOptions<InputModel, OutputModel>>(
configureOptionsList,postConfigures);
return new PredictionEnginePool<InputModel, OutputModel>(provider,
provider.GetRequiredService<IOptions<MLOptions>>(), optionsfactory);
});
It is also possible to add it through AddOptions like this:
services.AddOptions<PredictionEnginePoolOptions<InputModel, OutputModel>>().Configure(options =>
{
options.ModelLoader = new ModelLoader();
});
But this does not allow access to the serviceprovider.
Describe the solution you'd like
- Document this feature.
- Add a method to configure the
PredictionEnginePoolOptionswith the serviceprovider as a parameter:
services.AddPredictionEnginePoolOptions<InputModel, OutputModel>((provider, options) =>
{
options.ModelLoader = new ModelLoader(provider);
});
Describe alternatives you've considered
Using the AddOptions method.
Additional context
Add any other context or screenshots about the feature request here.
Activity
michaelgsharp commentedon Jan 23, 2024
@JakeRadMSFT @zewditu @LittleLittleCloud are any of you familiar with this?
rosebyte commentedon Sep 10, 2026
triage: we will keep it as a feature request