machinelearning icon indicating copy to clipboard operation
machinelearning copied to clipboard

Manually Trigger Engine Pool Refresh that's From URI

Open KevinDJones opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. I'm using the prediction engine pool from a URI as such:

services.AddPredictionEnginePool<ModelInput, ModelOutput>().FromUri(
    uri: $"{URI}",
    period: TimeSpan.FromMinutes(5));

Which is working great. However, I'd like to be able to get the engine pool updated on demand, rather than waiting up to 5 minutes for it to refresh itself.

Describe the solution you'd like Perhaps a method on the PredictionEnginePool class that allows for a refresh i.e. predictionEnginePool.RefreshFromUri()

Describe alternatives you've considered Can certainly shorten the period, but it seems unnecessary to have it checking every 30 seconds when I know exactly when it needs to update.

It could also be a local file using FromFile but the model lives elsewhere and I'd like it to stay that way.

Additional context Is this something that has been explored at all? I'm not opposed to taking a stab at it but want to make sure it's not something that's already been discussed/attempted/etc.

KevinDJones avatar Sep 22 '22 23:09 KevinDJones

@KevinDJones thanks for your suggestion. This isn't something we've discussed (to my knowledge). However, before you start on anything I'd like to make sure similar functionality isn't already available.

@michaelgsharp do you know if what @KevinDJones is trying to do is already possible?

luisquintanilla avatar Sep 23 '22 00:09 luisquintanilla

I'm not sure. @tarekgh do you know if services can be refreshed manually?

michaelgsharp avatar Oct 10 '22 19:10 michaelgsharp

I don't believe this is currently possible using our built-in ModelLoaders.

You could, however, write your own ModelLoader class, and inject that into the DI container. With your own ModelLoader, you can refresh it whenever you want.

To hook up your class, instead of calling FromUri or FromFile, instead call:

            builder.Services.AddOptions<PredictionEnginePoolOptions<TData, TPrediction>>(modelName)
                .Configure(poolOptions =>
                {
                    poolOptions.ModelLoader = new YourOwnModelLoader();
                });

eerhardt avatar Oct 13 '22 19:10 eerhardt

@luisquintanilla based on the prior comment its not something that is built in yet and would have to be custom. I'll add it to the future milestone for now but we can always discuss as needed.

michaelgsharp avatar Nov 28 '22 18:11 michaelgsharp