Skip to content

Commit

Permalink
Broken - needs more work
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Jan 18, 2024
1 parent 79c0832 commit faa6cb3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/SIL.Machine.AspNetCore/Services/ClearMLService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ public async Task<bool> StopTaskAsync(string id, CancellationToken cancellationT
}

public async Task<IReadOnlyList<ClearMLTask>> GetTasksForCurrentQueueAsync(
string? queueName = null,
CancellationToken cancellationToken = default
)
{
var body = new JsonObject { ["name"] = _options.CurrentValue.Queue };
var body = new JsonObject { ["name"] = queueName ?? _options.CurrentValue.Queue };
JsonObject? result = await CallAsync("queues", "get_all_ex", body, cancellationToken);
var tasks = (JsonArray?)result?["data"]?["queues"]?[0]?["entries"];
IEnumerable<string> taskIds = tasks?.Select(t => (string)t?["id"]!) ?? new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ Task StartBuildAsync(

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

Task<int> GetQueueSizeAsync(CancellationToken cancellationToken = default);
Task<int> GetQueueSizeAsync(string? queueName = null, CancellationToken cancellationToken = default);
}
2 changes: 1 addition & 1 deletion src/SIL.Machine.AspNetCore/Services/NmtEngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Task TrainSegmentPairAsync(
throw new NotSupportedException();
}

public Task<int> GetQueueSizeAsync(CancellationToken cancellationToken = default)
public Task<int> GetQueueSizeAsync(string? queueName = null, CancellationToken cancellationToken = default)
{
return Task.FromResult(_clearMLMonitorService.QueueSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ ServerCallContext context
)
{
ITranslationEngineService engineService = GetEngineService(request.EngineType);
return new GetQueueSizeResponse { Size = await engineService.GetQueueSizeAsync(context.CancellationToken) };
return new GetQueueSizeResponse
{
Size = await engineService.GetQueueSizeAsync(request.queueName, context.CancellationToken)
};
}

public override async Task<HealthCheckResponse> HealthCheck(Empty request, ServerCallContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public async Task CancelBuildAsync(string engineId, CancellationToken cancellati
}
}

public Task<int> GetQueueSizeAsync(CancellationToken cancellationToken = default)
public Task<int> GetQueueSizeAsync(string? queueName = null, CancellationToken cancellationToken = default)
{
return Task.FromResult(Convert.ToInt32(_jobStorage.GetMonitoringApi().EnqueuedCount("smt_transfer")));
}
Expand Down

0 comments on commit faa6cb3

Please sign in to comment.