public Response QueryLastTrainingState(Guid modelId)
        {
            modelId.CheckArgumentEmpty(nameof(modelId));

            var             modelConfig       = GetModelConfig(modelId);
            var             modelConfigArg    = new ConstructorArgument("modelConfig", modelConfig);
            var             userConnectionArg = new ConstructorArgument("userConnection", UserConnection);
            IMLModelTrainer trainer           = ClassFactory.Get <IMLModelTrainer>(userConnectionArg, modelConfigArg);

            TrainSessionState[] notInProgressStates =
            {
                TrainSessionState.NotStarted, TrainSessionState.Done, TrainSessionState.Error
            };
            if (!notInProgressStates.Contains(modelConfig.CurrentState))
            {
                if (modelConfig.TrainSessionId.IsEmpty())
                {
                    var message = $"Model {modelId} has state {modelConfig.CurrentState}, but TrainSessionId is empty";
                    _log.Error(message);
                    throw new InvalidObjectStateException(message);
                }
                trainer.UpdateModelState();
            }
            return(new Response {
                Value = modelConfig.CurrentState.ToString()
            });
        }
Ejemplo n.º 2
0
 private static void QueryTrainingState(IMLModelTrainer trainer, Guid modelId)
 {
     try {
         trainer.UpdateModelState();
     } catch (Exception e) {
         _log.ErrorFormat("Error occurred while trying to update training state for ML model {0}", e, modelId);
     }
 }