Skip to content

Commit

Permalink
Updates as per conversation
Browse files Browse the repository at this point in the history
Adding resolved codes
  • Loading branch information
johnml1135 committed Jan 5, 2024
1 parent f79e093 commit b9660f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/SIL.Machine.AspNetCore/Services/NmtPreprocessBuildJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class NmtPreprocessBuildJob : HangfireBuildJob<IReadOnlyList<Corpus>>
{
private readonly ISharedFileService _sharedFileService;
private readonly ICorpusService _corpusService;
private readonly ILanguageTagService _languageTagService;

public NmtPreprocessBuildJob(
IPlatformService platformService,
Expand All @@ -15,12 +16,14 @@ public NmtPreprocessBuildJob(
ILogger<NmtPreprocessBuildJob> logger,
IBuildJobService buildJobService,
ISharedFileService sharedFileService,
ICorpusService corpusService
ICorpusService corpusService,
ILanguageTagService languageTagService
)
: base(platformService, engines, lockFactory, buildJobService, logger)
{
_sharedFileService = sharedFileService;
_corpusService = corpusService;
_languageTagService = languageTagService;
}

protected override async Task DoWorkAsync(
Expand All @@ -36,11 +39,22 @@ CancellationToken cancellationToken

// Log summary of build data
JsonObject _buildPreprocessSummary =
new() { { "event", "build_preprocess" }, { "engine_id", engineId }, { "build_id", buildId } };
new() { { "Event", "BuildPreprocess" }, { "EngineId", engineId }, { "BuildId", buildId } };
foreach (KeyValuePair<string, int> kvp in counts)
{
_buildPreprocessSummary.Add(kvp.Key, kvp.Value);
}
TranslationEngine? engine = await Engines.GetAsync(e => e.EngineId == engineId, cancellationToken);
if (engine is null)
throw new OperationCanceledException($"Engine {engineId} does not exist. Build canceled.");
_buildPreprocessSummary.Add(
"SourceLanguageResolved",
_languageTagService.ConvertToFlores200Code(engine.SourceLanguage)
);
_buildPreprocessSummary.Add(
"TargetLanguageResolved",
_languageTagService.ConvertToFlores200Code(engine.TargetLanguage)
);
Logger.LogInformation("{summary}", _buildPreprocessSummary.ToJsonString());

await using (await @lock.WriterLockAsync(cancellationToken: cancellationToken))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ public override object ActivateJob(Type jobType)
Substitute.For<ILogger<NmtPreprocessBuildJob>>(),
_env.BuildJobService,
_env.SharedFileService,
Substitute.For<ICorpusService>()
Substitute.For<ICorpusService>(),
new LanguageTagService()
);
}
if (jobType == typeof(NmtPostprocessBuildJob))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public TestEnvironment()
Logger,
BuildJobService,
SharedFileService,
CorpusService
CorpusService,
new LanguageTagService()
);
}
}
Expand Down

0 comments on commit b9660f8

Please sign in to comment.