public static async Task RegisterForecastTaskChainAsync( this ITaskManager taskManager, TimeSpan expiresAfter) { // Define workers parameters // datasource for PurchaseOutcomeModel projection var interactionDataSourceOptionsDictionary = new InteractionDataSourceOptionsDictionary(new InteractionExpandOptions(IpInfo.DefaultFacetKey), 5, 10); var modelTrainingOptions = new ModelTrainingTaskOptions( // assembly name of our processing engine model (PurchaseInteractionModel:IModel<Interaction>) typeof(PurchaseInteractionModel).AssemblyQualifiedName, // assembly name of entity for our processing engine model (PurchaseInteractionModel:IModel<Interaction>) typeof(Interaction).AssemblyQualifiedName, // custom options that we pass to PurchaseInteractionModel new Dictionary <string, string> { ["TestCaseId"] = "Id" }, // projection tableName of PurchaseOutcomeModel, must be equal to first parameter of 'CreateTabular' method => PurchaseInteractionModel.cs: CreateTabular("PurchaseOutcome", ...) "PurchaseOutcome", // name of resulted table (any name) "DemoResultTable"); await taskManager.RegisterModelTrainingTaskChainAsync(modelTrainingOptions, interactionDataSourceOptionsDictionary, expiresAfter); }
public static async Task <Guid> RegisterRfmModelTrainingTaskChainAsync( this ITaskManager taskManager, ModelTrainingTaskOptions modelTrainingOptions, IDataSourceOptionsCollection dataSourceOptions, TimeSpan expiresAfter, IEnumerable <Guid> prerequisiteTaskIds) { var projectionDictionary = new ProjectionWorkerOptionsDictionary( modelTrainingOptions.ModelEntityTypeString, modelTrainingOptions.ModelTypeString, expiresAfter, modelTrainingOptions.SchemaName, modelTrainingOptions.ModelOptions); Guid guid = await taskManager.RegisterDistributedTaskAsync(dataSourceOptions, projectionDictionary, prerequisiteTaskIds, expiresAfter).ConfigureAwait(false); var mergeTasks = new List <Task <Guid> >(); foreach (var targetTableNames in modelTrainingOptions.SourceTargetTableNamesMap) { var optionsDictionary1 = new MergeWorkerOptionsDictionary(targetTableNames.Value, targetTableNames.Key, expiresAfter, modelTrainingOptions.SchemaName); ITaskManager taskManager1 = taskManager; var optionsDictionary2 = optionsDictionary1; Guid[] guidArray = { guid }; TimeSpan expiresAfter1 = expiresAfter; mergeTasks.Add(taskManager1.RegisterDeferredTaskAsync(optionsDictionary2, guidArray, expiresAfter1)); } await Task.WhenAll(mergeTasks).ConfigureAwait(false); var trainTaskId = await taskManager.RegisterDeferredTaskAsync(new RfmTrainingWorkerOptionsDictionary(modelTrainingOptions.ModelEntityTypeString, modelTrainingOptions.ModelTypeString, modelTrainingOptions.SchemaName, modelTrainingOptions.SourceTargetTableNamesMap.Values.ToList(), modelTrainingOptions.ModelOptions), mergeTasks.Select(t => t.Result), expiresAfter).ConfigureAwait(false); return(trainTaskId); }
public static Task <Guid> RegisterRfmModelTrainingTaskChainAsync( this ITaskManager taskManager, ModelTrainingTaskOptions modelTrainingOptions, IDataSourceOptionsCollection dataSourceOptions, TimeSpan expiresAfter) { return(taskManager.RegisterRfmModelTrainingTaskChainAsync(modelTrainingOptions, dataSourceOptions, expiresAfter, Enumerable.Empty <Guid>())); }
public async Task RegisterAll() { try { var taskManager = ServiceLocator.ServiceProvider.GetService <ITaskManager>(); var dataSourceOptions = new InteractionDataSourceOptionsDictionary(new InteractionExpandOptions(IpInfo.DefaultFacetKey), 5, 10); var modelTrainingOptions = new ModelTrainingTaskOptions(typeof(GoalsProjectionModel).AssemblyQualifiedName, typeof(Interaction).AssemblyQualifiedName, new Dictionary <string, string> { ["TestCaseId"] = "Id" }, Constants.DemoGoal.ProjectionTableName, Constants.DemoGoal.ProjectionResultTableName); var x = await taskManager.RegisterRfmModelTrainingTaskChainAsync(modelTrainingOptions, dataSourceOptions, TimeSpan.FromHours(5)); Log.Info("TaskAgent RegisterAll taskId=" + x, this); } catch (Exception ex) { Log.Error("TaskAgent RegisterAll exception", ex, this); } }
public static async Task RegisterRfmModelTaskChainAsync( this ITaskManager taskManager, TimeSpan expiresAfter) { // Define workers parameters // datasource for PurchaseOutcomeModel projection var interactionDataSourceOptionsDictionary = new InteractionDataSourceOptionsDictionary(new InteractionExpandOptions(IpInfo.DefaultFacetKey), 5, 10); // datasource for ContactModel protection var contactDataSourceOptionsDictionary = new ContactDataSourceOptionsDictionary(new ContactExpandOptions(PersonalInformation.DefaultFacetKey, EmailAddressList.DefaultFacetKey, ContactBehaviorProfile.DefaultFacetKey, RfmContactFacet.DefaultFacetKey) , 5, 10); var modelTrainingOptions = new ModelTrainingTaskOptions( // assembly name of our processing engine model (PurchaseInteractionModel:IModel<Interaction>) typeof(PurchaseInteractionModel).AssemblyQualifiedName, // assembly name of entity for our processing engine model (PurchaseInteractionModel:IModel<Interaction>) typeof(Interaction).AssemblyQualifiedName, // custom options that we pass to PurchaseInteractionModel new Dictionary <string, string> { ["TestCaseId"] = "Id" }, // projection tableName of PurchaseOutcomeModel, must be equal to first parameter of 'CreateTabular' method => PurchaseOutcomeModel.cs: CreateTabular("PurchaseOutcome", ...) "PurchaseOutcome", // name of resulted table (any name) "DemoResultTable"); var projectionDictionary = new ProjectionWorkerOptionsDictionary( modelTrainingOptions.ModelEntityTypeString, modelTrainingOptions.ModelTypeString, expiresAfter, modelTrainingOptions.SchemaName, modelTrainingOptions.ModelOptions); var evaluationDictionary = new EvaluationWorkerOptionsDictionary( typeof(RfmEvaluationWorker).AssemblyQualifiedName, typeof(ContactModel).AssemblyQualifiedName, new Dictionary <string, string> { ["TestCaseId"] = "Id" }, "Evaluator.Schema", expiresAfter); // Register chain of Tasks // 1) Register Projection-worker Guid projectionTaskId = await taskManager.RegisterDistributedTaskAsync( interactionDataSourceOptionsDictionary, projectionDictionary, // no prerequisite tasks Enumerable.Empty <Guid>(), expiresAfter).ConfigureAwait(false); // 2) Register Merge-worker var mergeTaskIds = new List <Task <Guid> >(); foreach (var targetTableNames in modelTrainingOptions.SourceTargetTableNamesMap) { var mergeWorkerOptionsDictionary = new MergeWorkerOptionsDictionary(targetTableNames.Value, targetTableNames.Key, expiresAfter, modelTrainingOptions.SchemaName); mergeTaskIds.Add( taskManager.RegisterDeferredTaskAsync( mergeWorkerOptionsDictionary, // execute after Projection task new[] { projectionTaskId }, expiresAfter)); } await Task.WhenAll(mergeTaskIds).ConfigureAwait(false); // 3) Register Train-worker var trainWorkerOptionsDictionary = new RfmTrainingWorkerOptionsDictionary( modelTrainingOptions.ModelEntityTypeString, modelTrainingOptions.ModelTypeString, modelTrainingOptions.SchemaName, modelTrainingOptions.SourceTargetTableNamesMap.Values.ToList(), modelTrainingOptions.ModelOptions); Guid trainTaskId = await taskManager.RegisterDeferredTaskAsync( trainWorkerOptionsDictionary, // execute after Merge task mergeTaskIds.Select(t => t.Result), expiresAfter).ConfigureAwait(false); // 4) Register Evaluate worker Guid evaluateTaskId = await taskManager.RegisterDistributedTaskAsync( contactDataSourceOptionsDictionary, evaluationDictionary, // execute after Train worker new[] { trainTaskId }, expiresAfter) .ConfigureAwait(false); }