Skip to content

Commit

Permalink
Update from reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Feb 6, 2024
1 parent 99374c9 commit 77a7f9b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Task StartBuildAsync(

Task CancelBuildAsync(string engineId, CancellationToken cancellationToken = default);

Task<ModelPresignedUrl> GetModelPresignedUrlAsync(string engineId, CancellationToken cancellationToken = default);
Task<ModelDownloadUrl> GetModelDownloadUrlAsync(string engineId, CancellationToken cancellationToken = default);

Task<int> GetQueueSizeAsync(CancellationToken cancellationToken = default);

Expand Down
12 changes: 5 additions & 7 deletions src/SIL.Machine.AspNetCore/Services/NmtEngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public async Task CancelBuildAsync(string engineId, CancellationToken cancellati
}
}

public async Task<ModelPresignedUrl> GetModelPresignedUrlAsync(
public async Task<ModelDownloadUrl> GetModelDownloadUrlAsync(
string engineId,
CancellationToken cancellationToken = default
)
Expand All @@ -136,18 +136,16 @@ public async Task<ModelPresignedUrl> GetModelPresignedUrlAsync(
throw new FileNotFoundException(
$"The model should exist to be downloaded but is not there for BuildRevision {engine.BuildRevision}."
);
var modelInfo = new ModelPresignedUrl
var modelInfo = new ModelDownloadUrl
{
PresignedUrl = (
Url = (
await _sharedFileService.GetPresignedUrlAsync(
ISharedFileService.ModelDirectory + filename,
MinutesToExpire
)
).ToString(),
BuildRevision = engine.BuildRevision,
UrlExpirationTime = DateTime
.UtcNow.AddMinutes(MinutesToExpire)
.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz", CultureInfo.InvariantCulture)
ModelRevision = engine.BuildRevision,
ExipiresAt = DateTime.UtcNow.AddMinutes(MinutesToExpire)
};
return modelInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ await engineService.CreateAsync(
request.HasEngineName ? request.EngineName : null,
request.SourceLanguage,
request.TargetLanguage,
request.IsModelRetrievable,
request.IsModelPersisted,
context.CancellationToken
);
return Empty;
Expand Down Expand Up @@ -120,23 +120,23 @@ public override async Task<Empty> CancelBuild(CancelBuildRequest request, Server
return Empty;
}

public override async Task<GetModelPresignedUrlResponse> GetModelPresignedUrl(
GetModelPresignedUrlRequest request,
public override async Task<GetModelDownloadUrlResponse> GetModelDownloadUrl(

Check failure on line 123 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-20.04

The type or namespace name 'GetModelDownloadUrlResponse' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 123 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-20.04

The type or namespace name 'GetModelDownloadUrlResponse' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 123 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on windows-latest

The type or namespace name 'GetModelDownloadUrlResponse' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 123 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on windows-latest

The type or namespace name 'GetModelDownloadUrlResponse' could not be found (are you missing a using directive or an assembly reference?)
GetModelDownloadUrlRequest request,

Check failure on line 124 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-20.04

The type or namespace name 'GetModelDownloadUrlRequest' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 124 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-20.04

The type or namespace name 'GetModelDownloadUrlRequest' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 124 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on windows-latest

The type or namespace name 'GetModelDownloadUrlRequest' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 124 in src/SIL.Machine.AspNetCore/Services/ServalTranslationEngineServiceV1.cs

View workflow job for this annotation

GitHub Actions / Build on windows-latest

The type or namespace name 'GetModelDownloadUrlRequest' could not be found (are you missing a using directive or an assembly reference?)
ServerCallContext context
)
{
try
{
ITranslationEngineService engineService = GetEngineService(request.EngineType);
ModelPresignedUrl modelPresignedUrl = await engineService.GetModelPresignedUrlAsync(
ModelDownloadUrl modelDownloadUrl = await engineService.GetModelDownloadUrlAsync(
request.EngineId,
context.CancellationToken
);
return new GetModelPresignedUrlResponse
return new GetModelDownloadUrlResponse
{
PresignedUrl = modelPresignedUrl.PresignedUrl,
BuildRevision = modelPresignedUrl.BuildRevision,
UrlExpirationTime = modelPresignedUrl.UrlExpirationTime
Url = modelDownloadUrl.Url,
ModelRevision = modelDownloadUrl.ModelRevision,
ExpiresAt = modelDownloadUrl.ExipiresAt.ToTimestamp()
};
}
catch (InvalidOperationException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private async Task CancelBuildJobAsync(string engineId, CancellationToken cancel
await _platformService.BuildCanceledAsync(buildId, CancellationToken.None);
}

public Task<ModelPresignedUrl> GetModelPresignedUrlAsync(
public Task<ModelDownloadUrl> GetModelDownloadUrlAsync(
string engineId,
CancellationToken cancellationToken = default
)
Expand Down
11 changes: 11 additions & 0 deletions src/SIL.Machine/Translation/ModelDownloadUrl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace SIL.Machine.Translation
{
public class ModelDownloadUrl
{
public string Url { get; set; } = default;
public int ModelRevision { get; set; } = default;
public DateTime ExipiresAt { get; set; } = default;
}
}
9 changes: 0 additions & 9 deletions src/SIL.Machine/Translation/ModelPresignedUrl.cs

This file was deleted.

0 comments on commit 77a7f9b

Please sign in to comment.