update 3rd party dependencies

azure computervision 5.0 -> 6.0
This commit is contained in:
13xforever
2020-10-27 01:08:55 +05:00
parent e634cb199f
commit 949b6c2b29
13 changed files with 36 additions and 36 deletions

View File

@@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.9" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.5" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.5" />

View File

@@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.9" />
</ItemGroup>
<ItemGroup>

View File

@@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.9" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.5" />
</ItemGroup>

View File

@@ -24,7 +24,7 @@ using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.TeamFoundation.Build.WebApi;

View File

@@ -14,7 +14,7 @@ using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.EventArgs;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.EntityFrameworkCore;
using Exception = System.Exception;

View File

@@ -12,7 +12,7 @@ using CompatBot.Utils;
using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using DSharpPlus.EventArgs;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands

View File

@@ -15,7 +15,7 @@ using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.CommandsNext.Converters;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;

View File

@@ -13,7 +13,7 @@ using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using PsnClient.POCOs;
namespace CompatBot.Commands

View File

@@ -139,10 +139,10 @@ namespace CompatBot.Commands
var client = new ComputerVisionClient(new ApiKeyServiceClientCredentials(Config.AzureComputerVisionKey)) { Endpoint = Config.AzureComputerVisionEndpoint };
var result = await client.AnalyzeImageInStreamAsync(
imageStream,
new List<VisualFeatureTypes>
new List<VisualFeatureTypes?>
{
VisualFeatureTypes.Objects,
VisualFeatureTypes.Description
VisualFeatureTypes.Description,
},
cancellationToken: Config.Cts.Token
).ConfigureAwait(false);

View File

@@ -10,7 +10,7 @@ using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands

View File

@@ -30,10 +30,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00737" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00737" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00737" />
<PackageReference Include="Google.Apis.Drive.v3" Version="1.49.0.2091" />
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00744" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00744" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00744" />
<PackageReference Include="Google.Apis.Drive.v3" Version="1.49.0.2117" />
<PackageReference Include="ksemenenko.ColorThief" Version="1.1.1.4" />
<PackageReference Include="MathParser.org-mXparser" Version="4.4.2" />
<PackageReference Include="MegaApiClient" Version="1.8.2" />
@@ -41,17 +41,17 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.15.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.15.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.8">
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.5" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.153.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
@@ -65,7 +65,7 @@
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.1" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0010" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.IO.Pipelines" Version="4.7.2" />
<PackageReference Include="System.IO.Pipelines" Version="4.7.3" />
</ItemGroup>
<ItemGroup>

View File

@@ -24,7 +24,7 @@ namespace CompatBot.EventHandlers
private readonly DiscordClient client;
private readonly ComputerVisionClient cvClient = new ComputerVisionClient(new ApiKeyServiceClientCredentials(Config.AzureComputerVisionKey)) {Endpoint = Config.AzureComputerVisionEndpoint};
private readonly SemaphoreSlim workSemaphore = new SemaphoreSlim(0);
private readonly ConcurrentQueue<(MessageCreateEventArgs evt, string readOperationId)> workQueue = new ConcurrentQueue<(MessageCreateEventArgs args, string readOperationId)>();
private readonly ConcurrentQueue<(MessageCreateEventArgs evt, Guid readOperationId)> workQueue = new ConcurrentQueue<(MessageCreateEventArgs args, Guid readOperationId)>();
public static int MaxQueueLength { get; private set; } = 0;
internal MediaScreenshotMonitor(DiscordClient client)
@@ -53,15 +53,15 @@ namespace CompatBot.EventHandlers
return;
var images = Vision.GetImageAttachment(message).ToList();
var tasks = new List<Task<BatchReadFileHeaders>>(images.Count);
var tasks = new List<Task<ReadHeaders>>(images.Count);
foreach (var img in images)
tasks.Add(cvClient.BatchReadFileAsync(img.Url, Config.Cts.Token));
tasks.Add(cvClient.ReadAsync(img.Url, null, Config.Cts.Token));
foreach (var t in tasks)
{
try
{
var headers = await t.ConfigureAwait(false);
workQueue.Enqueue((evt, new Uri(headers.OperationLocation).Segments.Last()));
workQueue.Enqueue((evt, new Guid(new Uri(headers.OperationLocation).Segments.Last())));
workSemaphore.Release();
}
catch (Exception ex)
@@ -76,7 +76,7 @@ namespace CompatBot.EventHandlers
if (string.IsNullOrEmpty(Config.AzureComputerVisionKey))
return;
string reEnqueId = null;
Guid? reEnqueId = null;
do
{
await workSemaphore.WaitAsync(Config.Cts.Token).ConfigureAwait(false);
@@ -97,17 +97,17 @@ namespace CompatBot.EventHandlers
try
{
var result = await cvClient.GetReadOperationResultAsync(item.readOperationId, Config.Cts.Token).ConfigureAwait(false);
if (result.Status == TextOperationStatusCodes.Succeeded)
var result = await cvClient.GetReadResultAsync(item.readOperationId, Config.Cts.Token).ConfigureAwait(false);
if (result.Status == OperationStatusCodes.Succeeded)
{
if (result.RecognitionResults.SelectMany(r => r.Lines).Any())
if (result.AnalyzeResult?.ReadResults?.SelectMany(r => r.Lines).Any() ?? false)
{
var cnt = true;
var prefix = $"[{item.evt.Message.Id % 100:00}]";
var ocrText = new StringBuilder($"OCR result of message <{item.evt.Message.JumpLink}>:").AppendLine();
Config.Log.Debug($"{prefix} OCR result of message {item.evt.Message.JumpLink}:");
var duplicates = new HashSet<string>();
foreach (var r in result.RecognitionResults)
foreach (var r in result.AnalyzeResult.ReadResults)
foreach (var l in r.Lines)
{
ocrText.AppendLine(l.Text.Sanitize());
@@ -143,7 +143,7 @@ namespace CompatBot.EventHandlers
}
}
}
else if (result.Status == TextOperationStatusCodes.NotStarted || result.Status == TextOperationStatusCodes.Running)
else if (result.Status == OperationStatusCodes.NotStarted || result.Status == OperationStatusCodes.Running)
{
workQueue.Enqueue(item);
reEnqueId ??= item.readOperationId;

View File

@@ -10,12 +10,12 @@ using CompatBot.Commands.Converters;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.EventHandlers;
using CompatBot.ThumbScrapper;
using CompatBot.Utils;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.Extensions.Configuration.UserSecrets;
using Microsoft.Extensions.DependencyInjection;
@@ -110,7 +110,7 @@ namespace CompatBot
var backgroundTasks = Task.WhenAll(
AmdDriverVersionProvider.RefreshAsync(),
#if !DEBUG
GameTdbScraper.RunAsync(Config.Cts.Token),
ThumbScrapper.GameTdbScraper.RunAsync(Config.Cts.Token),
#endif
StatsStorage.BackgroundSaveAsync(),
CompatList.ImportCompatListAsync()