Skip to content

Commit

Permalink
Better error handling for download endpoint
Browse files Browse the repository at this point in the history
In e2e test, grab current machine.py version
  • Loading branch information
johnml1135 committed Feb 22, 2024
1 parent 525950f commit 8b2765f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ jobs:
steps:
- uses: actions/checkout@v3

# get version of machine.py - MACHINE_PY_IMAGE will force the docker compose to use the proper version of machine.py
- name: Install regctl
uses: iarekylew00t/regctl-installer@v1

- name: Getr Version of Machine.py
run: echo "MACHINE_PY_IMAGE=ghcr.io/sillsdev/machine.py:$(regctl image config ghcr.io/sillsdev/machine.py | jq -r ".config.Labels[\"org.opencontainers.image.version\"]")" >> $GITHUB_ENV

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
Expand Down Expand Up @@ -58,6 +65,10 @@ jobs:
if: ${{ failure() }}
run: docker ps -a && docker logs --since 10m serval_cntr && docker logs --since 10m echo_cntr && docker logs --since 10m machine-engine-cntr && docker logs --since 10m serval-mongo-1 && docker logs --since 10m machine-job-cntr

- name: Stop containers
if: ${{ success() || failure() }}
- name: Stop containers branch
if: ${{ success() || failure() }} and steps.find_matching_branch.outcome != 'success'
run: docker compose -f "../tmp/serval/docker-compose.yml" down

- name: Stop containers main
if: ${{ success() || failure() }} and steps.find_matching_branch.outcome == 'success'
run: docker compose -f "../serval/docker-compose.yml" down
5 changes: 1 addition & 4 deletions src/SIL.Machine.AspNetCore/Services/NmtEngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ISharedFileService sharedFileService
private readonly ClearMLMonitorService _clearMLMonitorService = clearMLMonitorService;
private readonly ILanguageTagService _languageTagService = languageTagService;
private readonly ISharedFileService _sharedFileService = sharedFileService;

public const string ModelDirectory = "models/";

public static string GetModelPath(string engineId, int buildRevision)
Expand Down Expand Up @@ -137,9 +136,7 @@ public async Task<ModelDownloadUrl> GetModelDownloadUrlAsync(
string filepath = GetModelPath(engineId, engine.BuildRevision);
bool fileExists = await _sharedFileService.ExistsAsync(filepath, cancellationToken);
if (!fileExists)
throw new FileNotFoundException(
$"The model should exist to be downloaded but is not there for BuildRevision {engine.BuildRevision}."
);
throw new FileNotFoundException($"The model for build revision , {engine.BuildRevision}, does not exist.");
var expiresAt = DateTime.UtcNow.AddMinutes(MinutesToExpire);
var modelInfo = new ModelDownloadUrl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ ServerCallContext context
{
throw new RpcException(new Status(StatusCode.Aborted, e.Message));
}
catch (FileNotFoundException e)
{
throw new RpcException(new Status(StatusCode.DataLoss, e.Message));
}
}

public override async Task<GetQueueSizeResponse> GetQueueSize(
Expand Down

0 comments on commit 8b2765f

Please sign in to comment.