Skip to content

Commit

Permalink
Change SMT model save location to be in build - always do it and auto…
Browse files Browse the repository at this point in the history
…-save when delete.
  • Loading branch information
johnml1135 committed Jun 7, 2024
1 parent a1b7210 commit 346dd30
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/SIL.Machine.AspNetCore/Services/PostprocessBuildJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CancellationToken cancellationToken

await using (await @lock.WriterLockAsync(cancellationToken: CancellationToken.None))
{
int additionalCorpusSize = await SaveModelAsync(engineId);
int additionalCorpusSize = await SaveModelAsync(engineId, buildId);
await PlatformService.BuildCompletedAsync(
buildId,
corpusSize + additionalCorpusSize,
Expand All @@ -43,7 +43,7 @@ await PlatformService.BuildCompletedAsync(
Logger.LogInformation("Build completed ({0}).", buildId);
}

protected virtual Task<int> SaveModelAsync(string engineId)
protected virtual Task<int> SaveModelAsync(string engineId, string buildId)
{
return Task.FromResult(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public async Task<string> CreateJobScriptAsync(
+ $" 'shared_file_uri': '{baseUri}',\n"
+ $" 'shared_file_folder': '{folder}',\n"
+ (buildOptions is not null ? $" 'build_options': '''{buildOptions}''',\n" : "")
// buildRevision + 1 because the build revision is incremented after the build job
// is finished successfully but the file should be saved with the new revision number
+ (engine.IsModelPersisted ? $" 'save_model': '{engineId}',\n" : $"")
+ $" 'clearml': True\n"
+ "}\n"
+ "run(args)\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ IOptionsMonitor<SmtTransferEngineOptions> options
private readonly IRepository<TrainSegmentPair> _trainSegmentPairs = trainSegmentPairs;
private readonly IOptionsMonitor<SmtTransferEngineOptions> _options = options;

protected override async Task<int> SaveModelAsync(string engineId)
protected override async Task<int> SaveModelAsync(string engineId, string buildId)
{
await using (
Stream engineStream = await SharedFileService.OpenReadAsync(
$"models/{engineId}.zip",
$"builds/{buildId}/model.zip",
CancellationToken.None
)
)
Expand Down

0 comments on commit 346dd30

Please sign in to comment.