public async Task PredictAndApplyLabelAsync(int number, string title, string body, ILogger logger) { var corefxIssue = new GitHubIssue { ID = number.ToString(), Title = title, Description = body }; string label = await Predictor.PredictAsync(corefxIssue, logger); if (label != null) { var issueUpdate = new IssueUpdate(); issueUpdate.AddLabel(label); await _client.Issue.Update(_repoOwner, _repoName, number, issueUpdate); logger.LogInformation($"Issue {corefxIssue.ID} : \"{corefxIssue.Title}\" was labeled as: {label}"); } else { logger.LogInformation($"The Model is not able to assign the label to the Issue {corefxIssue.ID} confidently."); } }
public async Task PredictAndApplyLabelAsync(int number, string title, string body, ILogger logger) { if (_client == null) { await GitSetupAsync(); } var corefxIssue = new GitHubIssue { Number = number, Title = title, Body = body }; string label = Predictor.Predict(corefxIssue, logger, _threshold); Issue issueGithubVersion = await _client.Issue.Get(_repoOwner, _repoName, number); if (label != null && issueGithubVersion.Labels.Count == 0) { var issueUpdate = new IssueUpdate(); issueUpdate.AddLabel(label); issueUpdate.Milestone = issueGithubVersion.Milestone?.Number; // The number of milestone associated with the issue. await _client.Issue.Update(_repoOwner, _repoName, number, issueUpdate); } else { logger.LogInformation($"! The Model is not able to assign the label to the Issue {corefxIssue.Number} confidently."); } }
public async Task PredictAndApplyLabelAsync(int number, string title, string body, int?milestone, ILogger logger) { if (_client == null) { await GitSetupAsync(); } var corefxIssue = new GitHubIssue { ID = number.ToString(), Title = title, Description = body }; string label = await Predictor.PredictAsync(corefxIssue, logger, _threshold); if (label != null) { var issueUpdate = new IssueUpdate(); issueUpdate.AddLabel(label); issueUpdate.Milestone = milestone; // The number of milestone associated with the issue. await _client.Issue.Update(_repoOwner, _repoName, number, issueUpdate); } else { logger.LogInformation($"! The Model is not able to assign the label to the Issue {corefxIssue.ID} confidently."); } }
public async Task <LabelSuggestion> PredictUsingModelsFromStorageQueue(string owner, string repo, int number) { if (_regex == null) { _regex = new Regex(@"@[a-zA-Z0-9_//-]+"); } var modelHolder = _modelHolderFactory.CreateModelHolder(owner, repo); if (modelHolder == null) { throw new InvalidOperationException($"Repo {owner}/{repo} is not yet configured for label prediction."); } if (!modelHolder.IsIssueEngineLoaded || (!modelHolder.UseIssuesForPrsToo && !modelHolder.IsPrEngineLoaded)) { throw new InvalidOperationException("load engine before calling predict"); } var iop = await _gitHubClientWrapper.GetIssue(owner, repo, number); bool isPr = iop.PullRequest != null; string body = iop.Body ?? string.Empty; var userMentions = _regex.Matches(body).Select(x => x.Value).ToArray(); LabelSuggestion labelSuggestion = null; if (isPr && !_useIssueLabelerForPrsToo) { var prModel = await CreatePullRequest(owner, repo, iop.Number, iop.Title, iop.Body, userMentions, iop.User.Login); labelSuggestion = Predictor.Predict(prModel, _logger, modelHolder); _logger.LogInformation("predicted with pr model the new way"); _logger.LogInformation(string.Join(",", labelSuggestion.LabelScores.Select(x => x.LabelName))); return(labelSuggestion); } var issueModel = CreateIssue(iop.Number, iop.Title, iop.Body, userMentions, iop.User.Login); labelSuggestion = Predictor.Predict(issueModel, _logger, modelHolder); _logger.LogInformation("predicted with issue model the new way"); _logger.LogInformation(string.Join(",", labelSuggestion.LabelScores.Select(x => x.LabelName))); return(labelSuggestion); }
public async Task PredictAndApplyLabelAsync(int number, string title, string body, GithubObjectType issueOrPr, ILogger logger) { if (_client == null) { await GitSetupAsync(); } if (_regex == null) { _regex = new Regex(@"@[a-zA-Z0-9_//-]+"); } var userMentions = _regex.Matches(body).Select(x => x.Value).ToArray(); string label; if (issueOrPr == GithubObjectType.Issue) { IssueModel issue = CreateIssue(number, title, body, userMentions); label = Predictor.Predict(issue, logger, _threshold); } else { PrModel pr = await CreatePullRequest(number, title, body, userMentions); label = Predictor.Predict(pr, logger, _threshold); } Issue issueGithubVersion = await _client.Issue.Get(_repoOwner, _repoName, number); if (label != null && issueGithubVersion.Labels.Count == 0) { var issueUpdate = new IssueUpdate(); issueUpdate.AddLabel(label); issueUpdate.Milestone = issueGithubVersion.Milestone?.Number; // The number of milestone associated with the issue. await _client.Issue.Update(_repoOwner, _repoName, number, issueUpdate); } else { logger.LogInformation($"! The Model is not able to assign the label to the {issueOrPr} {number} confidently."); } }
public async Task PredictAndApplyLabelAsync(int number, string title, string body, GithubObjectType issueOrPr, ILogger logger) { if (_client == null) { await GitSetupAsync(); } var corefxIssue = new GitHubIssue { Number = number, Title = title, Body = body, IssueOrPr = issueOrPr, IsPR = issueOrPr == GithubObjectType.PullRequest, FilePaths = string.Empty }; if (corefxIssue.IsPR) { IReadOnlyList <PullRequestFile> prFiles = await _client.PullRequest.Files(_repoOwner, _repoName, number); corefxIssue.FilePaths = String.Join(";", prFiles.Select(x => x.FileName)); } string label = Predictor.Predict(corefxIssue, logger, _threshold); Issue issueGithubVersion = await _client.Issue.Get(_repoOwner, _repoName, number); if (label != null && issueGithubVersion.Labels.Count == 0) { var issueUpdate = new IssueUpdate(); issueUpdate.AddLabel(label); issueUpdate.Milestone = issueGithubVersion.Milestone?.Number; // The number of milestone associated with the issue. await _client.Issue.Update(_repoOwner, _repoName, number, issueUpdate); } else { logger.LogInformation($"! The Model is not able to assign the label to the {issueOrPr} {corefxIssue.Number} confidently."); } }
public async Task PredictAndApplyLabelAsync(int number, string title, string body, GithubObjectType issueOrPr, ILogger logger) { if (_client == null) { await GitSetupAsync(); } var corefxIssue = new GitHubIssue { Number = number, Title = title, Body = body, IssueOrPr = issueOrPr }; string label = Predictor.Predict(corefxIssue, logger, _threshold); Issue issueGithubVersion = await _client.Issue.Get(_repoOwner, _repoName, number); if (label.Equals("area-System.Net.Http.SocketsHttpHandler", StringComparison.OrdinalIgnoreCase)) { label = "area-System.Net.Http"; } if (label != null && issueGithubVersion.Labels.Count == 0) { var issueUpdate = new IssueUpdate(); issueUpdate.AddLabel(label); issueUpdate.Milestone = issueGithubVersion.Milestone?.Number; // The number of milestone associated with the issue. await _client.Issue.Update(_repoOwner, _repoName, number, issueUpdate); } else { logger.LogInformation($"! The Model is not able to assign the label to the {issueOrPr} {corefxIssue.Number} confidently."); } }