Ejemplo n.º 1
0
        public async Task RunAsync(CancellationToken token)
        {
            _logger.LogWarning("RfmTrainingWorker.RunAsync");

            var tableNames           = _options.TableNames;
            var tableStatisticsTasks = new List <Task <TableStatistics> >(tableNames.Count);

            foreach (string tableName in tableNames)
            {
                tableStatisticsTasks.Add(_tableStore.GetTableStatisticsAsync(tableName, token));
            }
            await Task.WhenAll(tableStatisticsTasks).ConfigureAwait(false);

            var tableDefinitionList = new List <TableDefinition>(tableStatisticsTasks.Count);

            for (int index = 0; index < tableStatisticsTasks.Count; ++index)
            {
                var result = tableStatisticsTasks[index].Result;
                if (result == null)
                {
                    _logger.LogWarning(string.Format("Statistics data for {0} table could not be retrieved. It will not participate in model training.", tableNames[index]));
                }
                else
                {
                    tableDefinitionList.Add(result.Definition);
                }
            }
            var modelStatistics = await _model.TrainAsync(_options.SchemaName, token, tableDefinitionList.ToArray()).ConfigureAwait(false);

            await UpdateRfmFacet(modelStatistics as RfmStatistics, token);
        }