コード例 #1
0
        public async Task RemoveModel()
        {
            _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, "Working | remove model...");
            try
            {
                if (SelectedInstalledModel == null)
                {
                    throw new Exception("No selected model.");
                }

                var config = new MLModelConfig();
                config.Image.Name   = SelectedInstalledModel.Name;
                config.Type         = SelectedInstalledModel.Type;
                config.ModelVersion = SelectedInstalledModel.Version;
                config.ApiVersion   = SelectedInstalledModel.ApiVersion;
                config.Image.Tag    = config.GetDockerTag();

                using (var model = new MLModel(config))
                    await model.Remove();

                if (SelectedInstalledModel.Name == Repository &&
                    Version == $"{SelectedInstalledModel.Version}" &&
                    API_VERSION == SelectedInstalledModel.ApiVersion &&
                    Type == $"{config.Type}")
                {
                    Repository = "None";
                    Type       = "None";
                    Version    = "None";
                    Status     = "Not ready";
                    await UpdateModelStatus();
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Unable to remove ml model.");
            }
            _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, "");
        }