Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/Serval/src/Serval.Client/Client.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11522,10 +11522,6 @@ public partial class TranslationBuild
[Newtonsoft.Json.JsonProperty("phases", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.IList<Phase>? Phases { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("analysis", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.Obsolete]
public System.Collections.Generic.IList<ParallelCorpusAnalysis>? Analysis { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("targetQuoteConvention", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? TargetQuoteConvention { get; set; } = default!;

Expand Down Expand Up @@ -11749,27 +11745,6 @@ public enum PhaseStage

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.7.1.0 (NJsonSchema v11.6.1.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ParallelCorpusAnalysis
{

[Newtonsoft.Json.JsonProperty("parallelCorpusRef", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public string ParallelCorpusRef { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("sourceQuoteConvention", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.Obsolete]
public string? SourceQuoteConvention { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("targetQuoteConvention", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public string TargetQuoteConvention { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("canDenormalizeQuotes", Required = Newtonsoft.Json.Required.Always)]
public bool CanDenormalizeQuotes { get; set; } = default!;

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.7.1.0 (NJsonSchema v11.6.1.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class TranslationEngine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public static IServalConfigurator AddTranslationDataAccess(this IServalConfigura
c.Indexes.CreateOrUpdateAsync(
new CreateIndexModel<Build>(Builders<Build>.IndexKeys.Ascending(b => b.DateFinished))
),
// Remove the old parallel corpus analysis
c =>
c.UpdateManyAsync(
Builders<Build>.Filter.Exists("analysis"),
Builders<Build>.Update.Unset("analysis")
),
]
);
configurator.DataAccess.AddRepository<Pretranslation>(
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions src/Serval/src/Serval.Translation/Dtos/TranslationBuildDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public record TranslationBuildDto
public string? DeploymentVersion { get; init; }
public required ExecutionDataDto ExecutionData { get; init; }
public IReadOnlyList<PhaseDto>? Phases { get; init; }

[Obsolete]
public IReadOnlyList<ParallelCorpusAnalysisDto>? Analysis { get; init; }
public string? TargetQuoteConvention { get; init; }
public bool CanDenormalizeQuotes { get; init; }
}
1 change: 0 additions & 1 deletion src/Serval/src/Serval.Translation/Models/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ public record Build : IOwnedEntity
public DateTime? DateStarted { get; set; }
public DateTime? DateCompleted { get; set; }
public IReadOnlyList<Phase>? Phases { get; init; }
public IReadOnlyList<ParallelCorpusAnalysis>? Analysis { get; init; }
public string? TargetQuoteConvention { get; init; }
}

This file was deleted.

10 changes: 0 additions & 10 deletions src/Serval/src/Serval.Translation/Services/DtoMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public TranslationBuildDto Map(Build source)
DeploymentVersion = source.DeploymentVersion,
ExecutionData = Map(source.ExecutionData),
Phases = source.Phases?.Select(Map).ToList(),
Analysis = source.Analysis?.Select(a => Map(a, targetQuoteConvention)).ToList(),
TargetQuoteConvention = targetQuoteConvention,
CanDenormalizeQuotes = targetQuoteConvention != "",
};
Expand Down Expand Up @@ -218,15 +217,6 @@ private static PhaseDto Map(Phase source) =>
Started = source.Started,
};

private static ParallelCorpusAnalysisDto Map(ParallelCorpusAnalysis source, string targetQuoteConvention) =>
new()
{
ParallelCorpusRef = source.ParallelCorpusRef,
TargetQuoteConvention = targetQuoteConvention,
SourceQuoteConvention = "ignore",
CanDenormalizeQuotes = targetQuoteConvention != "",
};

private static ExecutionDataDto Map(ExecutionData source) =>
new()
{
Expand Down
13 changes: 1 addition & 12 deletions src/Serval/src/Serval.Translation/Services/PlatformService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,9 @@ public async Task UpdateTargetQuoteConventionAsync(
Engine? engine = await _engines.GetAsync(engineId, cancellationToken);
if (engine is null)
return;
var analysis = engine
.ParallelCorpora.Select(pc => new ParallelCorpusAnalysis
{
ParallelCorpusRef = pc.Id,
TargetQuoteConvention = quoteConvention,
})
.ToList();
await _builds.UpdateAsync(
b => b.Id == buildId && b.EngineRef == engineId,
u =>
{
u.Set(b => b.TargetQuoteConvention, quoteConvention);
u.Set(b => b.Analysis, analysis);
},
u => u.Set(b => b.TargetQuoteConvention, quoteConvention),
cancellationToken: cancellationToken
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2488,52 +2488,6 @@ await corporaClient.UpdateAsync(
Assert.That(newEngine2.ParallelCorpora[0].TargetCorpora[0].Files.Count, Is.EqualTo(1));
}

[Test]
public async Task MongoMigration_TargetQuoteConvention()
{
await _env.Builds.InsertAsync(
new Build()
{
Id = "111111111111111111111111",
EngineRef = NMT_ENGINE1_ID,
Owner = "client1",
Analysis =
[
new Translation.Models.ParallelCorpusAnalysis()
{
ParallelCorpusRef = "111111111111111111111112",
TargetQuoteConvention = "",
},
new Translation.Models.ParallelCorpusAnalysis()
{
ParallelCorpusRef = "111111111111111111111113",
TargetQuoteConvention = "standard_english",
},
],
}
);

Build? unmigratedBuild = await _env.Builds.GetAsync(b => b.Id == "111111111111111111111111");
Assert.That(unmigratedBuild, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(unmigratedBuild.Analysis, Has.Count.EqualTo(2));
Assert.That(unmigratedBuild.TargetQuoteConvention, Is.Null);
});

await MongoMigrations.MigrateTargetQuoteConvention(
_env.MongoClient.GetDatabase("serval_test").GetCollection<Build>("translation.builds")
);

Build? migratedBuild = await _env.Builds.GetAsync(b => b.Id == "111111111111111111111111");
Assert.That(migratedBuild, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(migratedBuild.Analysis, Has.Count.EqualTo(2));
Assert.That(migratedBuild.TargetQuoteConvention, Is.EqualTo("standard_english"));
});
}

[Test]
public async Task GetAllPretranslationConfidencesAsync_Exists()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
global using Serval.Shared.Contracts;
global using Serval.Shared.Controllers;
global using Serval.Shared.Services;
global using Serval.Translation.Configuration;
global using SIL.DataAccess;
global using SIL.ObjectModel;
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,7 @@ public async Task UpdateTargetQuoteConventionAsync()

build = await env.Builds.GetAsync(c => c.Id == build.Id);

Assert.Multiple(() =>
{
Assert.That(build?.TargetQuoteConvention, Is.EqualTo(expected));
Assert.That(build?.Analysis, Has.Count.EqualTo(1));
});
Assert.That(build?.Analysis?[0].TargetQuoteConvention, Is.EqualTo(expected));
Assert.That(build?.TargetQuoteConvention, Is.EqualTo(expected));
}

[Test]
Expand All @@ -356,11 +351,7 @@ public async Task UpdateTargetQuoteConventionAsync_NoEngine()

build = await env.Builds.GetAsync(c => c.Id == build.Id);

Assert.Multiple(() =>
{
Assert.That(build?.TargetQuoteConvention, Is.Null);
Assert.That(build?.Analysis, Is.Null);
});
Assert.That(build?.TargetQuoteConvention, Is.Null);
}

[Test]
Expand Down Expand Up @@ -391,11 +382,7 @@ public async Task UpdateTargetQuoteConventionAsync_NoParallelCorpora()

build = await env.Builds.GetAsync(c => c.Id == build.Id);

Assert.Multiple(() =>
{
Assert.That(build?.TargetQuoteConvention, Is.EqualTo(""));
Assert.That(build?.Analysis, Has.Count.EqualTo(0));
});
Assert.That(build?.TargetQuoteConvention, Is.Empty);
}

[Test]
Expand Down
Loading